diff options
author | Douglas Gregor <dgregor@apple.com> | 2010-03-16 22:30:13 +0000 |
---|---|---|
committer | Douglas Gregor <dgregor@apple.com> | 2010-03-16 22:30:13 +0000 |
commit | 453091cc2082e207ea2c2dda645a9bc01b37fb0c (patch) | |
tree | 96026d218bae429d6706d3783cd94e86b578dc47 /lib/Lex/TokenLexer.cpp | |
parent | a98c27ba83d25d878473ed8c6a34b40b27d323fd (diff) |
Audit all Preprocessor::getSpelling() callers, improving failure
recovery for those that need it.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@98689 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Lex/TokenLexer.cpp')
-rw-r--r-- | lib/Lex/TokenLexer.cpp | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/lib/Lex/TokenLexer.cpp b/lib/Lex/TokenLexer.cpp index dbd1b8400d..56bb073e59 100644 --- a/lib/Lex/TokenLexer.cpp +++ b/lib/Lex/TokenLexer.cpp @@ -396,12 +396,17 @@ bool TokenLexer::PasteTokens(Token &Tok) { // Get the spelling of the LHS token in Buffer. const char *BufPtr = &Buffer[0]; - unsigned LHSLen = PP.getSpelling(Tok, BufPtr); + bool Invalid = false; + unsigned LHSLen = PP.getSpelling(Tok, BufPtr, &Invalid); if (BufPtr != &Buffer[0]) // Really, we want the chars in Buffer! memcpy(&Buffer[0], BufPtr, LHSLen); - + if (Invalid) + return true; + BufPtr = &Buffer[LHSLen]; - unsigned RHSLen = PP.getSpelling(RHS, BufPtr); + unsigned RHSLen = PP.getSpelling(RHS, BufPtr, &Invalid); + if (Invalid) + return true; if (BufPtr != &Buffer[LHSLen]) // Really, we want the chars in Buffer! memcpy(&Buffer[LHSLen], BufPtr, RHSLen); |