r243218 - Capture 'this' so GCC 4.7 can find a static members.

Benjamin Kramer benny.kra at googlemail.com
Sat Jul 25 08:27:04 PDT 2015


Author: d0k
Date: Sat Jul 25 10:27:04 2015
New Revision: 243218

URL: http://llvm.org/viewvc/llvm-project?rev=243218&view=rev
Log:
Capture 'this' so GCC 4.7 can find a static members.

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=243218&r1=243217&r2=243218&view=diff
==============================================================================
--- cfe/trunk/lib/AST/CXXInheritance.cpp (original)
+++ cfe/trunk/lib/AST/CXXInheritance.cpp Sat Jul 25 10:27:04 2015
@@ -87,8 +87,9 @@ bool CXXRecordDecl::isDerivedFrom(const
   Paths.setOrigin(const_cast<CXXRecordDecl*>(this));
 
   const CXXRecordDecl *BaseDecl = Base->getCanonicalDecl();
+  // FIXME: Capturing 'this' is a workaround for name lookup bugs in GCC 4.7.
   return lookupInBases(
-      [BaseDecl](const CXXBaseSpecifier *Specifier, CXXBasePath &Path) {
+      [this, BaseDecl](const CXXBaseSpecifier *Specifier, CXXBasePath &Path) {
         return FindBaseClass(Specifier, Path, BaseDecl);
       },
       Paths);
@@ -107,8 +108,9 @@ bool CXXRecordDecl::isVirtuallyDerivedFr
   Paths.setOrigin(const_cast<CXXRecordDecl*>(this));
 
   const CXXRecordDecl *BaseDecl = Base->getCanonicalDecl();
+  // FIXME: Capturing 'this' is a workaround for name lookup bugs in GCC 4.7.
   return lookupInBases(
-      [BaseDecl](const CXXBaseSpecifier *Specifier, CXXBasePath &Path) {
+      [this, BaseDecl](const CXXBaseSpecifier *Specifier, CXXBasePath &Path) {
         return FindVirtualBaseClass(Specifier, Path, BaseDecl);
       },
       Paths);
@@ -354,7 +356,7 @@ bool CXXRecordDecl::lookupInBases(BaseMa
 bool CXXRecordDecl::FindBaseClass(const CXXBaseSpecifier *Specifier, 
                                   CXXBasePath &Path,
                                   const CXXRecordDecl *BaseRecord) {
-  assert(((Decl *)BaseRecord)->getCanonicalDecl() == BaseRecord &&
+  assert(BaseRecord->getCanonicalDecl() == BaseRecord &&
          "User data for FindBaseClass is not canonical!");
   return Specifier->getType()->castAs<RecordType>()->getDecl()
             ->getCanonicalDecl() == BaseRecord;
@@ -363,7 +365,7 @@ bool CXXRecordDecl::FindBaseClass(const
 bool CXXRecordDecl::FindVirtualBaseClass(const CXXBaseSpecifier *Specifier, 
                                          CXXBasePath &Path,
                                          const CXXRecordDecl *BaseRecord) {
-  assert(((Decl *)BaseRecord)->getCanonicalDecl() == BaseRecord &&
+  assert(BaseRecord->getCanonicalDecl() == BaseRecord &&
          "User data for FindBaseClass is not canonical!");
   return Specifier->isVirtual() &&
          Specifier->getType()->castAs<RecordType>()->getDecl()





More information about the cfe-commits mailing list