diff options
author | Chris Lattner <sabre@nondot.org> | 2009-12-07 01:58:34 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2009-12-07 01:58:34 +0000 |
commit | 9dfed9fdb64e8b9e81aba9c749059287a044e134 (patch) | |
tree | 3a87049f235d25b1e4f1363b22f7e748fca2fd33 /clang/lib/Frontend | |
parent | 5a6fb511c7992dd063e6a68e8421f43e131da65a (diff) | |
download | bcm5719-llvm-9dfed9fdb64e8b9e81aba9c749059287a044e134.tar.gz bcm5719-llvm-9dfed9fdb64e8b9e81aba9c749059287a044e134.zip |
fix -dM with variadic macros, PR5699
llvm-svn: 90735
Diffstat (limited to 'clang/lib/Frontend')
-rw-r--r-- | clang/lib/Frontend/PrintPreprocessedOutput.cpp | 23 |
1 files changed, 15 insertions, 8 deletions
diff --git a/clang/lib/Frontend/PrintPreprocessedOutput.cpp b/clang/lib/Frontend/PrintPreprocessedOutput.cpp index e0186abeb49..c23c6e3b9a8 100644 --- a/clang/lib/Frontend/PrintPreprocessedOutput.cpp +++ b/clang/lib/Frontend/PrintPreprocessedOutput.cpp @@ -28,6 +28,13 @@ #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, @@ -39,19 +46,19 @@ static void PrintMacroDefinition(const IdentifierInfo &II, const MacroInfo &MI, if (MI.arg_empty()) ; else if (MI.getNumArgs() == 1) - OS << (*MI.arg_begin())->getName(); + PrintArgName(*MI.arg_begin(), OS); else { MacroInfo::arg_iterator AI = MI.arg_begin(), E = MI.arg_end(); OS << (*AI++)->getName(); - while (AI != E) - OS << ',' << (*AI++)->getName(); - } - - if (MI.isVariadic()) { - if (!MI.arg_empty()) + while (AI != E) { OS << ','; - OS << "..."; + PrintArgName(*AI++, OS); + } } + + if (MI.isGNUVarargs()) + OS << "..."; // #define foo(x...) + OS << ')'; } |