r179153 - Don't crash when mangling types defined in ObjC class extensions.

Jordan Rose jordan_rose at apple.com
Wed Apr 10 09:11:03 PDT 2013


On Apr 9, 2013, at 23:08 , John McCall <rjmccall at apple.com> wrote:

> Author: rjmccall
> Date: Wed Apr 10 01:08:21 2013
> New Revision: 179153
> 
> URL: http://llvm.org/viewvc/llvm-project?rev=179153&view=rev
> Log:
> Don't crash when mangling types defined in ObjC class extensions.
> 
> The original test case here was mangling a type name for TBAA,
> but we can provoke this in C++11 easily enough.
> 
> rdar://13434937
> 
> Modified:
>    cfe/trunk/lib/AST/ItaniumMangle.cpp
>    cfe/trunk/test/CodeGenObjCXX/mangle.mm
> 
> Modified: cfe/trunk/lib/AST/ItaniumMangle.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ItaniumMangle.cpp?rev=179153&r1=179152&r2=179153&view=diff
> ==============================================================================
> --- cfe/trunk/lib/AST/ItaniumMangle.cpp (original)
> +++ cfe/trunk/lib/AST/ItaniumMangle.cpp Wed Apr 10 01:08:21 2013
> @@ -1095,6 +1095,15 @@ void CXXNameMangler::mangleUnqualifiedNa
>       mangleSourceName(FD->getIdentifier());
>       break;
>     }
> +
> +    // Class extensions have no name as a category, and it's possible
> +    // for them to be the semantic parent of certain declarations
> +    // (primarily, tag decls defined within declarations).  Such
> +    // declarations will always have internal linkage, so the name
> +    // doesn't really matter, but we shouldn't crash on them.  For
> +    // safety, just handle all ObjC containers here.
> +    if (isa<ObjCContainerDecl>(ND))
> +      break;
> 

Is that true? If I do this awful thing:

@interface SomeClass ()
@property struct Evil {
	int i;
	void print() const;
} myEvil;
@end

then Evil gets internal linkage? (I guess that's an acceptable language rule, but I'm not sure where we would have stated that explicitly.)

Full test case (haven't rebuilt Clang yet, so I don't know what happens):

@interface SomeClass
@end

@interface SomeClass ()
@property struct Evil {
	
int i;
	
void print() const;
} myEvil;
@end

@implementation SomeClass
@end

void Evil::print() const {}

Jordan
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20130410/abab5ab5/attachment.html>


More information about the cfe-commits mailing list