diff options
author | Chris Lattner <sabre@nondot.org> | 2008-09-29 22:28:25 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2008-09-29 22:28:25 +0000 |
commit | 4a80a59b6e1f46c0868be8b96748e04e3ea0d23b (patch) | |
tree | 9d8e85c3d88d1fc270a2e5ebbc37f5fe1bf3af0f /clang/lib/AST/Builtins.cpp | |
parent | f61a84ec438f42f02d173ef5956b80fc04b02ae3 (diff) | |
download | bcm5719-llvm-4a80a59b6e1f46c0868be8b96748e04e3ea0d23b.tar.gz bcm5719-llvm-4a80a59b6e1f46c0868be8b96748e04e3ea0d23b.zip |
Fix va_arg handling to do argument decaying at the correct place. This
fixes problems handling references of va_list, which happens on x86_64.
This fixes PR2841 and rdar://6252231
llvm-svn: 56809
Diffstat (limited to 'clang/lib/AST/Builtins.cpp')
-rw-r--r-- | clang/lib/AST/Builtins.cpp | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/clang/lib/AST/Builtins.cpp b/clang/lib/AST/Builtins.cpp index 31e099af4ee..3980d205217 100644 --- a/clang/lib/AST/Builtins.cpp +++ b/clang/lib/AST/Builtins.cpp @@ -137,9 +137,6 @@ static QualType DecodeTypeFromStr(const char *&Str, ASTContext &Context, case 'a': Type = Context.getBuiltinVaListType(); assert(!Type.isNull() && "builtin va list type not initialized!"); - // Do array -> pointer decay. The builtin should use the decayed type. - if (Type->isArrayType()) - Type = Context.getArrayDecayedType(Type); break; case 'V': { char *End; @@ -185,8 +182,15 @@ QualType Builtin::Context::GetBuiltinType(unsigned id, llvm::SmallVector<QualType, 8> ArgTypes; QualType ResType = DecodeTypeFromStr(TypeStr, Context); - while (TypeStr[0] && TypeStr[0] != '.') - ArgTypes.push_back(DecodeTypeFromStr(TypeStr, Context)); + while (TypeStr[0] && TypeStr[0] != '.') { + QualType Ty = DecodeTypeFromStr(TypeStr, Context); + + // Do array -> pointer decay. The builtin should use the decayed type. + if (Ty->isArrayType()) + Ty = Context.getArrayDecayedType(Ty); + + ArgTypes.push_back(Ty); + } assert((TypeStr[0] != '.' || TypeStr[1] == 0) && "'.' should only occur at end of builtin type list!"); |