summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema
diff options
context:
space:
mode:
authorAnders Carlsson <andersca@mac.com>2009-06-26 06:29:23 +0000
committerAnders Carlsson <andersca@mac.com>2009-06-26 06:29:23 +0000
commit6915bf6158865cf753ef5ea1997771ba4caa7480 (patch)
tree9326ad3502f0b769e7f3d4e2501fe38d7162cb6f /clang/lib/Sema
parent1eda63715f82a478d607e725a1a94a5cfe89913d (diff)
downloadbcm5719-llvm-6915bf6158865cf753ef5ea1997771ba4caa7480.tar.gz
bcm5719-llvm-6915bf6158865cf753ef5ea1997771ba4caa7480.zip
Add NamedDecl::getUnderlyingDecl that can see through UsingDecl and ObjCCompatibleAliasDecl.
llvm-svn: 74279
Diffstat (limited to 'clang/lib/Sema')
-rw-r--r--clang/lib/Sema/SemaLookup.cpp41
1 files changed, 12 insertions, 29 deletions
diff --git a/clang/lib/Sema/SemaLookup.cpp b/clang/lib/Sema/SemaLookup.cpp
index d76761c6963..cc9e783f616 100644
--- a/clang/lib/Sema/SemaLookup.cpp
+++ b/clang/lib/Sema/SemaLookup.cpp
@@ -139,20 +139,14 @@ MaybeConstructOverloadSet(ASTContext &Context,
// nothing to leak.
Ovl = OverloadedFunctionDecl::Create(Context, (*I)->getDeclContext(),
(*I)->getDeclName());
- NamedDecl *ND = (*I);
- if (UsingDecl *UD = dyn_cast<UsingDecl>(ND))
- ND = UD->getTargetDecl();
-
+ NamedDecl *ND = (*I)->getUnderlyingDecl();
if (isa<FunctionDecl>(ND))
Ovl->addOverload(cast<FunctionDecl>(ND));
else
Ovl->addOverload(cast<FunctionTemplateDecl>(ND));
}
- NamedDecl *ND = (*Last);
- if (UsingDecl *UD = dyn_cast<UsingDecl>(ND))
- ND = UD->getTargetDecl();
-
+ NamedDecl *ND = (*Last)->getUnderlyingDecl();
if (isa<FunctionDecl>(ND))
Ovl->addOverload(cast<FunctionDecl>(ND));
else
@@ -219,9 +213,7 @@ MergeLookupResults(ASTContext &Context, LookupResultsTy &Results) {
break;
case LResult::Found: {
- NamedDecl *ND = I->getAsDecl();
- if (UsingDecl *UD = dyn_cast<UsingDecl>(ND))
- ND = UD->getTargetDecl();
+ NamedDecl *ND = I->getAsDecl()->getUnderlyingDecl();
if (TagDecl *TD = dyn_cast<TagDecl>(ND)) {
TagFound = Context.getCanonicalDecl(TD);
@@ -333,11 +325,8 @@ getIdentifierNamespacesFromLookupNameKind(Sema::LookupNameKind NameKind,
Sema::LookupResult
Sema::LookupResult::CreateLookupResult(ASTContext &Context, NamedDecl *D) {
- if (ObjCCompatibleAliasDecl *Alias
- = dyn_cast_or_null<ObjCCompatibleAliasDecl>(D))
- D = Alias->getClassInterface();
- if (UsingDecl *UD = dyn_cast_or_null<UsingDecl>(D))
- D = UD->getTargetDecl();
+ if (D)
+ D = D->getUnderlyingDecl();
LookupResult Result;
Result.StoredKind = (D && isa<OverloadedFunctionDecl>(D))?
@@ -367,12 +356,9 @@ Sema::LookupResult::CreateLookupResult(ASTContext &Context,
}
}
- Decl *D = *F;
- if (ObjCCompatibleAliasDecl *Alias
- = dyn_cast_or_null<ObjCCompatibleAliasDecl>(D))
- D = Alias->getClassInterface();
- if (UsingDecl *UD = dyn_cast_or_null<UsingDecl>(D))
- D = UD->getTargetDecl();
+ NamedDecl *D = *F;
+ if (D)
+ D = D->getUnderlyingDecl();
Result.StoredKind = SingleDecl;
Result.First = reinterpret_cast<uintptr_t>(D);
@@ -398,13 +384,10 @@ Sema::LookupResult::CreateLookupResult(ASTContext &Context,
}
}
- Decl *D = *F;
- if (ObjCCompatibleAliasDecl *Alias
- = dyn_cast_or_null<ObjCCompatibleAliasDecl>(D))
- D = Alias->getClassInterface();
- if (UsingDecl *UD = dyn_cast_or_null<UsingDecl>(D))
- D = UD->getTargetDecl();
-
+ NamedDecl *D = *F;
+ if (D)
+ D = D->getUnderlyingDecl();
+
Result.StoredKind = SingleDecl;
Result.First = reinterpret_cast<uintptr_t>(D);
Result.Last = 0;
OpenPOWER on IntegriCloud