summaryrefslogtreecommitdiffstats
path: root/clang/lib/Lex/MacroArgs.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'clang/lib/Lex/MacroArgs.cpp')
-rw-r--r--clang/lib/Lex/MacroArgs.cpp3
1 files changed, 3 insertions, 0 deletions
diff --git a/clang/lib/Lex/MacroArgs.cpp b/clang/lib/Lex/MacroArgs.cpp
index de54f392a48..d2525c0cd6c 100644
--- a/clang/lib/Lex/MacroArgs.cpp
+++ b/clang/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<Token>();
const Token *Result = Start;
+
// Scan to find Arg.
for (; Arg; ++Result) {
assert(Result < Start+NumUnexpArgTokens && "Invalid arg #");
OpenPOWER on IntegriCloud