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 | dc970f086663cf5ade0ccac79f8cb58e4bf110d5 (patch) | |
tree | c68a90dbc91ba7b70e8c81204e5293e6554a8178 /clang/lib/Lex/TokenLexer.cpp | |
parent | a41f71212a677f56c908c178ca679e17875c0052 (diff) | |
download | bcm5719-llvm-dc970f086663cf5ade0ccac79f8cb58e4bf110d5.tar.gz bcm5719-llvm-dc970f086663cf5ade0ccac79f8cb58e4bf110d5.zip |
Audit all Preprocessor::getSpelling() callers, improving failure
recovery for those that need it.
llvm-svn: 98689
Diffstat (limited to 'clang/lib/Lex/TokenLexer.cpp')
-rw-r--r-- | clang/lib/Lex/TokenLexer.cpp | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/clang/lib/Lex/TokenLexer.cpp b/clang/lib/Lex/TokenLexer.cpp index dbd1b8400de..56bb073e591 100644 --- a/clang/lib/Lex/TokenLexer.cpp +++ b/clang/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); |