From: Faisal Vali Date: Sat, 30 Sep 2017 13:58:38 +0000 (+0000) Subject: [NFC] Remove superfluous parameter X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=51cc2d29165533c6c0c07ddd1ab02cc0dfa8cb79;p=clang [NFC] Remove superfluous parameter - MacroArgs already knows the maximum number of arguments that can be supplied to the macro. No need to pass MacroInfo (information about the macro definition) to the call to getPreExpArgument (which by the way might benefit from being called getExpandedArgument() ?) for it to compute the number of arguments. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@314593 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/clang/Lex/MacroArgs.h b/include/clang/Lex/MacroArgs.h index ac02748191..157e5a132a 100644 --- a/include/clang/Lex/MacroArgs.h +++ b/include/clang/Lex/MacroArgs.h @@ -93,7 +93,7 @@ public: /// getPreExpArgument - Return the pre-expanded form of the specified /// argument. const std::vector & - getPreExpArgument(unsigned Arg, const MacroInfo *MI, Preprocessor &PP); + getPreExpArgument(unsigned Arg, Preprocessor &PP); /// getStringifiedArgument - Compute, cache, and return the specified argument /// that has been 'stringified' as required by the # operator. diff --git a/lib/Lex/MacroArgs.cpp b/lib/Lex/MacroArgs.cpp index 37a7d5c1ff..de54f392a4 100644 --- a/lib/Lex/MacroArgs.cpp +++ b/lib/Lex/MacroArgs.cpp @@ -150,14 +150,13 @@ bool MacroArgs::ArgNeedsPreexpansion(const Token *ArgTok, /// getPreExpArgument - Return the pre-expanded form of the specified /// argument. -const std::vector & -MacroArgs::getPreExpArgument(unsigned Arg, const MacroInfo *MI, - Preprocessor &PP) { - assert(Arg < MI->getNumParams() && "Invalid argument number!"); +const std::vector &MacroArgs::getPreExpArgument(unsigned Arg, + Preprocessor &PP) { + assert(Arg < getNumMacroArguments() && "Invalid argument number!"); // If we have already computed this, return it. - if (PreExpArgTokens.size() < MI->getNumParams()) - PreExpArgTokens.resize(MI->getNumParams()); + if (PreExpArgTokens.size() < getNumMacroArguments()) + PreExpArgTokens.resize(getNumMacroArguments()); std::vector &Result = PreExpArgTokens[Arg]; if (!Result.empty()) return Result; diff --git a/lib/Lex/TokenLexer.cpp b/lib/Lex/TokenLexer.cpp index 10e21b3b04..4341d56b4e 100644 --- a/lib/Lex/TokenLexer.cpp +++ b/lib/Lex/TokenLexer.cpp @@ -275,7 +275,7 @@ void TokenLexer::ExpandFunctionArguments() { // avoids some work in common cases. const Token *ArgTok = ActualArgs->getUnexpArgument(ArgNo); if (ActualArgs->ArgNeedsPreexpansion(ArgTok, PP)) - ResultArgToks = &ActualArgs->getPreExpArgument(ArgNo, Macro, PP)[0]; + ResultArgToks = &ActualArgs->getPreExpArgument(ArgNo, PP)[0]; else ResultArgToks = ArgTok; // Use non-preexpanded tokens.