[PATCH] D55275: [clangd] Dont provide locations for non-existent files.
Kadir Cetinkaya via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Tue Dec 4 08:34:40 PST 2018
kadircet created this revision.
kadircet added a reviewer: hokein.
Herald added subscribers: cfe-commits, arphaman, jkorous, MaskRay, ioeric, ilya-biryukov.
We were getting assertion errors when we had bad file names, instead we
should skip those.
Repository:
rCTE Clang Tools Extra
https://reviews.llvm.org/D55275
Files:
clangd/index/SymbolCollector.cpp
unittests/clangd/SymbolCollectorTests.cpp
Index: unittests/clangd/SymbolCollectorTests.cpp
===================================================================
--- unittests/clangd/SymbolCollectorTests.cpp
+++ unittests/clangd/SymbolCollectorTests.cpp
@@ -1028,6 +1028,15 @@
AllOf(QName("Public"), Not(ImplementationDetail()))));
}
+TEST_F(SymbolCollectorTest, RenameSymbolWithMacro) {
+ const std::string Header = R"(
+ void foo() {}
+ )";
+ runSymbolCollector(Header, /*Main=*/"", {"-Dfoo=bar"});
+ EXPECT_THAT(Symbols, UnorderedElementsAre(QName("bar")));
+}
+
+
} // namespace
} // namespace clangd
} // namespace clang
Index: clangd/index/SymbolCollector.cpp
===================================================================
--- clangd/index/SymbolCollector.cpp
+++ clangd/index/SymbolCollector.cpp
@@ -211,7 +211,10 @@
const SymbolCollector::Options &Opts,
const clang::LangOptions &LangOpts,
std::string &FileURIStorage) {
- auto U = toURI(SM, SM.getFilename(TokLoc), Opts);
+ llvm::StringRef FileName = SM.getFilename(TokLoc);
+ if (FileName.empty())
+ return None;
+ auto U = toURI(SM, FileName, Opts);
if (!U)
return None;
FileURIStorage = std::move(*U);
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D55275.176646.patch
Type: text/x-patch
Size: 1301 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20181204/c970ff57/attachment.bin>
More information about the cfe-commits
mailing list