This revision was automatically updated to reflect the committed changes. Closed by commit rGe04482456713: [Lex] Stop allocating/deallocating MacroInfo on a linked list. NFC (authored by sammccall).
Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D136725/new/ https://reviews.llvm.org/D136725 Files: clang/include/clang/Lex/MacroInfo.h clang/include/clang/Lex/Preprocessor.h clang/lib/Lex/PPDirectives.cpp clang/lib/Lex/Preprocessor.cpp Index: clang/lib/Lex/Preprocessor.cpp =================================================================== --- clang/lib/Lex/Preprocessor.cpp +++ 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. Index: clang/lib/Lex/PPDirectives.cpp =================================================================== --- clang/lib/Lex/PPDirectives.cpp +++ 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<MacroInfo>, ""); + return new (BP) MacroInfo(L); } DefMacroDirective *Preprocessor::AllocateDefMacroDirective(MacroInfo *MI, Index: clang/include/clang/Lex/Preprocessor.h =================================================================== --- clang/include/clang/Lex/Preprocessor.h +++ clang/include/clang/Lex/Preprocessor.h @@ -1011,15 +1011,6 @@ /// invoked (at which point the last position is popped). std::vector<CachedTokensTy::size_type> 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. /// Index: clang/include/clang/Lex/MacroInfo.h =================================================================== --- clang/include/clang/Lex/MacroInfo.h +++ 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.
Index: clang/lib/Lex/Preprocessor.cpp =================================================================== --- clang/lib/Lex/Preprocessor.cpp +++ 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. Index: clang/lib/Lex/PPDirectives.cpp =================================================================== --- clang/lib/Lex/PPDirectives.cpp +++ 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<MacroInfo>, ""); + return new (BP) MacroInfo(L); } DefMacroDirective *Preprocessor::AllocateDefMacroDirective(MacroInfo *MI, Index: clang/include/clang/Lex/Preprocessor.h =================================================================== --- clang/include/clang/Lex/Preprocessor.h +++ clang/include/clang/Lex/Preprocessor.h @@ -1011,15 +1011,6 @@ /// invoked (at which point the last position is popped). std::vector<CachedTokensTy::size_type> 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. /// Index: clang/include/clang/Lex/MacroInfo.h =================================================================== --- clang/include/clang/Lex/MacroInfo.h +++ 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.
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits