aboutsummaryrefslogtreecommitdiff
path: root/lib/AST/MicrosoftMangle.cpp
diff options
context:
space:
mode:
authorJohn McCall <rjmccall@apple.com>2012-05-01 02:33:44 +0000
committerJohn McCall <rjmccall@apple.com>2012-05-01 02:33:44 +0000
commit3a8ac07956ac63bd202cdd3b9e4a2c6cefa888da (patch)
tree3c8c25cc4d4ae65609651816efb16e18471b2664 /lib/AST/MicrosoftMangle.cpp
parent198ff65aff048b969db85a02ea52bd8b73637bbe (diff)
When mangling a synthetic function declaration, we might not have
type-source information for its parameters. Don't crash when mangling them in the MS C++ ABI. Patch by Timur Iskhodzhanov! git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@155879 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/AST/MicrosoftMangle.cpp')
-rw-r--r--lib/AST/MicrosoftMangle.cpp14
1 files changed, 9 insertions, 5 deletions
diff --git a/lib/AST/MicrosoftMangle.cpp b/lib/AST/MicrosoftMangle.cpp
index ba9856a843..6250f61198 100644
--- a/lib/AST/MicrosoftMangle.cpp
+++ b/lib/AST/MicrosoftMangle.cpp
@@ -763,12 +763,16 @@ void MicrosoftCXXNameMangler::mangleType(const FunctionType *T,
Out << 'X';
} else {
if (D) {
- // If we got a decl, use the "types-as-written" to make sure arrays
- // get mangled right.
+ // 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.
for (FunctionDecl::param_const_iterator Parm = D->param_begin(),
- ParmEnd = D->param_end();
- Parm != ParmEnd; ++Parm)
- mangleType((*Parm)->getTypeSourceInfo()->getType());
+ ParmEnd = D->param_end(); Parm != ParmEnd; ++Parm) {
+ if (TypeSourceInfo *typeAsWritten = (*Parm)->getTypeSourceInfo())
+ mangleType(typeAsWritten->getType());
+ else
+ mangleType((*Parm)->getType());
+ }
} else {
for (FunctionProtoType::arg_type_iterator Arg = Proto->arg_type_begin(),
ArgEnd = Proto->arg_type_end();