From: Eric Liu Date: Mon, 9 Jul 2018 18:54:51 +0000 (+0000) Subject: [clangd] Make sure macro information exists before increasing usage count. X-Git-Tag: llvmorg-7.0.0-rc1~1933 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=a62c9d62a32bbbba652b97e21d21e05b4b10fb94;p=platform%2Fupstream%2Fllvm.git [clangd] Make sure macro information exists before increasing usage count. llvm-svn: 336581 --- diff --git a/clang-tools-extra/clangd/index/SymbolCollector.cpp b/clang-tools-extra/clangd/index/SymbolCollector.cpp index 1ad75e1..568dff9 100644 --- a/clang-tools-extra/clangd/index/SymbolCollector.cpp +++ b/clang-tools-extra/clangd/index/SymbolCollector.cpp @@ -371,7 +371,6 @@ bool SymbolCollector::handleMacroOccurence(const IdentifierInfo *Name, Roles & static_cast(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();