aboutsummaryrefslogtreecommitdiff
path: root/lib/AST/CXXInheritance.cpp
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2010-03-03 01:02:31 +0000
committerDouglas Gregor <dgregor@apple.com>2010-03-03 01:02:31 +0000
commit3262a0f7b8c5484635b591dc83125fd24d6ad016 (patch)
treec82447012d9f8651517d8fc064dfb82a63a9f7bd /lib/AST/CXXInheritance.cpp
parente4687ef4b9c72e1c476fce27d0abc1a2f78f739c (diff)
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
Diffstat (limited to 'lib/AST/CXXInheritance.cpp')
-rw-r--r--lib/AST/CXXInheritance.cpp27
1 files changed, 18 insertions, 9 deletions
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<CXXRecordDecl>(BaseSpec->getType()->getAs<RecordType>()
->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) {