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); } 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@55@macro@MACRO")}}, + "c:TestTU.cpp@38@macro@MACRO")}}, + { + R"cpp( // Macro reference + #define MACRO 5\nint i = MACRO^; + )cpp", + {CreateExpectedSymbolDetails("MACRO", "", + "c:TestTU.cpp@38@macro@MACRO")}}, { R"cpp( // Multiple symbols returned - using overloaded function name void foo() {}