[cfe-commits] r142693 - in /cfe/trunk: lib/CodeGen/CGRTTI.cpp lib/Sema/SemaDeclAttr.cpp lib/Sema/SemaDeclCXX.cpp test/CodeGenCXX/weak-extern-typeinfo.cpp
Douglas Gregor
dgregor at apple.com
Mon Oct 24 10:21:36 PDT 2011
On Oct 21, 2011, at 3:27 PM, Fariborz Jahanian wrote:
> Author: fjahanian
> Date: Fri Oct 21 17:27:12 2011
> New Revision: 142693
>
> URL: http://llvm.org/viewvc/llvm-project?rev=142693&view=rev
> Log:
> c++: support gcc's application of weak attribute on
> class declaration which forces any such class and any
> class that inherits from such a class to have their
> typeinfo symbols be marked as weak.
> // rdar://10246395
> A test/CodeGenCXX/weak-extern-typeinfo.cpp
> M lib/Sema/SemaDeclCXX.cpp
> M lib/Sema/SemaDeclAttr.cpp
> M lib/CodeGen/CGRTTI.cpp
>
> Added:
> cfe/trunk/test/CodeGenCXX/weak-extern-typeinfo.cpp
> Modified:
> cfe/trunk/lib/CodeGen/CGRTTI.cpp
> cfe/trunk/lib/Sema/SemaDeclAttr.cpp
> cfe/trunk/lib/Sema/SemaDeclCXX.cpp
>
> Modified: cfe/trunk/lib/CodeGen/CGRTTI.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGRTTI.cpp?rev=142693&r1=142692&r2=142693&view=diff
> ==============================================================================
> --- cfe/trunk/lib/CodeGen/CGRTTI.cpp (original)
> +++ cfe/trunk/lib/CodeGen/CGRTTI.cpp Fri Oct 21 17:27:12 2011
> @@ -336,6 +336,8 @@
>
> if (const RecordType *Record = dyn_cast<RecordType>(Ty)) {
> const CXXRecordDecl *RD = cast<CXXRecordDecl>(Record->getDecl());
> + if (RD->hasAttr<WeakAttr>())
> + return llvm::GlobalValue::WeakODRLinkage;
> if (RD->isDynamicClass())
> return CGM.getVTableLinkage(RD);
> }
>
> Modified: cfe/trunk/lib/Sema/SemaDeclAttr.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclAttr.cpp?rev=142693&r1=142692&r2=142693&view=diff
> ==============================================================================
> --- cfe/trunk/lib/Sema/SemaDeclAttr.cpp (original)
> +++ cfe/trunk/lib/Sema/SemaDeclAttr.cpp Fri Oct 21 17:27:12 2011
> @@ -1914,6 +1914,10 @@
> }
>
> if (!isa<VarDecl>(D) && !isa<FunctionDecl>(D)) {
> + if (isa<CXXRecordDecl>(D)) {
> + D->addAttr(::new (S.Context) WeakAttr(Attr.getRange(), S.Context));
> + return;
> + }
> S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type)
> << Attr.getName() << ExpectedVariableOrFunction;
> return;
>
> Modified: cfe/trunk/lib/Sema/SemaDeclCXX.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclCXX.cpp?rev=142693&r1=142692&r2=142693&view=diff
> ==============================================================================
> --- cfe/trunk/lib/Sema/SemaDeclCXX.cpp (original)
> +++ cfe/trunk/lib/Sema/SemaDeclCXX.cpp Fri Oct 21 17:27:12 2011
> @@ -1151,6 +1151,10 @@
> // Okay, add this new base class.
> KnownBaseTypes[NewBaseType] = Bases[idx];
> Bases[NumGoodBases++] = Bases[idx];
> + if (const RecordType *Record = dyn_cast<RecordType>(NewBaseType))
Shouldn't this use NewBaseType->getAs<RecordType>()?
- Doug
More information about the cfe-commits
mailing list