From: Douglas Gregor Date: Wed, 3 Mar 2010 01:02:31 +0000 (+0000) Subject: Factor out the recursive lookup into C++ base classes into a separate, X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=3262a0f7b8c5484635b591dc83125fd24d6ad016;p=clang Factor out the recursive lookup into C++ base classes into a separate, static function. No functionality change. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@97618 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/AST/CXXInheritance.cpp b/lib/AST/CXXInheritance.cpp index 99f908caea..265b454975 100644 --- a/lib/AST/CXXInheritance.cpp +++ b/lib/AST/CXXInheritance.cpp @@ -140,18 +140,20 @@ bool CXXRecordDecl::forallBases(ForallBasesCallback *BaseMatches, return AllMatches; } -bool CXXRecordDecl::lookupInBases(BaseMatchesCallback *BaseMatches, - void *UserData, - CXXBasePaths &Paths) const { +static bool lookupInBases(ASTContext &Context, const CXXRecordDecl *Record, + CXXRecordDecl::BaseMatchesCallback *BaseMatches, + void *UserData, + CXXBasePaths &Paths) { bool FoundPath = false; // The access of the path down to this record. AccessSpecifier AccessToHere = Paths.ScratchPath.Access; bool IsFirstStep = Paths.ScratchPath.empty(); - ASTContext &Context = getASTContext(); - for (base_class_const_iterator BaseSpec = bases_begin(), - BaseSpecEnd = bases_end(); BaseSpec != BaseSpecEnd; ++BaseSpec) { + for (CXXRecordDecl::base_class_const_iterator BaseSpec = Record->bases_begin(), + BaseSpecEnd = Record->bases_end(); + BaseSpec != BaseSpecEnd; + ++BaseSpec) { // Find the record of the base class subobjects for this type. QualType BaseType = Context.getCanonicalType(BaseSpec->getType()) .getUnqualifiedType(); @@ -186,7 +188,7 @@ bool CXXRecordDecl::lookupInBases(BaseMatchesCallback *BaseMatches, // Add this base specifier to the current path. CXXBasePathElement Element; Element.Base = &*BaseSpec; - Element.Class = this; + Element.Class = Record; if (BaseSpec->isVirtual()) Element.SubobjectNumber = 0; else @@ -212,7 +214,8 @@ bool CXXRecordDecl::lookupInBases(BaseMatchesCallback *BaseMatches, Paths.ScratchPath.Access = BaseSpec->getAccessSpecifier(); else Paths.ScratchPath.Access - = MergeAccess(AccessToHere, BaseSpec->getAccessSpecifier()); + = CXXRecordDecl::MergeAccess(AccessToHere, + BaseSpec->getAccessSpecifier()); } // Track whether there's a path involving this specific base. @@ -233,7 +236,7 @@ bool CXXRecordDecl::lookupInBases(BaseMatchesCallback *BaseMatches, CXXRecordDecl *BaseRecord = cast(BaseSpec->getType()->getAs() ->getDecl()); - if (BaseRecord->lookupInBases(BaseMatches, UserData, Paths)) { + if (lookupInBases(Context, BaseRecord, BaseMatches, UserData, Paths)) { // C++ [class.member.lookup]p2: // A member name f in one sub-object B hides a member name f in // a sub-object A if A is a base class sub-object of B. Any @@ -266,6 +269,12 @@ bool CXXRecordDecl::lookupInBases(BaseMatchesCallback *BaseMatches, return FoundPath; } +bool CXXRecordDecl::lookupInBases(BaseMatchesCallback *BaseMatches, + void *UserData, + CXXBasePaths &Paths) const { + return ::lookupInBases(getASTContext(), this, BaseMatches, UserData, Paths); +} + bool CXXRecordDecl::FindBaseClass(const CXXBaseSpecifier *Specifier, CXXBasePath &Path, void *BaseRecord) {