Print empty structs as {} rather than { }.
authorDan Gohman <gohman@apple.com>
Thu, 8 Apr 2010 18:03:05 +0000 (18:03 +0000)
committerDan Gohman <gohman@apple.com>
Thu, 8 Apr 2010 18:03:05 +0000 (18:03 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@100787 91177308-0d34-0410-b5e6-96231b3b80d8

lib/VMCore/AsmWriter.cpp
test/FrontendC/2007-05-16-EmptyStruct.c
test/Transforms/InstCombine/invariant.ll
test/Transforms/SCCP/ipsccp-basic.ll

index f6a6076df7bc40b0865d21c641782bedb9322b60..6c1aa5ed10c6f8d971344019522060606fb0bb16 100644 (file)
@@ -227,13 +227,15 @@ void TypePrinting::CalcTypeName(const Type *Ty,
     const StructType *STy = cast<StructType>(Ty);
     if (STy->isPacked())
       OS << '<';
-    OS << "{ ";
+    OS << '{';
     for (StructType::element_iterator I = STy->element_begin(),
          E = STy->element_end(); I != E; ++I) {
+      OS << ' ';
       CalcTypeName(*I, TypeStack, OS);
-      if (next(I) != STy->element_end())
+      if (next(I) == STy->element_end())
+        OS << ' ';
+      else
         OS << ',';
-      OS << ' ';
     }
     OS << '}';
     if (STy->isPacked())
@@ -242,13 +244,15 @@ void TypePrinting::CalcTypeName(const Type *Ty,
   }
   case Type::UnionTyID: {
     const UnionType *UTy = cast<UnionType>(Ty);
-    OS << "union { ";
+    OS << "union {";
     for (StructType::element_iterator I = UTy->element_begin(),
          E = UTy->element_end(); I != E; ++I) {
+      OS << ' ';
       CalcTypeName(*I, TypeStack, OS);
-      if (next(I) != UTy->element_end())
+      if (next(I) == UTy->element_end())
+        OS << ' ';
+      else
         OS << ',';
-      OS << ' ';
     }
     OS << '}';
     break;
index 748aa98351d58156c141b690f8d1c136606edab9..23c0b1d6a3f6183e5eb7b00917512a5a11137a11 100644 (file)
@@ -1,5 +1,5 @@
 // PR 1417
 
-// RUN: %llvmgcc -xc  %s -c -o - | llvm-dis | grep "struct.anon = type \{ \}"
+// RUN: %llvmgcc -xc  %s -c -o - | llvm-dis | grep "struct.anon = type \{\}"
 
 struct { } *X;
index c67ad3319593ed9dee99cde2029421957192d315..383238022692c9affad681e1ea4c2796ac7085a6 100644 (file)
@@ -3,13 +3,13 @@
 
 declare void @g(i8*)
 
-declare { }* @llvm.invariant.start(i64, i8* nocapture) nounwind readonly
+declare {}* @llvm.invariant.start(i64, i8* nocapture) nounwind readonly
 
 define i8 @f() {
   %a = alloca i8                                  ; <i8*> [#uses=4]
   store i8 0, i8* %a
-  %i = call { }* @llvm.invariant.start(i64 1, i8* %a) ; <{ }*> [#uses=0]
-  ; CHECK: call { }* @llvm.invariant.start
+  %i = call {}* @llvm.invariant.start(i64 1, i8* %a) ; <{}*> [#uses=0]
+  ; CHECK: call {}* @llvm.invariant.start
   call void @g(i8* %a)
   %r = load i8* %a                                ; <i8> [#uses=1]
   ret i8 %r
index e3699209a35bf6f2bd88d135d6acd9e174fa4fb9..a3c7637f986bc2b297f30d4f89d6c78ae5b132a2 100644 (file)
@@ -188,7 +188,7 @@ define void @test8b(i32* %P) {
     %X = call {} @test8a(i32 5, i32* %P)
     ret void
 ; CHECK: define void @test8b
-; CHECK-NEXT: call { } @test8a
+; CHECK-NEXT: call {} @test8a
 ; CHECK-NEXT: ret void
 }