[SemaObjC] Be more strict while parsing type arguments and protocols
authorBruno Cardoso Lopes <bruno.cardoso@gmail.com>
Tue, 13 Sep 2016 20:04:35 +0000 (20:04 +0000)
committerBruno Cardoso Lopes <bruno.cardoso@gmail.com>
Tue, 13 Sep 2016 20:04:35 +0000 (20:04 +0000)
commit218c8743c8d5d18e42ee22afad2eaa9603575507
tree60e5836be09a515fab27c756a8189c1cca78177d
parent85edca95c67db6f820d8f15ffb27b04d3eb1a4b1
[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
clang/lib/Parse/ParseDecl.cpp
clang/lib/Parse/ParseObjc.cpp
clang/lib/Parse/Parser.cpp
clang/test/SemaObjC/crash-on-type-args-protocols.m [new file with mode: 0644]