[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
Showing
- lib/Parse/ParseDecl.cpp 2 additions, 1 deletionlib/Parse/ParseDecl.cpp
- lib/Parse/ParseObjc.cpp 8 additions, 1 deletionlib/Parse/ParseObjc.cpp
- lib/Parse/Parser.cpp 4 additions, 0 deletionslib/Parse/Parser.cpp
- test/SemaObjC/crash-on-type-args-protocols.m 40 additions, 0 deletionstest/SemaObjC/crash-on-type-args-protocols.m
Loading
Please register or sign in to comment