aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnders Carlsson <andersca@mac.com>2009-06-26 05:26:50 +0000
committerAnders Carlsson <andersca@mac.com>2009-06-26 05:26:50 +0000
commit58badb7a655d021fc67bb7ed0af95d6ea0c63eb1 (patch)
tree3a735ecc37d697ee049c566eab90c016103876e0
parent5e50569d45d7c8545fecd17685a3a613b1cb0158 (diff)
See through UsingDecls in more places.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@74269 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--include/clang/AST/DeclCXX.h20
-rw-r--r--lib/AST/DeclBase.cpp3
-rw-r--r--lib/Sema/SemaLookup.cpp20
3 files changed, 31 insertions, 12 deletions
diff --git a/include/clang/AST/DeclCXX.h b/include/clang/AST/DeclCXX.h
index 4e006c08ea..a2fe24e831 100644
--- a/include/clang/AST/DeclCXX.h
+++ b/include/clang/AST/DeclCXX.h
@@ -1101,17 +1101,25 @@ class UsingDecl : public NamedDecl {
public:
/// \brief Returns the source range that covers the nested-name-specifier
/// preceding the namespace name.
- SourceRange getNestedNameRange() { return(NestedNameRange); }
+ SourceRange getNestedNameRange() { return NestedNameRange; }
+
/// \brief Returns the source location of the target declaration name.
- SourceLocation getTargetNameLocation() { return(TargetNameLocation); }
+ SourceLocation getTargetNameLocation() { return TargetNameLocation; }
+
/// \brief Returns the source location of the "using" location itself.
- SourceLocation getUsingLocation() { return(UsingLocation); }
+ SourceLocation getUsingLocation() { return UsingLocation; }
+
/// \brief getTargetDecl - Returns target specified by using-decl.
- NamedDecl *getTargetDecl() { return(TargetDecl); }
+ NamedDecl *getTargetDecl() { return TargetDecl; }
+ const NamedDecl *getTargetDecl() const { return TargetDecl; }
+
/// \brief Get target nested name declaration.
- NestedNameSpecifier* getTargetNestedNameDecl() { return(TargetNestedNameDecl); }
+ NestedNameSpecifier* getTargetNestedNameDecl() {
+ return TargetNestedNameDecl;
+ }
+
/// isTypeName - Return true if using decl had 'typename'.
- bool isTypeName() const { return(IsTypeName); }
+ bool isTypeName() const { return IsTypeName; }
static UsingDecl *Create(ASTContext &C, DeclContext *DC,
SourceLocation L, SourceRange NNR, SourceLocation TargetNL,
diff --git a/lib/AST/DeclBase.cpp b/lib/AST/DeclBase.cpp
index 93bee84cff..5815d820ae 100644
--- a/lib/AST/DeclBase.cpp
+++ b/lib/AST/DeclBase.cpp
@@ -97,6 +97,9 @@ bool Decl::isTemplateParameterPack() const {
}
bool Decl::isFunctionOrFunctionTemplate() const {
+ if (const UsingDecl *UD = dyn_cast<UsingDecl>(this))
+ return UD->getTargetDecl()->isFunctionOrFunctionTemplate();
+
return isa<FunctionDecl>(this) || isa<FunctionTemplateDecl>(this);
}
diff --git a/lib/Sema/SemaLookup.cpp b/lib/Sema/SemaLookup.cpp
index e1c6302fcc..d76761c696 100644
--- a/lib/Sema/SemaLookup.cpp
+++ b/lib/Sema/SemaLookup.cpp
@@ -139,16 +139,24 @@ MaybeConstructOverloadSet(ASTContext &Context,
// nothing to leak.
Ovl = OverloadedFunctionDecl::Create(Context, (*I)->getDeclContext(),
(*I)->getDeclName());
- if (isa<FunctionDecl>(*I))
- Ovl->addOverload(cast<FunctionDecl>(*I));
+ NamedDecl *ND = (*I);
+ if (UsingDecl *UD = dyn_cast<UsingDecl>(ND))
+ ND = UD->getTargetDecl();
+
+ if (isa<FunctionDecl>(ND))
+ Ovl->addOverload(cast<FunctionDecl>(ND));
else
- Ovl->addOverload(cast<FunctionTemplateDecl>(*I));
+ Ovl->addOverload(cast<FunctionTemplateDecl>(ND));
}
- if (isa<FunctionDecl>(*Last))
- Ovl->addOverload(cast<FunctionDecl>(*Last));
+ NamedDecl *ND = (*Last);
+ if (UsingDecl *UD = dyn_cast<UsingDecl>(ND))
+ ND = UD->getTargetDecl();
+
+ if (isa<FunctionDecl>(ND))
+ Ovl->addOverload(cast<FunctionDecl>(ND));
else
- Ovl->addOverload(cast<FunctionTemplateDecl>(*Last));
+ Ovl->addOverload(cast<FunctionTemplateDecl>(ND));
}
// If we had more than one function, we built an overload