bool IsNamespace(NamedDecl *ND) const;
bool IsNamespaceOrAlias(NamedDecl *ND) const;
bool IsType(NamedDecl *ND) const;
+ bool IsMember(NamedDecl *ND) const;
//@}
};
}
if (!AllDeclsFound.insert(CanonDecl))
return;
+ // If the filter is for nested-name-specifiers, then this result starts a
+ // nested-name-specifier.
+ if ((Filter == &ResultBuilder::IsNestedNameSpecifier) ||
+ (Filter == &ResultBuilder::IsMember &&
+ isa<CXXRecordDecl>(R.Declaration) &&
+ cast<CXXRecordDecl>(R.Declaration)->isInjectedClassName()))
+ R.StartsNestedNameSpecifier = true;
+
// If this result is supposed to have an informative qualifier, add one.
- if (R.QualifierIsInformative && !R.Qualifier) {
+ if (R.QualifierIsInformative && !R.Qualifier &&
+ !R.StartsNestedNameSpecifier) {
DeclContext *Ctx = R.Declaration->getDeclContext();
if (NamespaceDecl *Namespace = dyn_cast<NamespaceDecl>(Ctx))
R.Qualifier = NestedNameSpecifier::Create(SemaRef.Context, 0, Namespace);
else
R.QualifierIsInformative = false;
}
-
- // If the filter is for nested-name-specifiers, then this result starts a
- // nested-name-specifier.
- if (Filter == &ResultBuilder::IsNestedNameSpecifier)
- R.StartsNestedNameSpecifier = true;
-
+
// Insert this result into the set of results and into the current shadow
// map.
SMap.insert(std::make_pair(R.Declaration->getDeclName(),
return isa<TypeDecl>(ND);
}
+/// \brief Since every declaration found within a class is a member that we
+/// care about, always returns true. This predicate exists mostly to
+/// communicate to the result builder that we are performing a lookup for
+/// member access.
+bool ResultBuilder::IsMember(NamedDecl *ND) const {
+ return true;
+}
+
// Find the next outer declaration context corresponding to this scope.
static DeclContext *findOuterContext(Scope *S) {
for (S = S->getParent(); S; S = S->getParent())
if (X.Hidden != Y.Hidden)
return !X.Hidden;
+ // Non-nested-name-specifiers precede nested-name-specifiers.
+ if (X.StartsNestedNameSpecifier != Y.StartsNestedNameSpecifier)
+ return !X.StartsNestedNameSpecifier;
+
// Ordering depends on the kind of result.
switch (X.Kind) {
case Result::RK_Declaration:
return;
}
- ResultBuilder Results(*this);
+ ResultBuilder Results(*this, &ResultBuilder::IsMember);
unsigned NextRank = 0;
if (const RecordType *Record = BaseType->getAs<RecordType>()) {