intellij: Bazel Plugin Inteferes with CLion Code Analysis, Making CLion Report Nonexistent Errors

Description of the bug:

After upgraded Bazel for CLion plugin to 2024.03.12.0.1-api-version-233, cleared CLion cache and did a full project sync, CLion can’t correctly analysis my C++ project, reporting nonexistent problems.

The project builds. image

CLion seems to recognize a legitimate C++ source file as C file (and this error is reported on a comment): image

and reports a lot of errors: image

Other files seems don’t have such funny error, but still have issues like failed to parse a FMT_COMPILE macro. image

All those issues disappeared after downgraded the Bazel plugin to 2024.02.27.0.1-api-version-233, cleared CLion cache and did a full project sync.

Which category does this issue belong to?

CLion

What’s the simplest, easiest way to reproduce this bug? Please provide a minimal example if possible.

I’m still struggling understanding this particular problem. Seems that not all .cc source files are affected by this problem. Because the project is proprietary (for now) I can’t share you with the exact code that triggers such problem.

Which Intellij IDE are you using? Please provide the specific version.

CLion 2023.3.4

What programming languages and tools are you using? Please provide specific versions.

C++, clang 17.0.6 (from archlinux repo), Bazel 6.2.0

What Bazel plugin version are you using?

2024.03.12.0.1-api-version-233

Have you found anything relevant by searching the web?

  • I searched GitHub issues with CLion or C++ tags and no relevant result showed.
  • I have no permission to view the email threads.
  • Most Google search results are totally irrelevant.

Any other information, logs, or outputs that you want to share?

I edited the clion.sh launcher script and added these three lines to it:

export CC=/usr/bin/clang
export CXX=/usr/bin/clang++
export BAZEL_USE_CPP_ONLY_TOOLCHAIN=1

I compared the “Show Compiler Info” result between two Bazel plugin versions, and found that the new Bazel plugin inserted a whole bunch of things like

......
+       -ibazelasio/detail/assert.hpp=/cache/bazel/_bazel_lk/4faefe1c41672e714c7262fd5f5f7a1c/external/com_github_chriskohlhoff_asio/asio/detail/assert.hpp
+       -ibazelasio/detail/atomic_count.hpp=/cache/bazel/_bazel_lk/4faefe1c41672e714c7262fd5f5f7a1c/external/com_github_chriskohlhoff_asio/asio/detail/atomic_count.hpp
+       -ibazelasio/detail/base_from_cancellation_state.hpp=/cache/bazel/_bazel_lk/4faefe1c41672e714c7262fd5f5f7a1c/external/com_github_chriskohlhoff_asio/asio/detail/base_from_cancellation_state.hpp
+       -ibazelasio/detail/base_from_completion_cond.hpp=/cache/bazel/_bazel_lk/4faefe1c41672e714c7262fd5f5f7a1c/external/com_github_chriskohlhoff_asio/asio/detail/base_from_completion_cond.hpp
+       -ibazelasio/detail/bind_handler.hpp=/cache/bazel/_bazel_lk/4faefe1c41672e714c7262fd5f5f7a1c/external/com_github_chriskohlhoff_asio/asio/detail/bind_handler.hpp
+       -ibazelasio/detail/blocking_executor_op.hpp=/cache/bazel/_bazel_lk/4faefe1c41672e714c7262fd5f5f7a1c/external/com_github_chriskohlhoff_asio/asio/detail/blocking_executor_op.hpp
......
+       -ibazelinclude/gsl/algorithm=/cache/bazel/_bazel_lk/4faefe1c41672e714c7262fd5f5f7a1c/external/com_github_microsoft_gsl/include/gsl/algorithm
+       -ibazelinclude/gsl/assert=/cache/bazel/_bazel_lk/4faefe1c41672e714c7262fd5f5f7a1c/external/com_github_microsoft_gsl/include/gsl/assert
+       -ibazelinclude/gsl/byte=/cache/bazel/_bazel_lk/4faefe1c41672e714c7262fd5f5f7a1c/external/com_github_microsoft_gsl/include/gsl/byte
+       -ibazelinclude/gsl/gsl_algorithm=/cache/bazel/_bazel_lk/4faefe1c41672e714c7262fd5f5f7a1c/external/com_github_microsoft_gsl/include/gsl/gsl_algorithm
+       -ibazelinclude/gsl/gsl_assert=/cache/bazel/_bazel_lk/4faefe1c41672e714c7262fd5f5f7a1c/external/com_github_microsoft_gsl/include/gsl/gsl_assert
+       -ibazelinclude/gsl/gsl_byte=/cache/bazel/_bazel_lk/4faefe1c41672e714c7262fd5f5f7a1c/external/com_github_microsoft_gsl/include/gsl/gsl_byte
+       -ibazelinclude/gsl/gsl=/cache/bazel/_bazel_lk/4faefe1c41672e714c7262fd5f5f7a1c/external/com_github_microsoft_gsl/include/gsl/gsl
......
+       -ibazelinternal/spinlock.h=/cache/bazel/_bazel_lk/4faefe1c41672e714c7262fd5f5f7a1c/external/com_google_absl/absl/base/internal/spinlock.h
+       -ibazelinternal/spinlock_wait.h=/cache/bazel/_bazel_lk/4faefe1c41672e714c7262fd5f5f7a1c/external/com_google_absl/absl/base/internal/spinlock_wait.h
+       -ibazelinternal/string_constant.h=/cache/bazel/_bazel_lk/4faefe1c41672e714c7262fd5f5f7a1c/external/com_google_absl/absl/strings/internal/string_constant.h
+       -ibazelinternal/sysinfo.h=/cache/bazel/_bazel_lk/4faefe1c41672e714c7262fd5f5f7a1c/external/com_google_absl/absl/base/internal/sysinfo.h
+       -ibazelinternal/thread_identity.h=/cache/bazel/_bazel_lk/4faefe1c41672e714c7262fd5f5f7a1c/external/com_google_absl/absl/base/internal/thread_identity.h
+       -ibazelinternal/throw_delegate.h=/cache/bazel/_bazel_lk/4faefe1c41672e714c7262fd5f5f7a1c/external/com_google_absl/absl/base/internal/throw_delegate.h
+       -ibazelinternal/tsan_mutex_interface.h=/cache/bazel/_bazel_lk/4faefe1c41672e714c7262fd5f5f7a1c/external/com_google_absl/absl/base/internal/tsan_mutex_interface.h
+       -ibazelinternal/unaligned_access.h=/cache/bazel/_bazel_lk/4faefe1c41672e714c7262fd5f5f7a1c/external/com_google_absl/absl/base/internal/unaligned_access.h
......

to the “Compiler switches” section. All other sections remain unchanged (orders may be changed as I sorted them first to do a diff).

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Comments: 15 (1 by maintainers)

Commits related to this issue

Most upvoted comments

We disabled these changes by default with #6534. If you still experience this issue, please reopen this ticket.

Edit: The fix is available in v2024.07.02-RC-1

My apologies for closing this too early. We provided a workaround in the related PR, you can set bazel.sync.resolve.virtual.includes to false to disable these -ibazel hints and use the old logic with implicit heuristics to find strip_include_prefix headers. But I guess we still would like to find the reason why -ibazel does not work for you.

@erinacio the -ibazel feature was added to the old engine (to be precise to clangd, and clangd is not used for navigation when resharper engine is enabled). This is caused by #6007. Unfortunately we’ve accidentally removed the feature switch and indeed the only workaround is to use Resharper engine. But it can’t be used with 2023.3. cc @LeFrosch