diff --git a/include/llvm/DerivedTypes.h b/include/llvm/DerivedTypes.h index 7fc7ed6a91c..5f4569cfd15 100644 --- a/include/llvm/DerivedTypes.h +++ b/include/llvm/DerivedTypes.h @@ -221,8 +221,9 @@ public: bool isPacked=false); /// StructType::get - This static method is a convenience method for - /// creating structure types by specifying the elements as arguments. Note - /// that this method always returns a non-packed struct. + /// creating structure types by specifying the elements as arguments. + /// Note that this method always returns a non-packed struct. To get + /// an empty struct, pass NULL, NULL. static StructType *get(const Type *type, ...) END_WITH_NULL; // Iterator access to the elements diff --git a/lib/VMCore/Type.cpp b/lib/VMCore/Type.cpp index 4554826c34b..829923e15a1 100644 --- a/lib/VMCore/Type.cpp +++ b/lib/VMCore/Type.cpp @@ -1252,9 +1252,10 @@ StructType *StructType::get(const Type *type, ...) { va_list ap; std::vector StructFields; va_start(ap, type); - do { + while (type) { StructFields.push_back(type); - } while ((type = va_arg(ap, llvm::Type*))); + type = va_arg(ap, llvm::Type*); + } return llvm::StructType::get(StructFields); }