[PATCH] D57228: [clangd] Make USRs for macros to be position independent
Kadir Cetinkaya via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Fri Jan 25 04:06:08 PST 2019
kadircet created this revision.
kadircet added a reviewer: jkorous.
Herald added subscribers: cfe-commits, arphaman, MaskRay, ioeric, ilya-biryukov.
USRs for macros were not cannonical due to usage of cursor location
instead of definition location.
Repository:
rCTE Clang Tools Extra
https://reviews.llvm.org/D57228
Files:
clangd/XRefs.cpp
unittests/clangd/SymbolInfoTests.cpp
Index: unittests/clangd/SymbolInfoTests.cpp
===================================================================
--- unittests/clangd/SymbolInfoTests.cpp
+++ 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: clangd/XRefs.cpp
===================================================================
--- clangd/XRefs.cpp
+++ 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.183514.patch
Type: text/x-patch
Size: 1394 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20190125/a23d90b8/attachment.bin>
More information about the cfe-commits
mailing list