r314600 - [NFC] Add assertion that we assume a valid macro argument index.

Faisal Vali via cfe-commits cfe-commits at lists.llvm.org
Sat Sep 30 12:34:28 PDT 2017


Author: faisalv
Date: Sat Sep 30 12:34:27 2017
New Revision: 314600

URL: http://llvm.org/viewvc/llvm-project?rev=314600&view=rev
Log:
[NFC] Add assertion that we assume a valid macro argument index.

Modified:
    cfe/trunk/lib/Lex/MacroArgs.cpp

Modified: cfe/trunk/lib/Lex/MacroArgs.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/MacroArgs.cpp?rev=314600&r1=314599&r2=314600&view=diff
==============================================================================
--- cfe/trunk/lib/Lex/MacroArgs.cpp (original)
+++ cfe/trunk/lib/Lex/MacroArgs.cpp Sat Sep 30 12:34:27 2017
@@ -118,10 +118,13 @@ unsigned MacroArgs::getArgLength(const T
 /// getUnexpArgument - Return the unexpanded tokens for the specified formal.
 ///
 const Token *MacroArgs::getUnexpArgument(unsigned Arg) const {
+
+  assert(Arg < getNumMacroArguments() && "Invalid arg #");
   // The unexpanded argument tokens start immediately after the MacroArgs object
   // in memory.
   const Token *Start = getTrailingObjects<Token>();
   const Token *Result = Start;
+  
   // Scan to find Arg.
   for (; Arg; ++Result) {
     assert(Result < Start+NumUnexpArgTokens && "Invalid arg #");




More information about the cfe-commits mailing list