summaryrefslogtreecommitdiffstats
path: root/clang/lib
diff options
context:
space:
mode:
authorJustin Bogner <mail@justinbogner.com>2013-12-10 21:29:48 +0000
committerJustin Bogner <mail@justinbogner.com>2013-12-10 21:29:48 +0000
commitab403f463a350e4bebe9b7f8f25a198746c89f54 (patch)
tree7800a6cae14e3f23a2ca80bb8c6a6fd7ca8d02b3 /clang/lib
parent29da7178c87d6606e40021562cec776239144ecf (diff)
downloadbcm5719-llvm-ab403f463a350e4bebe9b7f8f25a198746c89f54.tar.gz
bcm5719-llvm-ab403f463a350e4bebe9b7f8f25a198746c89f54.zip
Parse: Avoid crashing on unterminated top-level asm strings
When parsing invalid top-level asm statements, we were ignoring the return code of the SkipUntil we used for recovery. This led to crashes when we hit the end of file and tried to continue parsing anyway. This fixes the crash and adds a couple of tests for parsing related problems. llvm-svn: 196961
Diffstat (limited to 'clang/lib')
-rw-r--r--clang/lib/Parse/Parser.cpp11
1 files changed, 5 insertions, 6 deletions
diff --git a/clang/lib/Parse/Parser.cpp b/clang/lib/Parse/Parser.cpp
index 66ed352ef68..310105a4ac6 100644
--- a/clang/lib/Parse/Parser.cpp
+++ b/clang/lib/Parse/Parser.cpp
@@ -1354,16 +1354,15 @@ Parser::ExprResult Parser::ParseSimpleAsm(SourceLocation *EndLoc) {
ExprResult Result(ParseAsmStringLiteral());
- if (Result.isInvalid()) {
- SkipUntil(tok::r_paren, StopAtSemi | StopBeforeMatch);
- if (EndLoc)
- *EndLoc = Tok.getLocation();
- ConsumeAnyToken();
- } else {
+ if (!Result.isInvalid()) {
// Close the paren and get the location of the end bracket
T.consumeClose();
if (EndLoc)
*EndLoc = T.getCloseLocation();
+ } else if (SkipUntil(tok::r_paren, StopAtSemi | StopBeforeMatch)) {
+ if (EndLoc)
+ *EndLoc = Tok.getLocation();
+ ConsumeParen();
}
return Result;
OpenPOWER on IntegriCloud