[llvm-commits] [llvm] r48645 - in /llvm/trunk: include/llvm/DerivedTypes.h lib/VMCore/Type.cpp
Duncan Sands
baldrick at free.fr
Fri Mar 21 08:53:27 PDT 2008
Author: baldrick
Date: Fri Mar 21 10:53:17 2008
New Revision: 48645
URL: http://llvm.org/viewvc/llvm-project?rev=48645&view=rev
Log:
Make it possible to get an empty struct using
the new StructType::get method. The second NULL
is to pacify the gcc warning mechanism. This
patch compiles but is otherwise untested.
Modified:
llvm/trunk/include/llvm/DerivedTypes.h
llvm/trunk/lib/VMCore/Type.cpp
Modified: llvm/trunk/include/llvm/DerivedTypes.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/DerivedTypes.h?rev=48645&r1=48644&r2=48645&view=diff
==============================================================================
--- llvm/trunk/include/llvm/DerivedTypes.h (original)
+++ llvm/trunk/include/llvm/DerivedTypes.h Fri Mar 21 10:53:17 2008
@@ -221,8 +221,9 @@
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
Modified: llvm/trunk/lib/VMCore/Type.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Type.cpp?rev=48645&r1=48644&r2=48645&view=diff
==============================================================================
--- llvm/trunk/lib/VMCore/Type.cpp (original)
+++ llvm/trunk/lib/VMCore/Type.cpp Fri Mar 21 10:53:17 2008
@@ -1252,9 +1252,10 @@
va_list ap;
std::vector<const llvm::Type*> 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);
}
More information about the llvm-commits
mailing list