mirror of
https://github.com/llvm/llvm-project.git
synced 2025-05-01 03:56:09 +00:00
DiagnoseUnknownTypename always emits a diagnostic and returns true
Make it return void and delete the dead code in the parser that handled the case where it might return false. This has been dead since 2010 when John deleted Action.h. llvm-svn: 211248
This commit is contained in:
parent
a0050b0961
commit
c05ca5e40c
@ -333,8 +333,6 @@ def warn_vector_long_decl_spec_combination : Warning<
|
|||||||
"Use of 'long' with '__vector' is deprecated">, InGroup<Deprecated>;
|
"Use of 'long' with '__vector' is deprecated">, InGroup<Deprecated>;
|
||||||
def err_friend_invalid_in_context : Error<
|
def err_friend_invalid_in_context : Error<
|
||||||
"'friend' used outside of class">;
|
"'friend' used outside of class">;
|
||||||
def err_unknown_typename : Error<
|
|
||||||
"unknown type name %0">;
|
|
||||||
def err_use_of_tag_name_without_tag : Error<
|
def err_use_of_tag_name_without_tag : Error<
|
||||||
"must use '%1' tag to refer to type %0%select{| in this scope}2">;
|
"must use '%1' tag to refer to type %0%select{| in this scope}2">;
|
||||||
def err_templated_using_directive : Error<
|
def err_templated_using_directive : Error<
|
||||||
|
@ -6828,6 +6828,8 @@ def warn_direct_ivar_access : Warning<"instance variable %0 is being "
|
|||||||
"directly accessed">, InGroup<DiagGroup<"direct-ivar-access">>, DefaultIgnore;
|
"directly accessed">, InGroup<DiagGroup<"direct-ivar-access">>, DefaultIgnore;
|
||||||
|
|
||||||
// Spell-checking diagnostics
|
// Spell-checking diagnostics
|
||||||
|
def err_unknown_typename : Error<
|
||||||
|
"unknown type name %0">;
|
||||||
def err_unknown_type_or_class_name_suggest : Error<
|
def err_unknown_type_or_class_name_suggest : Error<
|
||||||
"unknown %select{type|class}1 name %0; did you mean %2?">;
|
"unknown %select{type|class}1 name %0; did you mean %2?">;
|
||||||
def err_unknown_typename_suggest : Error<
|
def err_unknown_typename_suggest : Error<
|
||||||
|
@ -1408,7 +1408,7 @@ public:
|
|||||||
IdentifierInfo **CorrectedII = nullptr);
|
IdentifierInfo **CorrectedII = nullptr);
|
||||||
TypeSpecifierType isTagName(IdentifierInfo &II, Scope *S);
|
TypeSpecifierType isTagName(IdentifierInfo &II, Scope *S);
|
||||||
bool isMicrosoftMissingTypename(const CXXScopeSpec *SS, Scope *S);
|
bool isMicrosoftMissingTypename(const CXXScopeSpec *SS, Scope *S);
|
||||||
bool DiagnoseUnknownTypeName(IdentifierInfo *&II,
|
void DiagnoseUnknownTypeName(IdentifierInfo *&II,
|
||||||
SourceLocation IILoc,
|
SourceLocation IILoc,
|
||||||
Scope *S,
|
Scope *S,
|
||||||
CXXScopeSpec *SS,
|
CXXScopeSpec *SS,
|
||||||
|
@ -2170,42 +2170,33 @@ bool Parser::ParseImplicitInt(DeclSpec &DS, CXXScopeSpec *SS,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// This is almost certainly an invalid type name. Let the action emit a
|
// This is almost certainly an invalid type name. Let Sema emit a diagnostic
|
||||||
// diagnostic and attempt to recover.
|
// and attempt to recover.
|
||||||
ParsedType T;
|
ParsedType T;
|
||||||
IdentifierInfo *II = Tok.getIdentifierInfo();
|
IdentifierInfo *II = Tok.getIdentifierInfo();
|
||||||
if (Actions.DiagnoseUnknownTypeName(II, Loc, getCurScope(), SS, T,
|
Actions.DiagnoseUnknownTypeName(II, Loc, getCurScope(), SS, T,
|
||||||
getLangOpts().CPlusPlus &&
|
getLangOpts().CPlusPlus &&
|
||||||
NextToken().is(tok::less))) {
|
NextToken().is(tok::less));
|
||||||
// The action emitted a diagnostic, so we don't have to.
|
if (T) {
|
||||||
if (T) {
|
// The action has suggested that the type T could be used. Set that as
|
||||||
// The action has suggested that the type T could be used. Set that as
|
// the type in the declaration specifiers, consume the would-be type
|
||||||
// the type in the declaration specifiers, consume the would-be type
|
// name token, and we're done.
|
||||||
// name token, and we're done.
|
const char *PrevSpec;
|
||||||
const char *PrevSpec;
|
unsigned DiagID;
|
||||||
unsigned DiagID;
|
DS.SetTypeSpecType(DeclSpec::TST_typename, Loc, PrevSpec, DiagID, T,
|
||||||
DS.SetTypeSpecType(DeclSpec::TST_typename, Loc, PrevSpec, DiagID, T,
|
Actions.getASTContext().getPrintingPolicy());
|
||||||
Actions.getASTContext().getPrintingPolicy());
|
DS.SetRangeEnd(Tok.getLocation());
|
||||||
DS.SetRangeEnd(Tok.getLocation());
|
ConsumeToken();
|
||||||
ConsumeToken();
|
// There may be other declaration specifiers after this.
|
||||||
// There may be other declaration specifiers after this.
|
return true;
|
||||||
return true;
|
} else if (II != Tok.getIdentifierInfo()) {
|
||||||
} else if (II != Tok.getIdentifierInfo()) {
|
// If no type was suggested, the correction is to a keyword
|
||||||
// If no type was suggested, the correction is to a keyword
|
Tok.setKind(II->getTokenID());
|
||||||
Tok.setKind(II->getTokenID());
|
// There may be other declaration specifiers after this.
|
||||||
// There may be other declaration specifiers after this.
|
return true;
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Fall through; the action had no suggestion for us.
|
|
||||||
} else {
|
|
||||||
// The action did not emit a diagnostic, so emit one now.
|
|
||||||
SourceRange R;
|
|
||||||
if (SS) R = SS->getRange();
|
|
||||||
Diag(Loc, diag::err_unknown_typename) << Tok.getIdentifierInfo() << R;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Mark this as an error.
|
// Otherwise, the action had no suggestion for us. Mark this as an error.
|
||||||
DS.SetTypeSpecError();
|
DS.SetTypeSpecError();
|
||||||
DS.SetRangeEnd(Tok.getLocation());
|
DS.SetRangeEnd(Tok.getLocation());
|
||||||
ConsumeToken();
|
ConsumeToken();
|
||||||
|
@ -438,7 +438,7 @@ bool Sema::isMicrosoftMissingTypename(const CXXScopeSpec *SS, Scope *S) {
|
|||||||
return CurContext->isFunctionOrMethod() || S->isFunctionPrototypeScope();
|
return CurContext->isFunctionOrMethod() || S->isFunctionPrototypeScope();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Sema::DiagnoseUnknownTypeName(IdentifierInfo *&II,
|
void Sema::DiagnoseUnknownTypeName(IdentifierInfo *&II,
|
||||||
SourceLocation IILoc,
|
SourceLocation IILoc,
|
||||||
Scope *S,
|
Scope *S,
|
||||||
CXXScopeSpec *SS,
|
CXXScopeSpec *SS,
|
||||||
@ -483,7 +483,7 @@ bool Sema::DiagnoseUnknownTypeName(IdentifierInfo *&II,
|
|||||||
/*IsCtorOrDtorName=*/false,
|
/*IsCtorOrDtorName=*/false,
|
||||||
/*NonTrivialTypeSourceInfo=*/true);
|
/*NonTrivialTypeSourceInfo=*/true);
|
||||||
}
|
}
|
||||||
return true;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (getLangOpts().CPlusPlus) {
|
if (getLangOpts().CPlusPlus) {
|
||||||
@ -502,7 +502,7 @@ bool Sema::DiagnoseUnknownTypeName(IdentifierInfo *&II,
|
|||||||
Diag(TplDecl->getLocation(), diag::note_template_decl_here)
|
Diag(TplDecl->getLocation(), diag::note_template_decl_here)
|
||||||
<< TplDecl->getTemplateParameters()->getSourceRange();
|
<< TplDecl->getTemplateParameters()->getSourceRange();
|
||||||
}
|
}
|
||||||
return true;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -529,8 +529,6 @@ bool Sema::DiagnoseUnknownTypeName(IdentifierInfo *&II,
|
|||||||
assert(SS && SS->isInvalid() &&
|
assert(SS && SS->isInvalid() &&
|
||||||
"Invalid scope specifier has already been diagnosed");
|
"Invalid scope specifier has already been diagnosed");
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// \brief Determine whether the given result set contains either a type name
|
/// \brief Determine whether the given result set contains either a type name
|
||||||
|
Loading…
x
Reference in New Issue
Block a user