From 3e3bb95b6951c313dd5dd1c099184c309a3952e2 Mon Sep 17 00:00:00 2001 From: George Burgess IV Date: Wed, 2 Dec 2015 21:58:08 +0000 Subject: Add the `pass_object_size` attribute to clang. `pass_object_size` is our way of enabling `__builtin_object_size` to produce high quality results without requiring inlining to happen everywhere. A link to the design doc for this attribute is available at the Differential review link below. Differential Revision: http://reviews.llvm.org/D13263 llvm-svn: 254554 --- clang/lib/AST/MicrosoftMangle.cpp | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) (limited to 'clang/lib/AST/MicrosoftMangle.cpp') diff --git a/clang/lib/AST/MicrosoftMangle.cpp b/clang/lib/AST/MicrosoftMangle.cpp index c1c2d2d1a45..3651673ffd2 100644 --- a/clang/lib/AST/MicrosoftMangle.cpp +++ b/clang/lib/AST/MicrosoftMangle.cpp @@ -1841,8 +1841,20 @@ void MicrosoftCXXNameMangler::mangleFunctionType(const FunctionType *T, Out << 'X'; } else { // Happens for function pointer type arguments for example. - for (const QualType &Arg : Proto->param_types()) - mangleArgumentType(Arg, Range); + for (unsigned I = 0, E = Proto->getNumParams(); I != E; ++I) { + mangleArgumentType(Proto->getParamType(I), Range); + // Mangle each pass_object_size parameter as if it's a paramater of enum + // type passed directly after the parameter with the pass_object_size + // attribute. The aforementioned enum's name is __pass_object_size, and we + // pretend it resides in a top-level namespace called __clang. + // + // FIXME: Is there a defined extension notation for the MS ABI, or is it + // necessary to just cross our fingers and hope this type+namespace + // combination doesn't conflict with anything? + if (D) + if (auto *P = D->getParamDecl(I)->getAttr()) + Out << "W4__pass_object_size" << P->getType() << "@__clang@@"; + } // ::= Z # ellipsis if (Proto->isVariadic()) Out << 'Z'; -- cgit v1.2.3