summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/SemaDecl.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2009-01-06 07:20:03 +0000
committerChris Lattner <sabre@nondot.org>2009-01-06 07:20:03 +0000
commita7c7095b427c50b59337a7f147410895c6cc10d4 (patch)
treed7dd6b41c3a5f6607c915bc453b8a33fc24a58e3 /clang/lib/Sema/SemaDecl.cpp
parentd05cb418fd61c8fd5bd4ba2fbfefc3dfd06002da (diff)
downloadbcm5719-llvm-a7c7095b427c50b59337a7f147410895c6cc10d4.tar.gz
bcm5719-llvm-a7c7095b427c50b59337a7f147410895c6cc10d4.zip
simplify some code using 'continue' and the new 'isInIdentifierNamespace' predicate.
llvm-svn: 61799
Diffstat (limited to 'clang/lib/Sema/SemaDecl.cpp')
-rw-r--r--clang/lib/Sema/SemaDecl.cpp50
1 files changed, 25 insertions, 25 deletions
diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp
index 5a7d07b86f7..0e14150021e 100644
--- a/clang/lib/Sema/SemaDecl.cpp
+++ b/clang/lib/Sema/SemaDecl.cpp
@@ -282,19 +282,18 @@ Decl *Sema::LookupDecl(DeclarationName Name, unsigned NSI, Scope *S,
// should not take long, as shadowing of names is uncommon, and
// deep shadowing is extremely uncommon.
for (; I != IdResolver.end(); ++I)
- if ((*I)->getIdentifierNamespace() & NS)
+ if ((*I)->isInIdentifierNamespace(NS))
return *I;
} else if (LookupCtx) {
// Perform qualified name lookup into the LookupCtx.
// FIXME: Will need to look into base classes and such.
DeclContext::lookup_const_iterator I, E;
for (llvm::tie(I, E) = LookupCtx->lookup(Context, Name); I != E; ++I)
- if ((*I)->getIdentifierNamespace() & NS) {
- if (NamespaceNameOnly && !isa<NamespaceDecl>(*I)) {
- // Skip non-namespace name.
- } else {
- return MaybeConstructOverloadSet(Context, I, E);
- }
+ if ((*I)->isInIdentifierNamespace(NS)) {
+ // Ignore non-namespace names if we're only looking for namespaces.
+ if (NamespaceNameOnly && !isa<NamespaceDecl>(*I)) continue;
+
+ return MaybeConstructOverloadSet(Context, I, E);
}
} else {
// Name lookup for ordinary names and tag names in C++ requires
@@ -308,22 +307,22 @@ Decl *Sema::LookupDecl(DeclarationName Name, unsigned NSI, Scope *S,
// Check whether the IdResolver has anything in this scope.
// FIXME: The isDeclScope check could be expensive. Can we do better?
for (; I != IEnd && S->isDeclScope(*I); ++I) {
- if ((*I)->getIdentifierNamespace() & NS) {
- if (NamespaceNameOnly && !isa<NamespaceDecl>(*I)) {
- // Skip non-namespace name.
- } else {
- // We found something. Look for anything else in our scope
- // with this same name and in an acceptable identifier
- // namespace, so that we can construct an overload set if we
- // need to.
- IdentifierResolver::iterator LastI = I;
- for (++LastI; LastI != IEnd; ++LastI) {
- if (((*LastI)->getIdentifierNamespace() & NS) == 0 ||
- !S->isDeclScope(*LastI))
- break;
- }
- return MaybeConstructOverloadSet(Context, I, LastI);
+ if ((*I)->isInIdentifierNamespace(NS)) {
+ // Ignore non-namespace names if we're only looking for namespaces.
+ if (NamespaceNameOnly && !isa<NamespaceDecl>(*I))
+ continue;
+
+ // We found something. Look for anything else in our scope
+ // with this same name and in an acceptable identifier
+ // namespace, so that we can construct an overload set if we
+ // need to.
+ IdentifierResolver::iterator LastI = I;
+ for (++LastI; LastI != IEnd; ++LastI) {
+ if (!(*LastI)->isInIdentifierNamespace(NS) ||
+ !S->isDeclScope(*LastI))
+ break;
}
+ return MaybeConstructOverloadSet(Context, I, LastI);
}
}
@@ -338,9 +337,10 @@ Decl *Sema::LookupDecl(DeclarationName Name, unsigned NSI, Scope *S,
DeclContext::lookup_const_iterator I, E;
for (llvm::tie(I, E) = Ctx->lookup(Context, Name); I != E; ++I) {
// FIXME: Cache this result in the IdResolver
- if ((*I)->getIdentifierNamespace() & NS) {
- if (NamespaceNameOnly && !isa<NamespaceDecl>(*I)) {}
- else return MaybeConstructOverloadSet(Context, I, E);
+ if ((*I)->isInIdentifierNamespace(NS)) {
+ if (NamespaceNameOnly && !isa<NamespaceDecl>(*I))
+ continue;
+ return MaybeConstructOverloadSet(Context, I, E);
}
}
OpenPOWER on IntegriCloud