[PATCH] D57228: [clangd] Make USRs for macros to be position independent

Kadir Cetinkaya via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Jan 29 03:19:22 PST 2019


This revision was automatically updated to reflect the committed changes.
Closed by commit rL352481: [clangd] Make USRs for macros to be position independent (authored by kadircet, committed by ).
Herald added a subscriber: llvm-commits.

Repository:
  rL LLVM

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

https://reviews.llvm.org/D57228

Files:
  clang-tools-extra/trunk/clangd/XRefs.cpp
  clang-tools-extra/trunk/unittests/clangd/SymbolInfoTests.cpp


Index: clang-tools-extra/trunk/unittests/clangd/SymbolInfoTests.cpp
===================================================================
--- clang-tools-extra/trunk/unittests/clangd/SymbolInfoTests.cpp
+++ clang-tools-extra/trunk/unittests/clangd/SymbolInfoTests.cpp
@@ -149,7 +149,13 @@
           #define MACRO 5\nint i = MAC^RO;
         )cpp",
               {CreateExpectedSymbolDetails("MACRO", "",
-                                           "c:TestTU.cpp at 55@macro at MACRO")}},
+                                           "c:TestTU.cpp at 38@macro at MACRO")}},
+          {
+              R"cpp( // Macro reference
+          #define MACRO 5\nint i = MACRO^;
+        )cpp",
+              {CreateExpectedSymbolDetails("MACRO", "",
+                                           "c:TestTU.cpp at 38@macro at MACRO")}},
           {
               R"cpp( // Multiple symbols returned - using overloaded function name
           void foo() {}
Index: clang-tools-extra/trunk/clangd/XRefs.cpp
===================================================================
--- clang-tools-extra/trunk/clangd/XRefs.cpp
+++ clang-tools-extra/trunk/clangd/XRefs.cpp
@@ -794,7 +794,8 @@
     SymbolDetails NewMacro;
     NewMacro.name = Macro.Name;
     llvm::SmallString<32> USR;
-    if (!index::generateUSRForMacro(NewMacro.name, Loc, SM, USR)) {
+    if (!index::generateUSRForMacro(NewMacro.name,
+                                    Macro.Info->getDefinitionLoc(), SM, USR)) {
       NewMacro.USR = USR.str();
       NewMacro.ID = SymbolID(NewMacro.USR);
     }


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D57228.184054.patch
Type: text/x-patch
Size: 1538 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20190129/8ff76129/attachment.bin>


More information about the cfe-commits mailing list