diff options
author | David Majnemer <david.majnemer@gmail.com> | 2015-03-19 00:10:23 +0000 |
---|---|---|
committer | David Majnemer <david.majnemer@gmail.com> | 2015-03-19 00:10:23 +0000 |
commit | a8f2f1da999b7ef1e5e16ec539164106018cb431 (patch) | |
tree | 3fb09db2219818be070e2ac0f27abc37acfbec3d /clang/lib/Parse/ParseCXXInlineMethods.cpp | |
parent | cfb53e49b6962f314d7a153d7d940d9aff291274 (diff) | |
download | bcm5719-llvm-a8f2f1da999b7ef1e5e16ec539164106018cb431.tar.gz bcm5719-llvm-a8f2f1da999b7ef1e5e16ec539164106018cb431.zip |
Parse: Don't assume tokens have a length
Don't crash if the last token in a bad inline method body is an
annotation token.
llvm-svn: 232694
Diffstat (limited to 'clang/lib/Parse/ParseCXXInlineMethods.cpp')
-rw-r--r-- | clang/lib/Parse/ParseCXXInlineMethods.cpp | 10 |
1 files changed, 3 insertions, 7 deletions
diff --git a/clang/lib/Parse/ParseCXXInlineMethods.cpp b/clang/lib/Parse/ParseCXXInlineMethods.cpp index a53079b260d..86ac471ddb1 100644 --- a/clang/lib/Parse/ParseCXXInlineMethods.cpp +++ b/clang/lib/Parse/ParseCXXInlineMethods.cpp @@ -317,8 +317,7 @@ void Parser::ParseLexedMethodDeclaration(LateParsedMethodDeclaration &LM) { Token DefArgEnd; DefArgEnd.startToken(); DefArgEnd.setKind(tok::eof); - DefArgEnd.setLocation(LastDefaultArgToken.getLocation().getLocWithOffset( - LastDefaultArgToken.getLength())); + DefArgEnd.setLocation(LastDefaultArgToken.getEndLoc()); DefArgEnd.setEofData(Param); Toks->push_back(DefArgEnd); @@ -392,9 +391,7 @@ void Parser::ParseLexedMethodDeclaration(LateParsedMethodDeclaration &LM) { Token ExceptionSpecEnd; ExceptionSpecEnd.startToken(); ExceptionSpecEnd.setKind(tok::eof); - ExceptionSpecEnd.setLocation( - LastExceptionSpecToken.getLocation().getLocWithOffset( - LastExceptionSpecToken.getLength())); + ExceptionSpecEnd.setLocation(LastExceptionSpecToken.getEndLoc()); ExceptionSpecEnd.setEofData(LM.Method); Toks->push_back(ExceptionSpecEnd); @@ -499,8 +496,7 @@ void Parser::ParseLexedMethodDef(LexedMethod &LM) { Token BodyEnd; BodyEnd.startToken(); BodyEnd.setKind(tok::eof); - BodyEnd.setLocation( - LastBodyToken.getLocation().getLocWithOffset(LastBodyToken.getLength())); + BodyEnd.setLocation(LastBodyToken.getEndLoc()); BodyEnd.setEofData(LM.D); LM.Toks.push_back(BodyEnd); // Append the current token at the end of the new token stream so that it |