Don't look up decls with no name (such as parameters and unnamed tagged types),

this removes 4266 calls to LookupDecl.

llvm-svn: 62662
This commit is contained in:
Chris Lattner 2009-01-21 02:38:50 +00:00
parent 201501995f
commit d9773516e7
1 changed files with 15 additions and 13 deletions

View File

@ -2564,18 +2564,20 @@ Sema::ActOnParamDeclarator(Scope *S, Declarator &D) {
// Can this happen for params? We already checked that they don't conflict // Can this happen for params? We already checked that they don't conflict
// among each other. Here they can only shadow globals, which is ok. // among each other. Here they can only shadow globals, which is ok.
IdentifierInfo *II = D.getIdentifier(); IdentifierInfo *II = D.getIdentifier();
if (Decl *PrevDecl = LookupDecl(II, Decl::IDNS_Ordinary, S)) { if (II) {
if (PrevDecl->isTemplateParameter()) { if (Decl *PrevDecl = LookupDecl(II, Decl::IDNS_Ordinary, S)) {
// Maybe we will complain about the shadowed template parameter. if (PrevDecl->isTemplateParameter()) {
DiagnoseTemplateParameterShadow(D.getIdentifierLoc(), PrevDecl); // Maybe we will complain about the shadowed template parameter.
// Just pretend that we didn't see the previous declaration. DiagnoseTemplateParameterShadow(D.getIdentifierLoc(), PrevDecl);
PrevDecl = 0; // Just pretend that we didn't see the previous declaration.
} else if (S->isDeclScope(PrevDecl)) { PrevDecl = 0;
Diag(D.getIdentifierLoc(), diag::err_param_redefinition) << II; } else if (S->isDeclScope(PrevDecl)) {
Diag(D.getIdentifierLoc(), diag::err_param_redefinition) << II;
// Recover by removing the name // Recover by removing the name
II = 0; II = 0;
D.SetIdentifier(0, D.getIdentifierLoc()); D.SetIdentifier(0, D.getIdentifierLoc());
}
} }
} }
@ -2855,11 +2857,11 @@ Sema::DeclTy *Sema::ActOnTag(Scope *S, unsigned TagSpec, TagKind TK,
Name = 0; Name = 0;
goto CreateNewDecl; goto CreateNewDecl;
} }
} else { } else if (Name) {
// If this is a named struct, check to see if there was a previous forward // If this is a named struct, check to see if there was a previous forward
// declaration or definition. // declaration or definition.
PrevDecl = dyn_cast_or_null<NamedDecl>(LookupDecl(Name, Decl::IDNS_Tag,S) PrevDecl = dyn_cast_or_null<NamedDecl>(LookupDecl(Name, Decl::IDNS_Tag,S)
.getAsDecl()); .getAsDecl());
if (!getLangOptions().CPlusPlus && TK != TK_Reference) { if (!getLangOptions().CPlusPlus && TK != TK_Reference) {
// FIXME: This makes sure that we ignore the contexts associated // FIXME: This makes sure that we ignore the contexts associated