[llvm-commits] [bug_122] CVS: llvm/lib/Target/CBackend/Writer.cpp

LLVM llvm at cs.uiuc.edu
Sun May 16 21:34:02 PDT 2004


Changes in directory llvm/lib/Target/CBackend:

Writer.cpp updated: 1.174.2.1 -> 1.174.2.2

---
Log message:

Apply changes resulting from SymbolTable's interface changes supporting
Types distinctly from Values.


---
Diffs of the changes:  (+19 -18)

Index: llvm/lib/Target/CBackend/Writer.cpp
diff -u llvm/lib/Target/CBackend/Writer.cpp:1.174.2.1 llvm/lib/Target/CBackend/Writer.cpp:1.174.2.2
--- llvm/lib/Target/CBackend/Writer.cpp:1.174.2.1	Wed May 12 11:33:43 2004
+++ llvm/lib/Target/CBackend/Writer.cpp	Sun May 16 21:34:01 2004
@@ -215,19 +215,18 @@
   // already named, and removing names for structure types that are not used.
   //
   SymbolTable &MST = M.getSymbolTable();
-  if (MST.find(Type::TypeTy) != MST.end())
-    for (SymbolTable::value_iterator I = MST.type_begin(Type::TypeTy),
-           E = MST.type_end(Type::TypeTy); I != E; ) {
-      SymbolTable::value_iterator It = I++;
-      if (StructType *STy = dyn_cast<StructType>(It->second)) {
-        // If this is not used, remove it from the symbol table.
-        std::set<const Type *>::iterator UTI = UT.find(STy);
-        if (UTI == UT.end())
-          MST.remove(It->first, It->second);
-        else
-          UT.erase(UTI);
-      }
+  for (SymbolTable::type_iterator TI = MST.type_begin(), TE = MST.type_end();
+       TI != TE; ) {
+    SymbolTable::type_iterator I = TI++;
+    if (StructType *STy = dyn_cast<StructType>(I->second)) {
+      // If this is not used, remove it from the symbol table.
+      std::set<const Type *>::iterator UTI = UT.find(STy);
+      if (UTI == UT.end())
+	MST.remove(I->first, I->second);
+      else
+	UT.erase(UTI);
     }
+  }
 
   // UT now contains types that are not named.  Loop over it, naming
   // structure types.
@@ -861,17 +860,17 @@
 ///
 void CWriter::printModuleTypes(const SymbolTable &ST) {
   // If there are no type names, exit early.
-  if (ST.find(Type::TypeTy) == ST.end())
+  if ( ST.hasTypes() )
     return;
 
   // We are only interested in the type plane of the symbol table...
-  SymbolTable::value_const_iterator I   = ST.type_begin(Type::TypeTy);
-  SymbolTable::value_const_iterator End = ST.type_end(Type::TypeTy);
+  SymbolTable::type_const_iterator I   = ST.type_begin();
+  SymbolTable::type_const_iterator End = ST.type_end();
   
   // Print out forward declarations for structure types before anything else!
   Out << "/* Structure forward decls */\n";
   for (; I != End; ++I)
-    if (const Type *STy = dyn_cast<StructType>(I->second)) {
+    if (const StructType *STy = dyn_cast<StructType>(I->second)) {
       std::string Name = "struct l_" + Mangler::makeNameProper(I->first);
       Out << Name << ";\n";
       TypeNames.insert(std::make_pair(STy, Name));
@@ -881,7 +880,7 @@
 
   // Now we can print out typedefs...
   Out << "/* Typedefs */\n";
-  for (I = ST.type_begin(Type::TypeTy); I != End; ++I) {
+  for (I = ST.type_begin(); I != End; ++I) {
     const Type *Ty = cast<Type>(I->second);
     std::string Name = "l_" + Mangler::makeNameProper(I->first);
     Out << "typedef ";
@@ -898,7 +897,7 @@
   // printed in the correct order.
   //
   Out << "/* Structure contents */\n";
-  for (I = ST.type_begin(Type::TypeTy); I != End; ++I)
+  for (I = ST.type_begin(); I != End; ++I)
     if (const StructType *STy = dyn_cast<StructType>(I->second))
       // Only print out used types!
       printContainedStructs(STy, StructPrinted);
@@ -1505,3 +1504,5 @@
                                             IntrinsicLowering *IL) {
   return new CTargetMachine(M, IL);
 }
+
+// vim: sw=2





More information about the llvm-commits mailing list