Author: hokein Date: Tue Mar 13 07:31:31 2018 New Revision: 327401 URL: http://llvm.org/viewvc/llvm-project?rev=327401&view=rev Log: [clangd] Use the macro name range as the definition range.
Summary: This also aligns with the behavior of declarations. Reviewers: sammccall Reviewed By: sammccall Subscribers: klimek, ilya-biryukov, jkorous-apple, ioeric, cfe-commits Differential Revision: https://reviews.llvm.org/D44423 Modified: clang-tools-extra/trunk/clangd/XRefs.cpp clang-tools-extra/trunk/unittests/clangd/XRefsTests.cpp Modified: clang-tools-extra/trunk/clangd/XRefs.cpp URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/XRefs.cpp?rev=327401&r1=327400&r2=327401&view=diff ============================================================================== --- clang-tools-extra/trunk/clangd/XRefs.cpp (original) +++ clang-tools-extra/trunk/clangd/XRefs.cpp Tue Mar 13 07:31:31 2018 @@ -219,9 +219,8 @@ std::vector<Location> findDefinitions(Pa } 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); } Modified: clang-tools-extra/trunk/unittests/clangd/XRefsTests.cpp URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/unittests/clangd/XRefsTests.cpp?rev=327401&r1=327400&r2=327401&view=diff ============================================================================== --- clang-tools-extra/trunk/unittests/clangd/XRefsTests.cpp (original) +++ clang-tools-extra/trunk/unittests/clangd/XRefsTests.cpp Tue Mar 13 07:31:31 2018 @@ -207,7 +207,7 @@ TEST(GoToDefinition, All) { R"cpp(// Macro #define MACRO 0 - #define [[MACRO 1]] + #define [[MACRO]] 1 int main() { return ^MACRO; } #define MACRO 2 #undef macro @@ -215,7 +215,7 @@ TEST(GoToDefinition, All) { 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); _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits