From: Benjamin Kramer Date: Sat, 25 Jul 2015 15:27:04 +0000 (+0000) Subject: Capture 'this' so GCC 4.7 can find a static members. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=70cc20fef2f6589f23adab997c8ece419b0b8463;p=clang Capture 'this' so GCC 4.7 can find a static members. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@243218 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/AST/CXXInheritance.cpp b/lib/AST/CXXInheritance.cpp index c8529196c8..75d775f260 100644 --- a/lib/AST/CXXInheritance.cpp +++ b/lib/AST/CXXInheritance.cpp @@ -87,8 +87,9 @@ bool CXXRecordDecl::isDerivedFrom(const CXXRecordDecl *Base, Paths.setOrigin(const_cast(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::isVirtuallyDerivedFrom(const CXXRecordDecl *Base) const { Paths.setOrigin(const_cast(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(BaseMatchesCallback BaseMatches, 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()->getDecl() ->getCanonicalDecl() == BaseRecord; @@ -363,7 +365,7 @@ bool CXXRecordDecl::FindBaseClass(const CXXBaseSpecifier *Specifier, 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()->getDecl()