[cfe-commits] r90927 - /cfe/trunk/lib/Frontend/PrintPreprocessedOutput.cpp

Chris Lattner sabre at nondot.org
Tue Dec 8 18:08:14 PST 2009


Author: lattner
Date: Tue Dec  8 20:08:14 2009
New Revision: 90927

URL: http://llvm.org/viewvc/llvm-project?rev=90927&view=rev
Log:
Neil points out that this could be simplified, do it.

Modified:
    cfe/trunk/lib/Frontend/PrintPreprocessedOutput.cpp

Modified: cfe/trunk/lib/Frontend/PrintPreprocessedOutput.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/PrintPreprocessedOutput.cpp?rev=90927&r1=90926&r2=90927&view=diff

==============================================================================
--- cfe/trunk/lib/Frontend/PrintPreprocessedOutput.cpp (original)
+++ cfe/trunk/lib/Frontend/PrintPreprocessedOutput.cpp Tue Dec  8 20:08:14 2009
@@ -28,13 +28,6 @@
 #include <cstdio>
 using namespace clang;
 
-static void PrintArgName(const IdentifierInfo *II, llvm::raw_ostream &OS) {
-  if (II->getName() == "__VA_ARGS__")
-    OS << "...";
-  else
-    OS << II->getName();
-}
-
 /// PrintMacroDefinition - Print a macro definition in a form that will be
 /// properly accepted back as a definition.
 static void PrintMacroDefinition(const IdentifierInfo &II, const MacroInfo &MI,
@@ -43,17 +36,18 @@
 
   if (MI.isFunctionLike()) {
     OS << '(';
-    if (MI.arg_empty())
-      ;
-    else if (MI.getNumArgs() == 1)
-      PrintArgName(*MI.arg_begin(), OS);
-    else {
+    if (!MI.arg_empty()) {
       MacroInfo::arg_iterator AI = MI.arg_begin(), E = MI.arg_end();
-      OS << (*AI++)->getName();
-      while (AI != E) {
+      for (; AI+1 != E; ++AI) {
+        OS << (*AI)->getName();
         OS << ',';
-        PrintArgName(*AI++, OS);
       }
+
+      // Last argument.
+      if ((*AI)->getName() == "__VA_ARGS__")
+        OS << "...";
+      else
+        OS << (*AI)->getName();
     }
 
     if (MI.isGNUVarargs())





More information about the cfe-commits mailing list