diff options
author | Chris Lattner <sabre@nondot.org> | 2009-06-26 04:27:47 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2009-06-26 04:27:47 +0000 |
commit | 5558e9fc55a1677798c3ac664e613e7fcd41da06 (patch) | |
tree | 1c8567afaa891ddfae58d245bc71c651a53f41c3 /clang/lib/Parse/Parser.cpp | |
parent | 6dde0bfef7c8a467d4c2470ef126ccef167a904a (diff) | |
download | bcm5719-llvm-5558e9fc55a1677798c3ac664e613e7fcd41da06.tar.gz bcm5719-llvm-5558e9fc55a1677798c3ac664e613e7fcd41da06.zip |
fix PR4452, a crash on invalid. The error recovery is still terrible in this case
but at least we don't crash :)
llvm-svn: 74264
Diffstat (limited to 'clang/lib/Parse/Parser.cpp')
-rw-r--r-- | clang/lib/Parse/Parser.cpp | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/clang/lib/Parse/Parser.cpp b/clang/lib/Parse/Parser.cpp index 18048443223..f582448ee9b 100644 --- a/clang/lib/Parse/Parser.cpp +++ b/clang/lib/Parse/Parser.cpp @@ -839,7 +839,8 @@ Parser::OwningExprResult Parser::ParseSimpleAsm(SourceLocation *EndLoc) { /// specifier, and another one to get the actual type inside /// ParseDeclarationSpecifiers). /// -/// This returns true if the token was annotated. +/// This returns true if the token was annotated or an unrecoverable error +/// occurs. /// /// Note that this routine emits an error if you call it with ::new or ::delete /// as the current tokens, so only call it in contexts where these are invalid. @@ -934,7 +935,12 @@ bool Parser::TryAnnotateTypeOrScopeToken() { if (TemplateNameKind TNK = Actions.isTemplateName(*Tok.getIdentifierInfo(), CurScope, Template, &SS)) - AnnotateTemplateIdToken(Template, TNK, &SS); + if (AnnotateTemplateIdToken(Template, TNK, &SS)) { + // If an unrecoverable error occurred, we need to return true here, + // because the token stream is in a damaged state. We may not return + // a valid identifier. + return Tok.isNot(tok::identifier); + } } // The current token, which is either an identifier or a @@ -978,7 +984,8 @@ bool Parser::TryAnnotateTypeOrScopeToken() { /// TryAnnotateScopeToken - Like TryAnnotateTypeOrScopeToken but only /// annotates C++ scope specifiers and template-ids. This returns -/// true if the token was annotated. +/// true if the token was annotated or there was an error that could not be +/// recovered from. /// /// Note that this routine emits an error if you call it with ::new or ::delete /// as the current tokens, so only call it in contexts where these are invalid. |