summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/Lookup.h
diff options
context:
space:
mode:
authorJohn McCall <rjmccall@apple.com>2009-12-18 10:40:03 +0000
committerJohn McCall <rjmccall@apple.com>2009-12-18 10:40:03 +0000
commitea305edd63da4b03f49df6e31fd35a8fd3b7c5a8 (patch)
tree8529afaf67fa9786e9eb0eea43e8877d20385993 /clang/lib/Sema/Lookup.h
parent86b9d75dc892f301561521a105bce06e0389dde9 (diff)
downloadbcm5719-llvm-ea305edd63da4b03f49df6e31fd35a8fd3b7c5a8.tar.gz
bcm5719-llvm-ea305edd63da4b03f49df6e31fd35a8fd3b7c5a8.zip
Pull Sema::isAcceptableLookupResult into SemaLookup. Extract the criteria into
different functions and pick the function at lookup initialization time. In theory we could actually divide the criteria functions into N different functions for the N cases, but it's so not worth it. Among other things, lets us invoke LookupQualifiedName without recomputing IDNS info every time. Do some refactoring in SemaDecl to avoid an awkward special case in LQN that was only necessary for redeclaration testing for anonymous structs/unions --- which could be done more efficiently with a scoped lookup anyway. llvm-svn: 91676
Diffstat (limited to 'clang/lib/Sema/Lookup.h')
-rw-r--r--clang/lib/Sema/Lookup.h39
1 files changed, 25 insertions, 14 deletions
diff --git a/clang/lib/Sema/Lookup.h b/clang/lib/Sema/Lookup.h
index 78f79eac2ba..6b7e28ce3dc 100644
--- a/clang/lib/Sema/Lookup.h
+++ b/clang/lib/Sema/Lookup.h
@@ -121,6 +121,8 @@ public:
typedef llvm::SmallVector<NamedDecl*, 4> DeclsTy;
typedef DeclsTy::const_iterator iterator;
+ typedef bool (*ResultFilter)(NamedDecl*, unsigned IDNS);
+
LookupResult(Sema &SemaRef, DeclarationName Name, SourceLocation NameLoc,
Sema::LookupNameKind LookupKind,
Sema::RedeclarationKind Redecl = Sema::NotForRedeclaration)
@@ -130,11 +132,14 @@ public:
Name(Name),
NameLoc(NameLoc),
LookupKind(LookupKind),
+ IsAcceptableFn(0),
IDNS(0),
Redecl(Redecl != Sema::NotForRedeclaration),
HideTags(true),
Diagnose(Redecl == Sema::NotForRedeclaration)
- {}
+ {
+ configure();
+ }
/// Creates a temporary lookup result, initializing its core data
/// using the information from another result. Diagnostics are always
@@ -146,6 +151,7 @@ public:
Name(Other.Name),
NameLoc(Other.NameLoc),
LookupKind(Other.LookupKind),
+ IsAcceptableFn(Other.IsAcceptableFn),
IDNS(Other.IDNS),
Redecl(Other.Redecl),
HideTags(Other.HideTags),
@@ -178,17 +184,6 @@ public:
HideTags = Hide;
}
- /// The identifier namespace of this lookup. This information is
- /// private to the lookup routines.
- unsigned getIdentifierNamespace() const {
- assert(IDNS);
- return IDNS;
- }
-
- void setIdentifierNamespace(unsigned NS) {
- IDNS = NS;
- }
-
bool isAmbiguous() const {
return getResultKind() == Ambiguous;
}
@@ -231,7 +226,19 @@ public:
return Paths;
}
- /// \brief Add a declaration to these results.
+ /// \brief Tests whether the given declaration is acceptable.
+ bool isAcceptableDecl(NamedDecl *D) const {
+ assert(IsAcceptableFn);
+ return IsAcceptableFn(D, IDNS);
+ }
+
+ /// \brief Returns the identifier namespace mask for this lookup.
+ unsigned getIdentifierNamespace() const {
+ return IDNS;
+ }
+
+ /// \brief Add a declaration to these results. Does not test the
+ /// acceptance criteria.
void addDecl(NamedDecl *D) {
Decls.push_back(D);
ResultKind = Found;
@@ -334,6 +341,7 @@ public:
void clear(Sema::LookupNameKind Kind) {
clear();
LookupKind = Kind;
+ configure();
}
void print(llvm::raw_ostream &);
@@ -438,6 +446,7 @@ private:
}
void addDeclsFromBasePaths(const CXXBasePaths &P);
+ void configure();
// Sanity checks.
void sanity() const {
@@ -476,7 +485,9 @@ private:
SourceLocation NameLoc;
SourceRange NameContextRange;
Sema::LookupNameKind LookupKind;
- unsigned IDNS; // ill-defined until set by lookup
+ ResultFilter IsAcceptableFn; // set by configure()
+ unsigned IDNS; // set by configure()
+
bool Redecl;
/// \brief True if tag declarations should be hidden if non-tags
OpenPOWER on IntegriCloud