Add an END_WITH_NULL accessor for ConstantStruct.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@126714 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Talin 2011-02-28 23:53:27 +00:00
parent e7200684b0
commit 41ee4e57ea
2 changed files with 15 additions and 2 deletions

View File

@ -425,6 +425,8 @@ public:
const std::vector<Constant*> &V, bool Packed);
static Constant *get(LLVMContext &Context,
Constant *const *Vals, unsigned NumVals, bool Packed);
static Constant *get(LLVMContext &Context, bool Packed,
Constant * Val, ...) END_WITH_NULL;
/// Transparently provide more efficient getOperand methods.
DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Constant);

View File

@ -33,6 +33,7 @@
#include "llvm/ADT/SmallVector.h"
#include <algorithm>
#include <map>
#include <cstdarg>
using namespace llvm;
//===----------------------------------------------------------------------===//
@ -596,8 +597,6 @@ Constant *ConstantArray::get(LLVMContext &Context, StringRef Str,
return get(ATy, ElementVals);
}
ConstantStruct::ConstantStruct(const StructType *T,
const std::vector<Constant*> &V)
: Constant(T, ConstantStructVal,
@ -644,6 +643,18 @@ Constant *ConstantStruct::get(LLVMContext &Context,
return get(Context, std::vector<Constant*>(Vals, Vals+NumVals), Packed);
}
Constant* ConstantStruct::get(LLVMContext &Context, bool Packed,
Constant * Val, ...) {
va_list ap;
std::vector<Constant*> Values;
va_start(ap, Val);
while (Val) {
Values.push_back(Val);
Val = va_arg(ap, llvm::Constant*);
}
return get(Context, Values, Packed);
}
ConstantVector::ConstantVector(const VectorType *T,
const std::vector<Constant*> &V)
: Constant(T, ConstantVectorVal,