[PATCH] [ms-cxxabi] Mangle function pointer arguments correctly
Richard Smith
richard at metafoo.co.uk
Mon Jun 3 10:56:14 PDT 2013
Am I right in thinking this patch depends on your other patch to keep the type before parameter decay as the TypeSourceInfo of a FunctionDecl?
================
Comment at: lib/AST/MicrosoftMangle.cpp:263-264
@@ -262,2 +262,4 @@
// We don't even know how to mangle their types anyway :).
- const FunctionProtoType *FT = FD->getType()->castAs<FunctionProtoType>();
+ TypeSourceInfo *TSI = FD->getTypeSourceInfo();
+ QualType T = TSI ? TSI->getType() : FD->getType();
+ const FunctionProtoType *FT = T->castAs<FunctionProtoType>();
----------------
Which declaration is 'FD' here? If I have this in a header:
void f(int p[123]);
... and this in my source file:
#include "header"
void f(int *const p) {}
... then do we use the mangling for the header's declaration or for the source file's declaration? I would guess (or rather, hope) that we use the mangling for the first declaration of the function.
================
Comment at: lib/AST/MicrosoftMangle.cpp:1217-1225
@@ -1210,11 +1216,11 @@
if (D) {
- // If we got a decl, use the type-as-written to make sure arrays
- // get mangled right. Note that we can't rely on the TSI
- // existing if (for example) the parameter was synthesized.
+ // If we got a decl, use it to get the source range. This used to be
+ // important for getting the type-as-written. We've since changed to
+ // traversing the type-as-written, so this shouldn't be necessary anymore.
for (FunctionDecl::param_const_iterator Parm = D->param_begin(),
ParmEnd = D->param_end(); Parm != ParmEnd; ++Parm) {
TypeSourceInfo *TSI = (*Parm)->getTypeSourceInfo();
QualType Type = TSI ? TSI->getType() : (*Parm)->getType();
mangleArgumentType(Type, (*Parm)->getSourceRange());
}
} else {
----------------
Can you just use the parameter types from the FunctionProtoType here?
http://llvm-reviews.chandlerc.com/D844
More information about the cfe-commits
mailing list