This simplifies the CWriter code, makes the generated code easier to read,
authorChris Lattner <sabre@nondot.org>
Mon, 3 Nov 2003 04:31:54 +0000 (04:31 +0000)
committerChris Lattner <sabre@nondot.org>
Mon, 3 Nov 2003 04:31:54 +0000 (04:31 +0000)
and makes the output work with the intel compiler.  Overall, a win.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@9671 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Target/CBackend/CBackend.cpp
lib/Target/CBackend/Writer.cpp

index d778d1e946fab2389a940320d3d04fd5555a7509..e32987cbd2ee351948935b9fa39c25983e53ff42 100644 (file)
@@ -163,11 +163,6 @@ namespace {
   };
 }
 
-// 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 @@ std::ostream &CWriter::printType(std::ostream &Out, const Type *Ty,
     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);
   }
index d778d1e946fab2389a940320d3d04fd5555a7509..e32987cbd2ee351948935b9fa39c25983e53ff42 100644 (file)
@@ -163,11 +163,6 @@ namespace {
   };
 }
 
-// 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 @@ std::ostream &CWriter::printType(std::ostream &Out, const Type *Ty,
     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);
   }