diff options
Diffstat (limited to 'clang/lib')
-rw-r--r-- | clang/lib/AST/Builtins.cpp | 17 | ||||
-rw-r--r-- | clang/lib/CodeGen/CGBuiltin.cpp | 6 |
2 files changed, 18 insertions, 5 deletions
diff --git a/clang/lib/AST/Builtins.cpp b/clang/lib/AST/Builtins.cpp index a721c6ea8c1..b675c729738 100644 --- a/clang/lib/AST/Builtins.cpp +++ b/clang/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/clang/lib/CodeGen/CGBuiltin.cpp b/clang/lib/CodeGen/CGBuiltin.cpp index 6e140da7323..2d840ffd8d6 100644 --- a/clang/lib/CodeGen/CGBuiltin.cpp +++ b/clang/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); |