diff options
author | Bruno Cardoso Lopes <bruno.cardoso@gmail.com> | 2016-09-13 20:04:35 +0000 |
---|---|---|
committer | Bruno Cardoso Lopes <bruno.cardoso@gmail.com> | 2016-09-13 20:04:35 +0000 |
commit | 218c8743c8d5d18e42ee22afad2eaa9603575507 (patch) | |
tree | 60e5836be09a515fab27c756a8189c1cca78177d /clang/lib/Parse/ParseDecl.cpp | |
parent | 85edca95c67db6f820d8f15ffb27b04d3eb1a4b1 (diff) | |
download | bcm5719-llvm-218c8743c8d5d18e42ee22afad2eaa9603575507.tar.gz bcm5719-llvm-218c8743c8d5d18e42ee22afad2eaa9603575507.zip |
[SemaObjC] Be more strict while parsing type arguments and protocols
Fix a crash-on-invalid.
When parsing type arguments and protocols,
parseObjCTypeArgsOrProtocolQualifiers() calls ParseTypeName(), which tries to
find matching tokens for '[', '(', etc whenever they appear among potential
type names. If unmatched, ParseTypeName() yields a tok::eof token stream. This
leads to crashes since the parsing at this point is not expected to go beyond
the param list closing '>'.
Fix that by properly handling tok::eof in
parseObjCTypeArgsOrProtocolQualifiers() callers.
Differential Revision: https://reviews.llvm.org/D23852
rdar://problem/25063557
llvm-svn: 281383
Diffstat (limited to 'clang/lib/Parse/ParseDecl.cpp')
-rw-r--r-- | clang/lib/Parse/ParseDecl.cpp | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/clang/lib/Parse/ParseDecl.cpp b/clang/lib/Parse/ParseDecl.cpp index 71cbc451e1c..1dfa2f4e7c1 100644 --- a/clang/lib/Parse/ParseDecl.cpp +++ b/clang/lib/Parse/ParseDecl.cpp @@ -5877,7 +5877,8 @@ bool Parser::isFunctionDeclaratorIdentifierList() { // To handle this, we check to see if the token after the first // identifier is a "," or ")". Only then do we parse it as an // identifier list. - && (NextToken().is(tok::comma) || NextToken().is(tok::r_paren)); + && (!Tok.is(tok::eof) && + (NextToken().is(tok::comma) || NextToken().is(tok::r_paren))); } /// ParseFunctionDeclaratorIdentifierList - While parsing a function declarator |