diff options
author | Eli Friedman <eli.friedman@gmail.com> | 2009-01-20 07:46:22 +0000 |
---|---|---|
committer | Eli Friedman <eli.friedman@gmail.com> | 2009-01-20 07:46:22 +0000 |
commit | 6597f985156b3a24c0a9db1e01eeec85714c4a8d (patch) | |
tree | cfed15374eb0f085e30f24ffa08393f2c2a041bc /lib | |
parent | 4e3d7626e479866182d1a2d1b138813cf2d7adb1 (diff) |
Fix for PR3350: add special-casing for "references" to va_lists in
builtins.
Also, a minor tweak to va_copy for consistency.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@62574 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r-- | lib/AST/Builtins.cpp | 17 | ||||
-rw-r--r-- | lib/CodeGen/CGBuiltin.cpp | 6 |
2 files changed, 18 insertions, 5 deletions
diff --git a/lib/AST/Builtins.cpp b/lib/AST/Builtins.cpp index a721c6ea8c..b675c72973 100644 --- a/lib/AST/Builtins.cpp +++ b/lib/AST/Builtins.cpp @@ -142,6 +142,23 @@ static QualType DecodeTypeFromStr(const char *&Str, ASTContext &Context, Type = Context.getBuiltinVaListType(); assert(!Type.isNull() && "builtin va list type not initialized!"); break; + case 'A': + // This is a "reference" to a va_list; however, what exactly + // this means depends on how va_list is defined. There are two + // different kinds of va_list: ones passed by value, and ones + // passed by reference. An example of a by-value va_list is + // x86, where va_list is a char*. An example of by-ref va_list + // is x86-64, where va_list is a __va_list_tag[1]. For x86, + // we want this argument to be a char*&; for x86-64, we want + // it to be a __va_list_tag*. + Type = Context.getBuiltinVaListType(); + assert(!Type.isNull() && "builtin va list type not initialized!"); + if (Type->isArrayType()) { + Type = Context.getArrayDecayedType(Type); + } else { + Type = Context.getReferenceType(Type); + } + break; case 'V': { char *End; diff --git a/lib/CodeGen/CGBuiltin.cpp b/lib/CodeGen/CGBuiltin.cpp index 6e140da732..2d840ffd8d 100644 --- a/lib/CodeGen/CGBuiltin.cpp +++ b/lib/CodeGen/CGBuiltin.cpp @@ -67,11 +67,7 @@ RValue CodeGenFunction::EmitBuiltinExpr(unsigned BuiltinID, const CallExpr *E) { case Builtin::BI__builtin_va_copy: { // FIXME: This does not yet handle architectures where va_list is a struct. Value *DstPtr = EmitLValue(E->getArg(0)).getAddress(); - Value *SrcValue = EmitScalarExpr(E->getArg(1)); - - Value *SrcPtr = CreateTempAlloca(SrcValue->getType(), "dst_ptr"); - - Builder.CreateStore(SrcValue, SrcPtr, false); + Value *SrcPtr = EmitLValue(E->getArg(1)).getAddress(); const llvm::Type *Type = llvm::PointerType::getUnqual(llvm::Type::Int8Ty); |