LookupResult R(SemaRef, Name, NameLoc, Sema::LookupTagName);
SemaRef.LookupParsedName(R, S, &SS);
if (TagDecl *Tag = R.getAsSingle<TagDecl>()) {
- const char *TagName = 0;
- const char *FixItTagName = 0;
+ StringRef FixItTagName;
switch (Tag->getTagKind()) {
case TTK_Class:
- TagName = "class";
FixItTagName = "class ";
break;
case TTK_Enum:
- TagName = "enum";
FixItTagName = "enum ";
break;
case TTK_Struct:
- TagName = "struct";
FixItTagName = "struct ";
break;
case TTK_Interface:
- TagName = "__interface";
FixItTagName = "__interface ";
break;
case TTK_Union:
- TagName = "union";
FixItTagName = "union ";
break;
}
+ StringRef TagName = FixItTagName.drop_back();
SemaRef.Diag(NameLoc, diag::err_use_of_tag_name_without_tag)
<< Name << TagName << SemaRef.getLangOpts().CPlusPlus
<< FixItHint::CreateInsertion(NameLoc, FixItTagName);