Summary: Also fixes a potential user-after-scope issue of "Path".
Reviewers: kadircet
Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, usaxena95, cfe-commits
Tags: #clang
Differential Revision: https://reviews.llvm.org/D68564
llvm-svn: 373897
if (!Path)
return Reply(Path.takeError());
if (*Path)
- Reply(URIForFile::canonicalize(**Path, Params.uri.file()));
+ return Reply(URIForFile::canonicalize(**Path, Params.uri.file()));
return Reply(llvm::None);
});
}
if (auto CorrespondingFile =
getCorrespondingHeaderOrSource(Path, FSProvider.getFileSystem()))
return CB(std::move(CorrespondingFile));
- auto Action = [Path, CB = std::move(CB),
+ auto Action = [Path = Path.str(), CB = std::move(CB),
this](llvm::Expected<InputsAndAST> InpAST) mutable {
if (!InpAST)
return CB(InpAST.takeError());
if (auto TargetPath = URI::resolve(TargetURI, OriginalFile)) {
if (*TargetPath != OriginalFile) // exclude the original file.
++Candidates[*TargetPath];
- };
+ } else {
+ elog("Failed to resolve URI {0}: {1}", TargetURI, TargetPath.takeError());
+ }
};
// If we switch from a header, we are looking for the implementation
// file, so we use the definition loc; otherwise we look for the header file,
Testing.HeaderCode = R"cpp(
void B_Sym1();
void B_Sym2();
+ void B_Sym3_NoDef();
)cpp";
Testing.Filename = "b.cpp";
Testing.Code = R"cpp(
void B_Sym1();
)cpp",
testPath("a.cpp")},
+
+ {R"cpp(
+ // We don't have definition in the index, so stay in the header.
+ void B_Sym3_NoDef();
+ )cpp",
+ None},
};
for (const auto &Case : TestCases) {
TestTU TU = TestTU::withCode(Case.HeaderCode);