summaryrefslogtreecommitdiffstats
path: root/clang/lib
diff options
context:
space:
mode:
Diffstat (limited to 'clang/lib')
-rw-r--r--clang/lib/AST/DeclCXX.cpp33
-rw-r--r--clang/lib/Sema/SemaLookup.cpp25
2 files changed, 49 insertions, 9 deletions
diff --git a/clang/lib/AST/DeclCXX.cpp b/clang/lib/AST/DeclCXX.cpp
index 6be675ad834..f525667ad0a 100644
--- a/clang/lib/AST/DeclCXX.cpp
+++ b/clang/lib/AST/DeclCXX.cpp
@@ -451,6 +451,39 @@ void OverloadedFunctionDecl::addOverload(AnyFunctionDecl F) {
this->setLocation(F.get()->getLocation());
}
+OverloadIterator::reference OverloadIterator::operator*() const {
+ if (FunctionDecl *FD = dyn_cast<FunctionDecl>(D))
+ return FD;
+
+ if (FunctionTemplateDecl *FTD = dyn_cast<FunctionTemplateDecl>(D))
+ return FTD;
+
+ assert(isa<OverloadedFunctionDecl>(D));
+ return *Iter;
+}
+
+OverloadIterator &OverloadIterator::operator++() {
+ if (isa<FunctionDecl>(D) || isa<FunctionTemplateDecl>(D)) {
+ D = 0;
+ return *this;
+ }
+
+ if (++Iter == cast<OverloadedFunctionDecl>(D)->function_end())
+ D = 0;
+
+ return *this;
+}
+
+bool OverloadIterator::Equals(const OverloadIterator &Other) const {
+ if (!D || !Other.D)
+ return D == Other.D;
+
+ if (D != Other.D)
+ return false;
+
+ return !isa<OverloadedFunctionDecl>(D) || Iter == Other.Iter;
+}
+
LinkageSpecDecl *LinkageSpecDecl::Create(ASTContext &C,
DeclContext *DC,
SourceLocation L,
diff --git a/clang/lib/Sema/SemaLookup.cpp b/clang/lib/Sema/SemaLookup.cpp
index 343cbae673a..c88321e1a35 100644
--- a/clang/lib/Sema/SemaLookup.cpp
+++ b/clang/lib/Sema/SemaLookup.cpp
@@ -19,6 +19,7 @@
#include "clang/AST/DeclObjC.h"
#include "clang/AST/DeclTemplate.h"
#include "clang/AST/Expr.h"
+#include "clang/AST/ExprCXX.h"
#include "clang/Parse/DeclSpec.h"
#include "clang/Basic/Builtins.h"
#include "clang/Basic/LangOptions.h"
@@ -1579,18 +1580,24 @@ Sema::FindAssociatedClassesAndNamespaces(Expr **Args, unsigned NumArgs,
// classes and namespaces associated with its (non-dependent)
// parameter types and return type.
DeclRefExpr *DRE = 0;
+ TemplateIdRefExpr *TIRE = 0;
+ Arg = Arg->IgnoreParens();
if (UnaryOperator *unaryOp = dyn_cast<UnaryOperator>(Arg)) {
- if (unaryOp->getOpcode() == UnaryOperator::AddrOf)
+ if (unaryOp->getOpcode() == UnaryOperator::AddrOf) {
DRE = dyn_cast<DeclRefExpr>(unaryOp->getSubExpr());
- } else
+ TIRE = dyn_cast<TemplateIdRefExpr>(unaryOp->getSubExpr());
+ }
+ } else {
DRE = dyn_cast<DeclRefExpr>(Arg);
- if (!DRE)
- continue;
-
- // FIXME: The declaration might be a FunctionTemplateDecl (by itself)
- // or might be buried in a TemplateIdRefExpr.
- OverloadedFunctionDecl *Ovl
- = dyn_cast<OverloadedFunctionDecl>(DRE->getDecl());
+ TIRE = dyn_cast<TemplateIdRefExpr>(Arg);
+ }
+
+ OverloadedFunctionDecl *Ovl = 0;
+ if (DRE)
+ Ovl = dyn_cast<OverloadedFunctionDecl>(DRE->getDecl());
+ else if (TIRE)
+ Ovl = dyn_cast_or_null<OverloadedFunctionDecl>(
+ TIRE->getTemplateName().getAsTemplateDecl());
if (!Ovl)
continue;
OpenPOWER on IntegriCloud