From: Chris Lattner Date: Mon, 14 Dec 2009 22:12:52 +0000 (+0000) Subject: move the VarargsElided member of MacrosArgs to shrink the MacroArgs struct X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=561395bead16b9dc9b0d5bfb6b257a9ed4545db6;p=clang move the VarargsElided member of MacrosArgs to shrink the MacroArgs struct on 64-bit targets. Pass Preprocessor into create/destroy methods of MacroArgs even though it isn't used yet. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@91345 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Lex/MacroArgs.cpp b/lib/Lex/MacroArgs.cpp index c14d7c438d..a621854814 100644 --- a/lib/Lex/MacroArgs.cpp +++ b/lib/Lex/MacroArgs.cpp @@ -20,7 +20,8 @@ using namespace clang; /// MacroArgs ctor function - This destroys the vector passed in. MacroArgs *MacroArgs::create(const MacroInfo *MI, const Token *UnexpArgTokens, - unsigned NumToks, bool VarargsElided) { + unsigned NumToks, bool VarargsElided, + Preprocessor &PP) { assert(MI->isFunctionLike() && "Can't have args for an object-like macro!"); @@ -40,7 +41,7 @@ MacroArgs *MacroArgs::create(const MacroInfo *MI, /// destroy - Destroy and deallocate the memory for this object. /// -void MacroArgs::destroy() { +void MacroArgs::destroy(Preprocessor &PP) { // Run the dtor to deallocate the vectors. this->~MacroArgs(); // Release the memory for the object. diff --git a/lib/Lex/MacroArgs.h b/lib/Lex/MacroArgs.h index 8dee5b3bc9..43ce08c269 100644 --- a/lib/Lex/MacroArgs.h +++ b/lib/Lex/MacroArgs.h @@ -30,6 +30,13 @@ class MacroArgs { /// concatenated together, with 'EOF' markers at the end of each argument. unsigned NumUnexpArgTokens; + /// VarargsElided - True if this is a C99 style varargs macro invocation and + /// there was no argument specified for the "..." argument. If the argument + /// was specified (even empty) or this isn't a C99 style varargs function, or + /// if in strict mode and the C99 varargs macro had only a ... argument, this + /// is false. + bool VarargsElided; + /// PreExpArgTokens - Pre-expanded tokens for arguments that need them. Empty /// if not yet computed. This includes the EOF marker at the end of the /// stream. @@ -39,13 +46,6 @@ class MacroArgs { /// stringified form of an argument has not yet been computed, this is empty. std::vector StringifiedArgs; - /// VarargsElided - True if this is a C99 style varargs macro invocation and - /// there was no argument specified for the "..." argument. If the argument - /// was specified (even empty) or this isn't a C99 style varargs function, or - /// if in strict mode and the C99 varargs macro had only a ... argument, this - /// is false. - bool VarargsElided; - MacroArgs(unsigned NumToks, bool varargsElided) : NumUnexpArgTokens(NumToks), VarargsElided(varargsElided) {} ~MacroArgs() {} @@ -54,11 +54,12 @@ public: /// macro and argument info. static MacroArgs *create(const MacroInfo *MI, const Token *UnexpArgTokens, - unsigned NumArgTokens, bool VarargsElided); + unsigned NumArgTokens, bool VarargsElided, + Preprocessor &PP); /// destroy - Destroy and deallocate the memory for this object. /// - void destroy(); + void destroy(Preprocessor &PP); /// ArgNeedsPreexpansion - If we can prove that the argument won't be affected /// by pre-expansion, return false. Otherwise, conservatively return true. diff --git a/lib/Lex/PPMacroExpansion.cpp b/lib/Lex/PPMacroExpansion.cpp index ca54236b5c..dfb14ff06f 100644 --- a/lib/Lex/PPMacroExpansion.cpp +++ b/lib/Lex/PPMacroExpansion.cpp @@ -204,7 +204,7 @@ bool Preprocessor::HandleMacroExpandedIdentifier(Token &Identifier, // expansion stack, only to take it right back off. if (MI->getNumTokens() == 0) { // No need for arg info. - if (Args) Args->destroy(); + if (Args) Args->destroy(*this); // Ignore this macro use, just return the next token in the current // buffer. @@ -232,7 +232,7 @@ bool Preprocessor::HandleMacroExpandedIdentifier(Token &Identifier, // "#define VAL 42". // No need for arg info. - if (Args) Args->destroy(); + if (Args) Args->destroy(*this); // Propagate the isAtStartOfLine/hasLeadingSpace markers of the macro // identifier to the expanded token. @@ -446,7 +446,7 @@ MacroArgs *Preprocessor::ReadFunctionLikeMacroArgs(Token &MacroName, } return MacroArgs::create(MI, ArgTokens.data(), ArgTokens.size(), - isVarargsElided); + isVarargsElided, *this); } /// ComputeDATE_TIME - Compute the current time, enter it into the specified diff --git a/lib/Lex/TokenLexer.cpp b/lib/Lex/TokenLexer.cpp index 5f70b05694..a40bb62db4 100644 --- a/lib/Lex/TokenLexer.cpp +++ b/lib/Lex/TokenLexer.cpp @@ -92,7 +92,7 @@ void TokenLexer::destroy() { } // TokenLexer owns its formal arguments. - if (ActualArgs) ActualArgs->destroy(); + if (ActualArgs) ActualArgs->destroy(PP); } /// Expand the arguments of a function-like macro so that we can quickly