[clang-tools-extra] r336581 - [clangd] Make sure macro information exists before increasing usage count.
Eric Liu via cfe-commits
cfe-commits at lists.llvm.org
Mon Jul 9 11:54:51 PDT 2018
Author: ioeric
Date: Mon Jul 9 11:54:51 2018
New Revision: 336581
URL: http://llvm.org/viewvc/llvm-project?rev=336581&view=rev
Log:
[clangd] Make sure macro information exists before increasing usage count.
Modified:
clang-tools-extra/trunk/clangd/index/SymbolCollector.cpp
Modified: clang-tools-extra/trunk/clangd/index/SymbolCollector.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/index/SymbolCollector.cpp?rev=336581&r1=336580&r2=336581&view=diff
==============================================================================
--- clang-tools-extra/trunk/clangd/index/SymbolCollector.cpp (original)
+++ clang-tools-extra/trunk/clangd/index/SymbolCollector.cpp Mon Jul 9 11:54:51 2018
@@ -371,7 +371,6 @@ bool SymbolCollector::handleMacroOccuren
Roles & static_cast<unsigned>(index::SymbolRole::Definition)))
return true;
-
llvm::SmallString<128> USR;
if (index::generateUSRForMacro(Name->getName(), MI->getDefinitionLoc(), SM,
USR))
@@ -433,11 +432,10 @@ void SymbolCollector::finish() {
assert(PP);
for (const IdentifierInfo *II : ReferencedMacros) {
llvm::SmallString<128> USR;
- if (!index::generateUSRForMacro(
- II->getName(),
- PP->getMacroDefinition(II).getMacroInfo()->getDefinitionLoc(),
- PP->getSourceManager(), USR))
- IncRef(SymbolID(USR));
+ if (const auto *MI = PP->getMacroDefinition(II).getMacroInfo())
+ if (!index::generateUSRForMacro(II->getName(), MI->getDefinitionLoc(),
+ PP->getSourceManager(), USR))
+ IncRef(SymbolID(USR));
}
}
ReferencedDecls.clear();
More information about the cfe-commits
mailing list