aboutsummaryrefslogtreecommitdiff
path: root/lib/Frontend/PrintPreprocessedOutput.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2009-12-09 02:08:14 +0000
committerChris Lattner <sabre@nondot.org>2009-12-09 02:08:14 +0000
commit13d555859cd643d657000401ebc88ca404d23bba (patch)
treed4910b5b528b7e7e858f6d2bca96afb516b43860 /lib/Frontend/PrintPreprocessedOutput.cpp
parentb89192151e3bda48d7cfb41ff61842d9cd06fc82 (diff)
Neil points out that this could be simplified, do it.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@90927 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Frontend/PrintPreprocessedOutput.cpp')
-rw-r--r--lib/Frontend/PrintPreprocessedOutput.cpp24
1 files changed, 9 insertions, 15 deletions
diff --git a/lib/Frontend/PrintPreprocessedOutput.cpp b/lib/Frontend/PrintPreprocessedOutput.cpp
index c23c6e3b9a..d9708d8bce 100644
--- a/lib/Frontend/PrintPreprocessedOutput.cpp
+++ b/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())