aboutsummaryrefslogtreecommitdiff
path: root/lib/Sema/SemaDecl.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2009-01-21 02:38:50 +0000
committerChris Lattner <sabre@nondot.org>2009-01-21 02:38:50 +0000
commitcf79b011e849a4455cb7b0de6dc4fb3b83308f39 (patch)
tree268bc3fb57bf069cebfc4dc0050aac51a1daa55c /lib/Sema/SemaDecl.cpp
parent768be1c162b8b22b625dac81b36a0a00ba4faf04 (diff)
Don't look up decls with no name (such as parameters and unnamed tagged types),
this removes 4266 calls to LookupDecl. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@62662 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaDecl.cpp')
-rw-r--r--lib/Sema/SemaDecl.cpp28
1 files changed, 15 insertions, 13 deletions
diff --git a/lib/Sema/SemaDecl.cpp b/lib/Sema/SemaDecl.cpp
index c91d174d65..c1741da3b6 100644
--- a/lib/Sema/SemaDecl.cpp
+++ b/lib/Sema/SemaDecl.cpp
@@ -2564,18 +2564,20 @@ Sema::ActOnParamDeclarator(Scope *S, Declarator &D) {
// 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.
IdentifierInfo *II = D.getIdentifier();
- if (Decl *PrevDecl = LookupDecl(II, Decl::IDNS_Ordinary, S)) {
- if (PrevDecl->isTemplateParameter()) {
- // Maybe we will complain about the shadowed template parameter.
- DiagnoseTemplateParameterShadow(D.getIdentifierLoc(), PrevDecl);
- // Just pretend that we didn't see the previous declaration.
- PrevDecl = 0;
- } else if (S->isDeclScope(PrevDecl)) {
- Diag(D.getIdentifierLoc(), diag::err_param_redefinition) << II;
+ if (II) {
+ if (Decl *PrevDecl = LookupDecl(II, Decl::IDNS_Ordinary, S)) {
+ if (PrevDecl->isTemplateParameter()) {
+ // Maybe we will complain about the shadowed template parameter.
+ DiagnoseTemplateParameterShadow(D.getIdentifierLoc(), PrevDecl);
+ // Just pretend that we didn't see the previous declaration.
+ PrevDecl = 0;
+ } else if (S->isDeclScope(PrevDecl)) {
+ Diag(D.getIdentifierLoc(), diag::err_param_redefinition) << II;
- // Recover by removing the name
- II = 0;
- D.SetIdentifier(0, D.getIdentifierLoc());
+ // Recover by removing the name
+ II = 0;
+ D.SetIdentifier(0, D.getIdentifierLoc());
+ }
}
}
@@ -2855,11 +2857,11 @@ Sema::DeclTy *Sema::ActOnTag(Scope *S, unsigned TagSpec, TagKind TK,
Name = 0;
goto CreateNewDecl;
}
- } else {
+ } else if (Name) {
// If this is a named struct, check to see if there was a previous forward
// declaration or definition.
PrevDecl = dyn_cast_or_null<NamedDecl>(LookupDecl(Name, Decl::IDNS_Tag,S)
- .getAsDecl());
+ .getAsDecl());
if (!getLangOptions().CPlusPlus && TK != TK_Reference) {
// FIXME: This makes sure that we ignore the contexts associated