// z -> size_t
// F -> constant CFString
// a -> __builtin_va_list
+// A -> "reference" to __builtin_va_list
// V -> Vector, following num elements and a base type.
// . -> "...". This may only occur at the end of the function list.
//
BUILTIN(__builtin_constant_p, "Us.", "nc")
BUILTIN(__builtin_classify_type, "i.", "nc")
BUILTIN(__builtin___CFStringMakeConstantString, "FC*cC*", "nc")
-BUILTIN(__builtin_va_start, "va&.", "n")
-BUILTIN(__builtin_va_end, "va&", "n")
-BUILTIN(__builtin_va_copy, "va&a", "n")
-BUILTIN(__builtin_stdarg_start, "va&.", "n")
+BUILTIN(__builtin_va_start, "vA.", "n")
+BUILTIN(__builtin_va_end, "vA", "n")
+BUILTIN(__builtin_va_copy, "vAA", "n")
+BUILTIN(__builtin_stdarg_start, "vA.", "n")
BUILTIN(__builtin_bzero, "vv*z", "n")
BUILTIN(__builtin_memcpy, "v*v*vC*z", "n")
BUILTIN(__builtin_memmove, "v*v*vC*z", "n")
/// hasVAListUse - Return true of the specified builtin uses __builtin_va_list
/// as an operand or return type.
bool hasVAListUse(unsigned ID) const {
- return strchr(GetRecord(ID).Type, 'a') != 0;
+ return strpbrk(GetRecord(ID).Type, "Aa") != 0;
}
/// GetBuiltinType - Return the type for the specified builtin.
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;
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);
__builtin_va_list ap;
__builtin_va_start(ap); // expected-error {{too few arguments to function}}
}
+
+// PR3350
+void
+foo(__builtin_va_list authors, ...) {
+ __builtin_va_start (authors, authors);
+ (void)__builtin_va_arg(authors, int);
+ __builtin_va_end (authors);
+}
+