[llvm-commits] CVS: llvm/lib/CWriter/Writer.cpp

Chris Lattner lattner at cs.uiuc.edu
Sun Nov 2 22:33:01 PST 2003


Changes in directory llvm/lib/CWriter:

Writer.cpp updated: 1.139 -> 1.140

---
Log message:

This simplifies the CWriter code, makes the generated code easier to read,
and makes the output work with the intel compiler.  Overall, a win.


---
Diffs of the changes:  (+2 -11)

Index: llvm/lib/CWriter/Writer.cpp
diff -u llvm/lib/CWriter/Writer.cpp:1.139 llvm/lib/CWriter/Writer.cpp:1.140
--- llvm/lib/CWriter/Writer.cpp:1.139	Sun Nov  2 19:01:59 2003
+++ llvm/lib/CWriter/Writer.cpp	Sun Nov  2 22:31:54 2003
@@ -163,11 +163,6 @@
   };
 }
 
-// A pointer type should not use parens around *'s alone, e.g., (**)
-inline bool ptrTypeNameNeedsParens(const std::string &NameSoFar) {
-  return NameSoFar.find_last_not_of('*') != std::string::npos;
-}
-
 // Pass the Type* and the variable name and this prints out the variable
 // declaration.
 //
@@ -240,12 +235,8 @@
     const PointerType *PTy = cast<PointerType>(Ty);
     std::string ptrName = "*" + NameSoFar;
 
-    // Do not need parens around "* NameSoFar" if NameSoFar consists only
-    // of zero or more '*' chars *and* this is not an unnamed pointer type
-    // such as the result type in a cast statement.  Otherwise, enclose in ( ).
-    if (ptrTypeNameNeedsParens(NameSoFar) ||
-        PTy->getElementType()->getPrimitiveID() == Type::ArrayTyID)
-      ptrName = "(" + ptrName + ")";    // 
+    if (isa<ArrayType>(PTy->getElementType()))
+      ptrName = "(" + ptrName + ")";
 
     return printType(Out, PTy->getElementType(), ptrName);
   }





More information about the llvm-commits mailing list