[PATCH] D70494: [clangd] Fix diagnostic location for macro expansions

Haojian Wu via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Nov 22 04:52:44 PST 2019


hokein added inline comments.


================
Comment at: clang-tools-extra/clangd/Diagnostics.cpp:121
   const SourceManager &SM = Info.getSourceManager();
+  const SourceLocation &DiagLoc = SM.getFileLoc(Info.getLocation());
   SourceLocation IncludeInMainFile;
----------------
should we use getExpansionLoc? getFileLoc returns a spelling location if it comes from a macro argument, but I think it doesn't matter.


================
Comment at: clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp:944
 
 TEST(IgnoreDiags, FromNonWrittenSources) {
   Annotations Main(R"cpp(
----------------
this doesn't belong to IgnoreDiags any more, I think, should be `DiagsInHeaders`, the same to the newly-added test.


================
Comment at: clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp:978
+  #define X foo
+  X;)cpp");
+  TestTU TU = TestTU::withCode(Main.code());
----------------
could you add one more test case where foo is spelled at macro argument? I believe it was broken as well before this patch.

```
#define X(arg) arg
X(foo);
```


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D70494/new/

https://reviews.llvm.org/D70494





More information about the cfe-commits mailing list