From 41ee4e57ea0f2afb89fd136065edb03f32f972d3 Mon Sep 17 00:00:00 2001 From: Talin Date: Mon, 28 Feb 2011 23:53:27 +0000 Subject: [PATCH] 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 --- include/llvm/Constants.h | 2 ++ lib/VMCore/Constants.cpp | 15 +++++++++++++-- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/include/llvm/Constants.h b/include/llvm/Constants.h index c4768f84234..4ca22984b60 100644 --- a/include/llvm/Constants.h +++ b/include/llvm/Constants.h @@ -425,6 +425,8 @@ public: const std::vector &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); diff --git a/lib/VMCore/Constants.cpp b/lib/VMCore/Constants.cpp index 246fde1569a..5468a4f1b4a 100644 --- a/lib/VMCore/Constants.cpp +++ b/lib/VMCore/Constants.cpp @@ -33,6 +33,7 @@ #include "llvm/ADT/SmallVector.h" #include #include +#include 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 &V) : Constant(T, ConstantStructVal, @@ -644,6 +643,18 @@ Constant *ConstantStruct::get(LLVMContext &Context, return get(Context, std::vector(Vals, Vals+NumVals), Packed); } +Constant* ConstantStruct::get(LLVMContext &Context, bool Packed, + Constant * Val, ...) { + va_list ap; + std::vector 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 &V) : Constant(T, ConstantVectorVal, -- 2.34.1