aboutsummaryrefslogtreecommitdiff
path: root/lib/Sema
diff options
context:
space:
mode:
Diffstat (limited to 'lib/Sema')
-rw-r--r--lib/Sema/Lookup.h7
-rw-r--r--lib/Sema/SemaDecl.cpp6
-rw-r--r--lib/Sema/SemaLookup.cpp40
-rw-r--r--lib/Sema/SemaTemplateInstantiateDecl.cpp6
4 files changed, 39 insertions, 20 deletions
diff --git a/lib/Sema/Lookup.h b/lib/Sema/Lookup.h
index 0961299587..97bc4f25a5 100644
--- a/lib/Sema/Lookup.h
+++ b/lib/Sema/Lookup.h
@@ -124,6 +124,7 @@ public:
};
typedef UnresolvedSetImpl::iterator iterator;
+ typedef bool (*ResultFilter)(NamedDecl*, unsigned IDNS);
LookupResult(Sema &SemaRef, DeclarationName Name, SourceLocation NameLoc,
Sema::LookupNameKind LookupKind,
@@ -135,6 +136,7 @@ public:
Name(Name),
NameLoc(NameLoc),
LookupKind(LookupKind),
+ IsAcceptableFn(0),
IDNS(0),
Redecl(Redecl != Sema::NotForRedeclaration),
HideTags(true),
@@ -154,6 +156,7 @@ public:
Name(Other.Name),
NameLoc(Other.NameLoc),
LookupKind(Other.LookupKind),
+ IsAcceptableFn(Other.IsAcceptableFn),
IDNS(Other.IDNS),
Redecl(Other.Redecl),
HideTags(Other.HideTags),
@@ -239,7 +242,8 @@ public:
/// \brief Tests whether the given declaration is acceptable.
bool isAcceptableDecl(NamedDecl *D) const {
- return D->isInIdentifierNamespace(IDNS);
+ assert(IsAcceptableFn);
+ return IsAcceptableFn(D, IDNS);
}
/// \brief Returns the identifier namespace mask for this lookup.
@@ -571,6 +575,7 @@ private:
SourceLocation NameLoc;
SourceRange NameContextRange;
Sema::LookupNameKind LookupKind;
+ ResultFilter IsAcceptableFn; // set by configure()
unsigned IDNS; // set by configure()
bool Redecl;
diff --git a/lib/Sema/SemaDecl.cpp b/lib/Sema/SemaDecl.cpp
index 83796ba65f..3964b755ba 100644
--- a/lib/Sema/SemaDecl.cpp
+++ b/lib/Sema/SemaDecl.cpp
@@ -3269,12 +3269,6 @@ Sema::ActOnFunctionDeclarator(Scope* S, Declarator& D, DeclContext* DC,
NewFD->setAccess(Access);
}
- if (NewFD->isOverloadedOperator() && !DC->isRecord() &&
- NewFD->isInIdentifierNamespace(Decl::IDNS_Ordinary)) {
- NewFD->setNonMemberOperator();
- if (FunctionTemplate) FunctionTemplate->setNonMemberOperator();
- }
-
// If we have a function template, check the template parameter
// list. This will check and merge default template arguments.
if (FunctionTemplate) {
diff --git a/lib/Sema/SemaLookup.cpp b/lib/Sema/SemaLookup.cpp
index 0609eef3c9..a7a1084d31 100644
--- a/lib/Sema/SemaLookup.cpp
+++ b/lib/Sema/SemaLookup.cpp
@@ -193,6 +193,37 @@ namespace {
};
}
+static bool IsAcceptableIDNS(NamedDecl *D, unsigned IDNS) {
+ return D->isInIdentifierNamespace(IDNS);
+}
+
+static bool IsAcceptableOperatorName(NamedDecl *D, unsigned IDNS) {
+ return D->isInIdentifierNamespace(IDNS) &&
+ !D->getDeclContext()->isRecord();
+}
+
+/// Gets the default result filter for the given lookup.
+static inline
+LookupResult::ResultFilter getResultFilter(Sema::LookupNameKind NameKind) {
+ switch (NameKind) {
+ case Sema::LookupOrdinaryName:
+ case Sema::LookupTagName:
+ case Sema::LookupMemberName:
+ case Sema::LookupRedeclarationWithLinkage: // FIXME: check linkage, scoping
+ case Sema::LookupUsingDeclName:
+ case Sema::LookupObjCProtocolName:
+ case Sema::LookupNestedNameSpecifierName:
+ case Sema::LookupNamespaceName:
+ return &IsAcceptableIDNS;
+
+ case Sema::LookupOperatorName:
+ return &IsAcceptableOperatorName;
+ }
+
+ llvm_unreachable("unkknown lookup kind");
+ return 0;
+}
+
// Retrieve the set of identifier namespaces that correspond to a
// specific kind of name lookup.
static inline unsigned getIDNS(Sema::LookupNameKind NameKind,
@@ -201,6 +232,7 @@ static inline unsigned getIDNS(Sema::LookupNameKind NameKind,
unsigned IDNS = 0;
switch (NameKind) {
case Sema::LookupOrdinaryName:
+ case Sema::LookupOperatorName:
case Sema::LookupRedeclarationWithLinkage:
IDNS = Decl::IDNS_Ordinary;
if (CPlusPlus) {
@@ -209,13 +241,6 @@ static inline unsigned getIDNS(Sema::LookupNameKind NameKind,
}
break;
- case Sema::LookupOperatorName:
- // Operator lookup is its own crazy thing; it is not the same
- // as (e.g.) looking up an operator name for redeclaration.
- assert(!Redeclaration && "cannot do redeclaration operator lookup");
- IDNS = Decl::IDNS_NonMemberOperator;
- break;
-
case Sema::LookupTagName:
if (CPlusPlus) {
IDNS = Decl::IDNS_Type;
@@ -262,6 +287,7 @@ void LookupResult::configure() {
IDNS = getIDNS(LookupKind,
SemaRef.getLangOptions().CPlusPlus,
isForRedeclaration());
+ IsAcceptableFn = getResultFilter(LookupKind);
// If we're looking for one of the allocation or deallocation
// operators, make sure that the implicitly-declared new and delete
diff --git a/lib/Sema/SemaTemplateInstantiateDecl.cpp b/lib/Sema/SemaTemplateInstantiateDecl.cpp
index 8924c7876a..fe60be062c 100644
--- a/lib/Sema/SemaTemplateInstantiateDecl.cpp
+++ b/lib/Sema/SemaTemplateInstantiateDecl.cpp
@@ -1140,12 +1140,6 @@ Decl *TemplateDeclInstantiator::VisitFunctionDecl(FunctionDecl *D,
DC->makeDeclVisibleInContext(ToFriendD, /*Recoverable=*/ false);
}
- if (Function->isOverloadedOperator() && !DC->isRecord() &&
- Function->isInIdentifierNamespace(Decl::IDNS_Ordinary)) {
- Function->setNonMemberOperator();
- if (FunctionTemplate) FunctionTemplate->setNonMemberOperator();
- }
-
return Function;
}