[cfe-commits] r97618 - /cfe/trunk/lib/AST/CXXInheritance.cpp

Douglas Gregor dgregor at apple.com
Tue Mar 2 17:02:32 PST 2010


Author: dgregor
Date: Tue Mar  2 19:02:31 2010
New Revision: 97618

URL: http://llvm.org/viewvc/llvm-project?rev=97618&view=rev
Log:
Factor out the recursive lookup into C++ base classes into a separate,
static function. No functionality change.

Modified:
    cfe/trunk/lib/AST/CXXInheritance.cpp

Modified: cfe/trunk/lib/AST/CXXInheritance.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/CXXInheritance.cpp?rev=97618&r1=97617&r2=97618&view=diff
==============================================================================
--- cfe/trunk/lib/AST/CXXInheritance.cpp (original)
+++ cfe/trunk/lib/AST/CXXInheritance.cpp Tue Mar  2 19:02:31 2010
@@ -140,18 +140,20 @@
   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 @@
       // 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 @@
         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 @@
       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 @@
   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) {





More information about the cfe-commits mailing list