Index: clang-tools-extra/clangd/CodeComplete.cpp =================================================================== --- clang-tools-extra/clangd/CodeComplete.cpp +++ clang-tools-extra/clangd/CodeComplete.cpp @@ -1105,14 +1105,19 @@ ExternalPreprocessorSource *PreambleMacros = PP.getExternalSource(); // As we have the names of the macros, we can look up their IdentifierInfo // and then use this to load just the macros we want. + const auto &ITable = PP.getIdentifierTable(); IdentifierInfoLookup *PreambleIdentifiers = - PP.getIdentifierTable().getExternalIdentifierLookup(); + ITable.getExternalIdentifierLookup(); + if (!PreambleIdentifiers || !PreambleMacros) return; - for (const auto &MacroName : Preamble.Macros.Names) + for (const auto &MacroName : Preamble.Macros.Names) { + if (ITable.find(MacroName.getKey()) != ITable.end()) + continue; if (auto *II = PreambleIdentifiers->get(MacroName.getKey())) if (II->isOutOfDate()) PreambleMacros->updateOutOfDateIdentifier(*II); + } } // Invokes Sema code completion on a file.