From 744bd75982e8bbcb7d74fa15e4d77c94c19040df Mon Sep 17 00:00:00 2001 From: Faisal Vali Date: Sat, 30 Sep 2017 19:34:27 +0000 Subject: [PATCH] [NFC] Add assertion that we assume a valid macro argument index. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@314600 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Lex/MacroArgs.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/Lex/MacroArgs.cpp b/lib/Lex/MacroArgs.cpp index de54f392a4..d2525c0cd6 100644 --- a/lib/Lex/MacroArgs.cpp +++ b/lib/Lex/MacroArgs.cpp @@ -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(); const Token *Result = Start; + // Scan to find Arg. for (; Arg; ++Result) { assert(Result < Start+NumUnexpArgTokens && "Invalid arg #"); -- 2.49.0