diff options
author | Chris Lattner <sabre@nondot.org> | 2009-12-09 02:08:14 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2009-12-09 02:08:14 +0000 |
commit | 53d80e2c072f74f38e410b3166527c82b65f3c4b (patch) | |
tree | c0645c4fb48b29c99f0d9f88cbb5179b15df3b03 | |
parent | 972e6d8d00e9d86e0dc11fbc0fdd3acebcf58fd6 (diff) | |
download | bcm5719-llvm-53d80e2c072f74f38e410b3166527c82b65f3c4b.tar.gz bcm5719-llvm-53d80e2c072f74f38e410b3166527c82b65f3c4b.zip |
Neil points out that this could be simplified, do it.
llvm-svn: 90927
-rw-r--r-- | clang/lib/Frontend/PrintPreprocessedOutput.cpp | 24 |
1 files changed, 9 insertions, 15 deletions
diff --git a/clang/lib/Frontend/PrintPreprocessedOutput.cpp b/clang/lib/Frontend/PrintPreprocessedOutput.cpp index c23c6e3b9a8..d9708d8bced 100644 --- a/clang/lib/Frontend/PrintPreprocessedOutput.cpp +++ b/clang/lib/Frontend/PrintPreprocessedOutput.cpp @@ -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 @@ static void PrintMacroDefinition(const IdentifierInfo &II, const MacroInfo &MI, 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()) |