More correct handling of error cases C++ name parser

Now incorrect type argument that looks like T<A><B> doesn't
cause an assert, but just a parsing error.

Bug: 36224
Differential Revision: https://reviews.llvm.org/D42939

llvm-svn: 324380
This commit is contained in:
Eugene Zemtsov 2018-02-06 19:04:12 +00:00
parent f951fc399f
commit 9e916e5e0e
2 changed files with 3 additions and 2 deletions

View File

@ -242,8 +242,7 @@ bool CPlusPlusNameParser::ConsumeTemplateArgs() {
} }
} }
assert(template_counter >= 0); if (template_counter != 0) {
if (template_counter > 0) {
return false; return false;
} }
start_position.Remove(); start_position.Remove();

View File

@ -160,4 +160,6 @@ TEST(CPlusPlusLanguage, ExtractContextAndIdentifier) {
"selector:otherField:", context, basename)); "selector:otherField:", context, basename));
EXPECT_FALSE(CPlusPlusLanguage::ExtractContextAndIdentifier( EXPECT_FALSE(CPlusPlusLanguage::ExtractContextAndIdentifier(
"abc::", context, basename)); "abc::", context, basename));
EXPECT_FALSE(CPlusPlusLanguage::ExtractContextAndIdentifier(
"f<A<B><C>>", context, basename));
} }