[clangd] Make sure macro information exists before increasing usage count.

llvm-svn: 336581
This commit is contained in:
Eric Liu 2018-07-09 18:54:51 +00:00
parent 0566f2352a
commit a62c9d62a3

View File

@ -371,7 +371,6 @@ bool SymbolCollector::handleMacroOccurence(const IdentifierInfo *Name,
Roles & static_cast<unsigned>(index::SymbolRole::Definition)))
return true;
llvm::SmallString<128> USR;
if (index::generateUSRForMacro(Name->getName(), MI->getDefinitionLoc(), SM,
USR))
@ -433,9 +432,8 @@ void SymbolCollector::finish() {
assert(PP);
for (const IdentifierInfo *II : ReferencedMacros) {
llvm::SmallString<128> USR;
if (!index::generateUSRForMacro(
II->getName(),
PP->getMacroDefinition(II).getMacroInfo()->getDefinitionLoc(),
if (const auto *MI = PP->getMacroDefinition(II).getMacroInfo())
if (!index::generateUSRForMacro(II->getName(), MI->getDefinitionLoc(),
PP->getSourceManager(), USR))
IncRef(SymbolID(USR));
}