[PATCH] D44423: [clangd] Use the macro name range as the definition range.

Haojian Wu via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Mar 13 05:45:22 PDT 2018


hokein created this revision.
hokein added a reviewer: sammccall.
Herald added subscribers: ioeric, jkorous-apple, ilya-biryukov, klimek.

This also aligns with the behavior of declarations.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D44423

Files:
  clangd/XRefs.cpp
  unittests/clangd/XRefsTests.cpp


Index: unittests/clangd/XRefsTests.cpp
===================================================================
--- unittests/clangd/XRefsTests.cpp
+++ unittests/clangd/XRefsTests.cpp
@@ -207,15 +207,15 @@
 
       R"cpp(// Macro
         #define MACRO 0
-        #define [[MACRO 1]]
+        #define [[MACRO]] 1
         int main() { return ^MACRO; }
         #define MACRO 2
         #undef macro
       )cpp",
 
       R"cpp(// Macro
        class TTT { public: int a; };
-       #define [[FF(S) if (int b = S.a) {}]]
+       #define [[FF]](S) if (int b = S.a) {}
        void f() {
          TTT t;
          F^F(t);
Index: clangd/XRefs.cpp
===================================================================
--- clangd/XRefs.cpp
+++ clangd/XRefs.cpp
@@ -219,9 +219,8 @@
   }
 
   for (auto Item : MacroInfos) {
-    SourceRange SR(Item.Info->getDefinitionLoc(),
-                   Item.Info->getDefinitionEndLoc());
-    auto L = makeLocation(AST, SR);
+    auto Loc = Item.Info->getDefinitionLoc();
+    auto L = makeLocation(AST, SourceRange(Loc, Loc));
     if (L)
       Result.push_back(*L);
   }


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D44423.138163.patch
Type: text/x-patch
Size: 1103 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20180313/139da1bb/attachment.bin>


More information about the cfe-commits mailing list