[llvm-commits] [llvm] r51729 - /llvm/trunk/utils/TableGen/LLVMCConfigurationEmitter.cpp

Mikhail Glushenkov foldr at codedgers.com
Thu May 29 23:10:47 PDT 2008


Author: foldr
Date: Fri May 30 01:10:47 2008
New Revision: 51729

URL: http://llvm.org/viewvc/llvm-project?rev=51729&view=rev
Log:
Some small tweaks to make the generated code prettier.

Modified:
    llvm/trunk/utils/TableGen/LLVMCConfigurationEmitter.cpp

Modified: llvm/trunk/utils/TableGen/LLVMCConfigurationEmitter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/LLVMCConfigurationEmitter.cpp?rev=51729&r1=51728&r2=51729&view=diff

==============================================================================
--- llvm/trunk/utils/TableGen/LLVMCConfigurationEmitter.cpp (original)
+++ llvm/trunk/utils/TableGen/LLVMCConfigurationEmitter.cpp Fri May 30 01:10:47 2008
@@ -776,13 +776,22 @@
   }
 }
 
+// A helper function used by EmitOptionPropertyHandlingCode() that
+// tells us whether we should emit any code at all.
+bool ToolOptionHasInterestingProperties(const ToolOptionDescription& D) {
+  if (!D.isForward() && !D.isUnpackValues() && D.Props.empty())
+    return false;
+  return true;
+}
+
 /// EmitOptionPropertyHandlingCode - Helper function used by
 /// EmitGenerateActionMethod(). Emits code that handles option
 /// properties.
-void EmitOptionPropertyHandlingCode (const ToolProperties& P,
-                                     const ToolOptionDescription& D,
+void EmitOptionPropertyHandlingCode (const ToolOptionDescription& D,
                                      std::ostream& O)
 {
+  if (!ToolOptionHasInterestingProperties(D))
+    return;
   // Start of the if-clause.
   O << Indent2 << "if (";
   if (D.Type == OptionType::Switch)
@@ -878,7 +887,8 @@
   void operator()(const Init* Statement, const char* IndentLevel,
                   std::ostream& O) const
   {
-    EmitCmdLineVecFill(Statement, ToolName, Version, IndentLevel, O);
+    EmitCmdLineVecFill(Statement, ToolName, Version,
+                       (std::string(IndentLevel) + Indent1).c_str(), O);
   }
 };
 
@@ -910,7 +920,7 @@
   for (ToolOptionDescriptions::const_iterator B = P.OptDescs.begin(),
         E = P.OptDescs.end(); B != E; ++B) {
     const ToolOptionDescription& val = B->second;
-    EmitOptionPropertyHandlingCode(P, val, O);
+    EmitOptionPropertyHandlingCode(val, O);
   }
 
   // Handle the Sink property.





More information about the llvm-commits mailing list