// Look for virtual methods in base classes that this method might override.
BasePaths Paths;
- // FIXME: This will not include hidden member functions.
if (LookupInBases(cast<CXXRecordDecl>(DC),
- MemberLookupCriteria(Name, LookupMemberName,
- // FIXME: Shouldn't IDNS_Member be
- // enough here?
- Decl::IDNS_Member |
- Decl::IDNS_Ordinary), Paths)) {
+ MemberLookupCriteria(NewMD), Paths)) {
for (BasePaths::decl_iterator I = Paths.found_decls_begin(),
E = Paths.found_decls_end(); I != E; ++I) {
if (CXXMethodDecl *OldMD = dyn_cast<CXXMethodDecl>(*I)) {
- OverloadedFunctionDecl::function_iterator MatchedDecl;
- // FIXME: Is this OK? Should it be done by LookupInBases?
- if (IsOverload(NewMD, OldMD, MatchedDecl))
- continue;
- if (!OldMD->isVirtual())
- continue;
-
if (!CheckOverridingFunctionReturnType(NewMD, OldMD))
NewMD->addOverriddenMethod(OldMD);
}
++Paths.ScratchPath.Decls.first;
}
break;
+ case MemberLookupCriteria::LK_OverriddenMember:
+ Paths.ScratchPath.Decls =
+ BaseRecord->lookup(Context, Criteria.Method->getDeclName());
+ while (Paths.ScratchPath.Decls.first != Paths.ScratchPath.Decls.second) {
+ CXXMethodDecl *MD =
+ cast<CXXMethodDecl>(*Paths.ScratchPath.Decls.first);
+
+ OverloadedFunctionDecl::function_iterator MatchedDecl;
+ if (MD->isVirtual() && !IsOverload(Criteria.Method, MD, MatchedDecl)) {
+ FoundPathToThisBase = true;
+ break;
+ }
+
+ ++Paths.ScratchPath.Decls.first;
+ }
+ break;
}
if (FoundPathToThisBase) {
/// LookupKind - the kind of lookup we're doing.
enum LookupKind {
LK_Base,
- LK_NamedMember
+ LK_NamedMember,
+ LK_OverriddenMember
};
/// MemberLookupCriteria - Constructs member lookup criteria to
unsigned IDNS)
: Kind(LK_NamedMember), Name(Name), NameKind(NameKind), IDNS(IDNS) { }
+ explicit MemberLookupCriteria(CXXMethodDecl *MD)
+ : Kind(LK_OverriddenMember), Method(MD) { }
+
/// Kind - The kind of lookup we're doing.
/// LK_Base if we are looking for a base class (whose
/// type is Base). LK_NamedMember if we are looking for a named member of
Sema::LookupNameKind NameKind;
unsigned IDNS;
+
+ CXXMethodDecl *Method;
};
}
};
bar x;
+
+// <rdar://problem/6902298>
+class A
+{
+public:
+ virtual void release() = 0;
+ virtual void release(int count) = 0;
+ virtual void retain() = 0;
+};
+
+class B : public A
+{
+public:
+ virtual void release();
+ virtual void release(int count);
+ virtual void retain();
+};
+
+void foo(void)
+{
+ B b;
+}
+