diff options
author | John McCall <rjmccall@apple.com> | 2012-05-01 02:33:44 +0000 |
---|---|---|
committer | John McCall <rjmccall@apple.com> | 2012-05-01 02:33:44 +0000 |
commit | 23dfaa1cef1eb1b47195408fdd456a238097ee9c (patch) | |
tree | 7dc86d3a584ce3e22e179ed8986e0ec4873195e7 /clang/lib/AST/MicrosoftMangle.cpp | |
parent | d37a0c09441bbe4c339d14b758ceb4c888c64c68 (diff) | |
download | bcm5719-llvm-23dfaa1cef1eb1b47195408fdd456a238097ee9c.tar.gz bcm5719-llvm-23dfaa1cef1eb1b47195408fdd456a238097ee9c.zip |
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!
llvm-svn: 155879
Diffstat (limited to 'clang/lib/AST/MicrosoftMangle.cpp')
-rw-r--r-- | clang/lib/AST/MicrosoftMangle.cpp | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/clang/lib/AST/MicrosoftMangle.cpp b/clang/lib/AST/MicrosoftMangle.cpp index ba9856a8432..6250f611986 100644 --- a/clang/lib/AST/MicrosoftMangle.cpp +++ b/clang/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(); |