]> granicus.if.org Git - clang/commitdiff
[NFC] Add assertion that we assume a valid macro argument index.
authorFaisal Vali <faisalv@yahoo.com>
Sat, 30 Sep 2017 19:34:27 +0000 (19:34 +0000)
committerFaisal Vali <faisalv@yahoo.com>
Sat, 30 Sep 2017 19:34:27 +0000 (19:34 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@314600 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Lex/MacroArgs.cpp

index de54f392a48553ada8a181fb68f4198b40d6beea..d2525c0cd6ce9859e33d2533d677f74e97f3c69b 100644 (file)
@@ -118,10 +118,13 @@ unsigned MacroArgs::getArgLength(const Token *ArgPtr) {
 /// 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 #");