[clang-tools-extra] r340539 - [clangd] Check for include overlapping looks for only the line now.
Kadir Cetinkaya via cfe-commits
cfe-commits at lists.llvm.org
Thu Aug 23 08:55:27 PDT 2018
Author: kadircet
Date: Thu Aug 23 08:55:27 2018
New Revision: 340539
URL: http://llvm.org/viewvc/llvm-project?rev=340539&view=rev
Log:
[clangd] Check for include overlapping looks for only the line now.
Summary:
Currently we match an include only if we are inside filename, with this patch we
will match whenever we are on the starting line of the include.
Reviewers: ilya-biryukov, hokein, ioeric
Reviewed By: ilya-biryukov
Subscribers: MaskRay, jkorous, arphaman, cfe-commits
Differential Revision: https://reviews.llvm.org/D51163
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=340539&r1=340538&r2=340539&view=diff
==============================================================================
--- clang-tools-extra/trunk/clangd/XRefs.cpp (original)
+++ clang-tools-extra/trunk/clangd/XRefs.cpp Thu Aug 23 08:55:27 2018
@@ -211,7 +211,7 @@ std::vector<Location> findDefinitions(Pa
std::vector<Location> Result;
// Handle goto definition for #include.
for (auto &Inc : AST.getIncludeStructure().MainFileIncludes) {
- if (!Inc.Resolved.empty() && Inc.R.contains(Pos))
+ if (!Inc.Resolved.empty() && Inc.R.start.line == Pos.line)
Result.push_back(Location{URIForFile{Inc.Resolved}, {}});
}
if (!Result.empty())
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=340539&r1=340538&r2=340539&view=diff
==============================================================================
--- clang-tools-extra/trunk/unittests/clangd/XRefsTests.cpp (original)
+++ clang-tools-extra/trunk/unittests/clangd/XRefsTests.cpp Thu Aug 23 08:55:27 2018
@@ -1014,11 +1014,13 @@ TEST(GoToInclude, All) {
Locations = runFindDefinitions(Server, FooCpp, SourceAnnotations.point("5"));
ASSERT_TRUE(bool(Locations)) << "findDefinitions returned an error";
- EXPECT_THAT(*Locations, IsEmpty());
+ EXPECT_THAT(*Locations,
+ ElementsAre(Location{FooHUri, HeaderAnnotations.range()}));
Locations = runFindDefinitions(Server, FooCpp, SourceAnnotations.point("7"));
ASSERT_TRUE(bool(Locations)) << "findDefinitions returned an error";
- EXPECT_THAT(*Locations, IsEmpty());
+ EXPECT_THAT(*Locations,
+ ElementsAre(Location{FooHUri, HeaderAnnotations.range()}));
}
TEST(GoToDefinition, WithPreamble) {
More information about the cfe-commits
mailing list