summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2010-03-16 22:30:13 +0000
committerDouglas Gregor <dgregor@apple.com>2010-03-16 22:30:13 +0000
commitdc970f086663cf5ade0ccac79f8cb58e4bf110d5 (patch)
treec68a90dbc91ba7b70e8c81204e5293e6554a8178 /clang/lib/Sema
parenta41f71212a677f56c908c178ca679e17875c0052 (diff)
downloadbcm5719-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/Sema')
-rw-r--r--clang/lib/Sema/SemaExpr.cpp10
1 files changed, 8 insertions, 2 deletions
diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp
index a39ba2f7d06..32ed3e0006e 100644
--- a/clang/lib/Sema/SemaExpr.cpp
+++ b/clang/lib/Sema/SemaExpr.cpp
@@ -1751,7 +1751,10 @@ Sema::OwningExprResult Sema::ActOnPredefinedExpr(SourceLocation Loc,
Sema::OwningExprResult Sema::ActOnCharacterConstant(const Token &Tok) {
llvm::SmallString<16> CharBuffer;
- llvm::StringRef ThisTok = PP.getSpelling(Tok, CharBuffer);
+ bool Invalid = false;
+ llvm::StringRef ThisTok = PP.getSpelling(Tok, CharBuffer, &Invalid);
+ if (Invalid)
+ return ExprError();
CharLiteralParser Literal(ThisTok.begin(), ThisTok.end(), Tok.getLocation(),
PP);
@@ -1789,7 +1792,10 @@ Action::OwningExprResult Sema::ActOnNumericConstant(const Token &Tok) {
const char *ThisTokBegin = &IntegerBuffer[0];
// Get the spelling of the token, which eliminates trigraphs, etc.
- unsigned ActualLength = PP.getSpelling(Tok, ThisTokBegin);
+ bool Invalid = false;
+ unsigned ActualLength = PP.getSpelling(Tok, ThisTokBegin, &Invalid);
+ if (Invalid)
+ return ExprError();
NumericLiteralParser Literal(ThisTokBegin, ThisTokBegin+ActualLength,
Tok.getLocation(), PP);
OpenPOWER on IntegriCloud