On Jul 3, 2010, at 9:56 AM, Charles Davis wrote: > Author: cdavis > Date: Sat Jul 3 11:56:59 2010 > New Revision: 107572 > > URL: http://llvm.org/viewvc/llvm-project?rev=107572&view=rev > Log: > Mangle Objective-C pointers and block pointers in the Microsoft C++ > Mangler. > > ObjC pointers were easy enough (as far as the ABI is concerned, > they're > just pointers to structs), but I had to invent a new mangling for > block > pointers. This is particularly worrying with the Microsoft ABI, > because > it is a vendor-specific ABI; extending it could come back to bite us > later when MS extends it on their own (and you know they will).
Any reason you can't follow gcc/clang's mangling scheme for blocks; such as '@' is already being used? - Fariborz > > Modified: > cfe/trunk/lib/CodeGen/MicrosoftCXXABI.cpp > cfe/trunk/test/CodeGenCXX/mangle-ms.cpp > > Modified: cfe/trunk/lib/CodeGen/MicrosoftCXXABI.cpp > URL: > http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/MicrosoftCXXABI.cpp?rev=107572&r1=107571&r2=107572&view=diff > = > = > = > = > = > = > = > = > ====================================================================== > --- cfe/trunk/lib/CodeGen/MicrosoftCXXABI.cpp (original) > +++ cfe/trunk/lib/CodeGen/MicrosoftCXXABI.cpp Sat Jul 3 11:56:59 2010 > @@ -599,6 +599,7 @@ > // ::= _B <basis> # based function (far?) > (pointers only) > // ::= _C <basis> # based method (pointers > only) > // ::= _D <basis> # based method (far?) > (pointers only) > + // ::= _E # block (Clang) > // <basis> ::= 0 # __based(void) > // ::= 1 # __based(segment)? > // ::= 2 <name> # __based(name) > @@ -641,14 +642,15 @@ > Qualifiers Quals = T.getLocalQualifiers(); > if (Quals) { > // We have to mangle these now, while we still have enough > information. > - // <pointer-cvr-qualifiers> ::= P # pointer > - // ::= Q # const pointer > - // ::= R # volatile pointer > - // ::= S # const volatile pointer > - if (T->isAnyPointerType() || T->isMemberPointerType()) { > - if (!Quals.hasVolatile()) { > + // <pointer-cvr-qualifiers> ::= P # pointer > + // ::= Q # const pointer > + // ::= R # volatile pointer > + // ::= S # const volatile pointer > + if (T->isAnyPointerType() || T->isMemberPointerType() || > + T->isBlockPointerType()) { > + if (!Quals.hasVolatile()) > Out << 'Q'; > - } else { > + else { > if (!Quals.hasConst()) > Out << 'R'; > else > @@ -660,8 +662,8 @@ > // type has no qualifiers, the lack of qualifier gets mangled > // in there. > mangleQualifiers(Quals, false); > - } > - else if (T->isAnyPointerType() || T->isMemberPointerType()) { > + } else if (T->isAnyPointerType() || T->isMemberPointerType() || > + T->isBlockPointerType()) { > Out << 'P'; > } > switch (T->getTypeClass()) { > @@ -1040,7 +1042,9 @@ > } > } > void MicrosoftCXXNameMangler::mangleType(const ObjCObjectPointerType > *T) { > - assert(false && "Don't know how to mangle ObjCObjectPointerTypes > yet!"); > + // Object pointers never have qualifiers. > + Out << 'A'; > + mangleType(T->getPointeeType()); > } > > // <type> ::= <reference-type> > @@ -1073,15 +1077,20 @@ > } > > void MicrosoftCXXNameMangler::mangleType(const ObjCInterfaceType *T) { > - assert(false && "Don't know how to mangle ObjCInterfaceTypes > yet!"); > + // ObjC interfaces have structs underlying them. > + Out << 'U'; > + mangleName(T->getDecl()); > } > > void MicrosoftCXXNameMangler::mangleType(const ObjCObjectType *T) { > - assert(false && "Don't know how to mangle ObjCObjectTypes yet!"); > + // We don't allow overloading by different protocol qualification, > + // so mangling them isn't necessary. > + mangleType(T->getBaseType()); > } > > void MicrosoftCXXNameMangler::mangleType(const BlockPointerType *T) { > - assert(false && "Don't know how to mangle BlockPointerTypes yet!"); > + Out << "_E"; > + mangleType(T->getPointeeType()); > } > > void MicrosoftCXXNameMangler::mangleType(const InjectedClassNameType > *T) { > > Modified: cfe/trunk/test/CodeGenCXX/mangle-ms.cpp > URL: > http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/mangle-ms.cpp?rev=107572&r1=107571&r2=107572&view=diff > = > = > = > = > = > = > = > = > ====================================================================== > --- cfe/trunk/test/CodeGenCXX/mangle-ms.cpp (original) > +++ cfe/trunk/test/CodeGenCXX/mangle-ms.cpp Sat Jul 3 11:56:59 2010 > @@ -1,4 +1,4 @@ > -// RUN: %clang_cc1 -fms-extensions -emit-llvm %s -o - -cxx-abi > microsoft -triple=i386-apple-darwin10 | FileCheck %s > +// RUN: %clang_cc1 -fms-extensions -fblocks -emit-llvm %s -o - -cxx- > abi microsoft -triple=i386-apple-darwin10 | FileCheck %s > > // CHECK: @"\01?a@@3HA" > // CHECK: @"\0...@n@@3HA" > @@ -86,7 +86,11 @@ > void delta(int * const a, const long &) {} > // CHECK: @"\01?delta@@yaxqah...@z" > > -// Array mangling. (It should be mangled as a const pointer, but > that needs > -// to be fixed in Sema.) > +// Array mangling. > void epsilon(int a[][10][20]) {} > // CHECK: @"\01?epsilon@@yaxqay1...@h@Z" > + > +// Blocks mangling (Clang extension). > +void zeta(int (^)(int, int)) {} > +// CHECK: @"\01?zeta@@yaxp_ea...@z@Z" > + > > > _______________________________________________ > cfe-commits mailing list > [email protected] > http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits _______________________________________________ cfe-commits mailing list [email protected] http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
