]> granicus.if.org Git - clang/commit
[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)
commitcd4da5b10180783b2520362a76cccfe97cd4b768
tree65ba99581076770df8835e0ec66c57cad338fddf
parentba75b718a17a7b6d1dc89308cf6de117ec2b1bbc
[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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@281383 91177308-0d34-0410-b5e6-96231b3b80d8
lib/Parse/ParseDecl.cpp
lib/Parse/ParseObjc.cpp
lib/Parse/Parser.cpp
test/SemaObjC/crash-on-type-args-protocols.m [new file with mode: 0644]