diff --git a/clang/include/clang/Lex/MacroInfo.h b/clang/include/clang/Lex/MacroInfo.h --- a/clang/include/clang/Lex/MacroInfo.h +++ b/clang/include/clang/Lex/MacroInfo.h @@ -117,9 +117,8 @@ /// Whether this macro was used as header guard. bool UsedForHeaderGuard : 1; - // Only the Preprocessor gets to create and destroy these. + // Only the Preprocessor gets to create these. MacroInfo(SourceLocation DefLoc); - ~MacroInfo() = default; public: /// Return the location that the macro was defined at. diff --git a/clang/include/clang/Lex/Preprocessor.h b/clang/include/clang/Lex/Preprocessor.h --- a/clang/include/clang/Lex/Preprocessor.h +++ b/clang/include/clang/Lex/Preprocessor.h @@ -1011,15 +1011,6 @@ /// invoked (at which point the last position is popped). std::vector BacktrackPositions; - struct MacroInfoChain { - MacroInfo MI; - MacroInfoChain *Next; - }; - - /// MacroInfos are managed as a chain for easy disposal. This is the head - /// of that list. - MacroInfoChain *MIChainHead = nullptr; - /// True if \p Preprocessor::SkipExcludedConditionalBlock() is running. /// This is used to guard against calling this function recursively. /// diff --git a/clang/lib/Lex/PPDirectives.cpp b/clang/lib/Lex/PPDirectives.cpp --- a/clang/lib/Lex/PPDirectives.cpp +++ b/clang/lib/Lex/PPDirectives.cpp @@ -57,9 +57,8 @@ //===----------------------------------------------------------------------===// MacroInfo *Preprocessor::AllocateMacroInfo(SourceLocation L) { - auto *MIChain = new (BP) MacroInfoChain{L, MIChainHead}; - MIChainHead = MIChain; - return &MIChain->MI; + static_assert(std::is_trivially_destructible_v, ""); + return new (BP) MacroInfo(L); } DefMacroDirective *Preprocessor::AllocateDefMacroDirective(MacroInfo *MI, diff --git a/clang/lib/Lex/Preprocessor.cpp b/clang/lib/Lex/Preprocessor.cpp --- a/clang/lib/Lex/Preprocessor.cpp +++ b/clang/lib/Lex/Preprocessor.cpp @@ -165,12 +165,6 @@ IncludeMacroStack.clear(); - // Destroy any macro definitions. - while (MacroInfoChain *I = MIChainHead) { - MIChainHead = I->Next; - I->~MacroInfoChain(); - } - // Free any cached macro expanders. // This populates MacroArgCache, so all TokenLexers need to be destroyed // before the code below that frees up the MacroArgCache list.