summaryrefslogtreecommitdiffstats
path: root/clang/Driver
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2006-07-29 06:30:25 +0000
committerChris Lattner <sabre@nondot.org>2006-07-29 06:30:25 +0000
commit457fc15bc5beb48fb3041a7525b6731edf720cc8 (patch)
tree878e141457ea9f7f4b03d3f6d3c8a707dfaa6cd1 /clang/Driver
parent2be41154652c162e5ab5db6ea41a651c4dc3263f (diff)
downloadbcm5719-llvm-457fc15bc5beb48fb3041a7525b6731edf720cc8.tar.gz
bcm5719-llvm-457fc15bc5beb48fb3041a7525b6731edf720cc8.zip
Implement comment saving mode: the -C and -CC options.
llvm-svn: 38783
Diffstat (limited to 'clang/Driver')
-rw-r--r--clang/Driver/PrintPreprocessedOutput.cpp12
-rw-r--r--clang/Driver/clang.cpp2
-rw-r--r--clang/Driver/clang.h5
3 files changed, 15 insertions, 4 deletions
diff --git a/clang/Driver/PrintPreprocessedOutput.cpp b/clang/Driver/PrintPreprocessedOutput.cpp
index dff4411ef2a..e1fb1aa42a7 100644
--- a/clang/Driver/PrintPreprocessedOutput.cpp
+++ b/clang/Driver/PrintPreprocessedOutput.cpp
@@ -99,6 +99,11 @@ static void OutputString(const char *Ptr, unsigned Size) {
static cl::opt<bool>
DisableLineMarkers("P", cl::desc("Disable linemarker output in -E mode"));
+static cl::opt<bool>
+EnableCommentOutput("C", cl::desc("Enable comment output in -E mode"));
+static cl::opt<bool>
+EnableMacroCommentOutput("CC", cl::desc("Enable comment output in -E mode, "
+ "even from macro expansions"));
static unsigned EModeCurLine;
static std::string EModeCurFilename;
@@ -357,7 +362,12 @@ static bool AvoidConcat(const LexerToken &PrevTok, const LexerToken &Tok,
/// DoPrintPreprocessedInput - This implements -E mode.
///
-void clang::DoPrintPreprocessedInput(Preprocessor &PP) {
+void clang::DoPrintPreprocessedInput(Preprocessor &PP, LangOptions &Options) {
+ if (EnableCommentOutput) // -C specified?
+ Options.KeepComments = 1;
+ if (EnableMacroCommentOutput) // -CC specified?
+ Options.KeepComments = Options.KeepMacroComments = 1;
+
InitOutputBuffer();
LexerToken Tok, PrevTok;
diff --git a/clang/Driver/clang.cpp b/clang/Driver/clang.cpp
index 8dfbe59f50d..f2464992b3f 100644
--- a/clang/Driver/clang.cpp
+++ b/clang/Driver/clang.cpp
@@ -703,7 +703,7 @@ int main(int argc, char **argv) {
}
case PrintPreprocessedInput: // -E mode.
- DoPrintPreprocessedInput(PP);
+ DoPrintPreprocessedInput(PP, Options);
break;
case DumpTokens: { // Token dump mode.
diff --git a/clang/Driver/clang.h b/clang/Driver/clang.h
index 98cdb7f3692..3050d6aff14 100644
--- a/clang/Driver/clang.h
+++ b/clang/Driver/clang.h
@@ -16,10 +16,11 @@
namespace llvm {
namespace clang {
-class Preprocessor;
+class Preprocessor;
+class LangOptions;
/// DoPrintPreprocessedInput - Implement -E mode.
-void DoPrintPreprocessedInput(Preprocessor &PP);
+void DoPrintPreprocessedInput(Preprocessor &PP, LangOptions &Options);
} // end namespace clang
} // end namespace llvm
OpenPOWER on IntegriCloud