From: Haojian Wu Date: Tue, 13 Mar 2018 14:31:31 +0000 (+0000) Subject: [clangd] Use the macro name range as the definition range. X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=0259e7d872797e9bb4ee1a5d22a551a6bd9fa0d8;p=platform%2Fupstream%2Fllvm.git [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 llvm-svn: 327401 --- diff --git a/clang-tools-extra/clangd/XRefs.cpp b/clang-tools-extra/clangd/XRefs.cpp index df3bf6f..b502efe 100644 --- a/clang-tools-extra/clangd/XRefs.cpp +++ b/clang-tools-extra/clangd/XRefs.cpp @@ -219,9 +219,8 @@ std::vector findDefinitions(ParsedAST &AST, Position Pos) { } 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); } diff --git a/clang-tools-extra/unittests/clangd/XRefsTests.cpp b/clang-tools-extra/unittests/clangd/XRefsTests.cpp index 0052d42..e112043 100644 --- a/clang-tools-extra/unittests/clangd/XRefsTests.cpp +++ b/clang-tools-extra/unittests/clangd/XRefsTests.cpp @@ -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);