ilya-biryukov added a comment.

In, @simark wrote:

>   It seems to me like
> changes in command line arguments (adding -DMACRO=1) are not taken into 
> account
>  when changing configuration.

It looks like a bug in the preamble handling. (It does not check if macros were 
You can workaround that by making sure the preamble ends before your code 
starts (preamble only captures preprocessor directives, so any C++ decl will 
end it):

    Annotations SourceAnnotations(R"cpp(
  int avoid_preamble;
  #ifndef MACRO
  $before[[static void bob() {}]]
  $after[[static void bob() {}]]
  /// ....

Comment at: unittests/clangd/XRefsTests.cpp:260
+TEST(DidChangeConfiguration, DifferentDeclaration) {
+  Annotations SourceAnnotations(R"cpp(
I'd move it to `ClangdTests.cpp`, generic `ClangdServer` tests usually go 
there. It's fine to `#include "Annotations.h"` there, too, even though it 
hasn't been used before.

Comment at: unittests/clangd/XRefsTests.cpp:271
+  MockCompilationDatabase CDB(/*UseRelPaths=*/true);
+  MockFSProvider FS;
Specifying `/*UseRelPath=*/true` is not necessary for this test, default value 
should do.

  rCTE Clang Tools Extra

cfe-commits mailing list

Reply via email to