[cfe-commits] r72095 - in /cfe/trunk/tools/clang-cc: PrintPreprocessedOutput.cpp clang-cc.cpp clang-cc.h
Eli Friedman
eli.friedman at gmail.com
Mon May 18 20:06:48 PDT 2009
Author: efriedma
Date: Mon May 18 22:06:47 2009
New Revision: 72095
URL: http://llvm.org/viewvc/llvm-project?rev=72095&view=rev
Log:
Move options for -E mode from PrintPreprocessedOutput.cpp to
clang-cc.cpp.
Modified:
cfe/trunk/tools/clang-cc/PrintPreprocessedOutput.cpp
cfe/trunk/tools/clang-cc/clang-cc.cpp
cfe/trunk/tools/clang-cc/clang-cc.h
Modified: cfe/trunk/tools/clang-cc/PrintPreprocessedOutput.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/clang-cc/PrintPreprocessedOutput.cpp?rev=72095&r1=72094&r2=72095&view=diff
==============================================================================
--- cfe/trunk/tools/clang-cc/PrintPreprocessedOutput.cpp (original)
+++ cfe/trunk/tools/clang-cc/PrintPreprocessedOutput.cpp Mon May 18 22:06:47 2009
@@ -81,22 +81,6 @@
// Preprocessed token printer
//===----------------------------------------------------------------------===//
-static llvm::cl::opt<bool>
-DisableLineMarkers("P", llvm::cl::desc("Disable linemarker output in -E mode"));
-static llvm::cl::opt<bool>
-EnableCommentOutput("C", llvm::cl::desc("Enable comment output in -E mode"));
-static llvm::cl::opt<bool>
-EnableMacroCommentOutput("CC",
- llvm::cl::desc("Enable comment output in -E mode, "
- "even from macro expansions"));
-static llvm::cl::opt<bool>
-DumpMacros("dM", llvm::cl::desc("Print macro definitions in -E mode instead of"
- " normal output"));
-
-static llvm::cl::opt<bool>
-DumpDefines("dD", llvm::cl::desc("Print macro definitions in -E mode in "
- "addition to normal output"));
-
namespace {
class PrintPPOutputPPCallbacks : public PPCallbacks {
Preprocessor &PP;
@@ -109,9 +93,13 @@
SrcMgr::CharacteristicKind FileType;
llvm::SmallString<512> CurFilename;
bool Initialized;
+ bool DisableLineMarkers;
+ bool DumpDefines;
public:
- PrintPPOutputPPCallbacks(Preprocessor &pp, llvm::raw_ostream &os)
- : PP(pp), ConcatInfo(PP), OS(os) {
+ PrintPPOutputPPCallbacks(Preprocessor &pp, llvm::raw_ostream &os,
+ bool lineMarkers, bool defines)
+ : PP(pp), ConcatInfo(PP), OS(os), DisableLineMarkers(lineMarkers),
+ DumpDefines(defines) {
CurLine = 0;
CurFilename += "<uninit>";
EmittedTokensOnThisLine = false;
@@ -441,19 +429,19 @@
/// DoPrintPreprocessedInput - This implements -E mode.
///
-void clang::DoPrintPreprocessedInput(Preprocessor &PP, llvm::raw_ostream *OS) {
- if (DumpMacros) {
- DoPrintMacros(PP, OS);
- return;
- }
-
+void clang::DoPrintPreprocessedInput(Preprocessor &PP, llvm::raw_ostream *OS,
+ bool EnableCommentOutput,
+ bool EnableMacroCommentOutput,
+ bool DisableLineMarkers,
+ bool DumpDefines) {
// Inform the preprocessor whether we want it to retain comments or not, due
// to -C or -CC.
PP.SetCommentRetentionState(EnableCommentOutput, EnableMacroCommentOutput);
OS->SetBufferSize(64*1024);
- PrintPPOutputPPCallbacks *Callbacks = new PrintPPOutputPPCallbacks(PP, *OS);
+ PrintPPOutputPPCallbacks *Callbacks =
+ new PrintPPOutputPPCallbacks(PP, *OS, DisableLineMarkers, DumpDefines);
PP.AddPragmaHandler(0, new UnknownPragmaHandler("#pragma", Callbacks));
PP.AddPragmaHandler("GCC", new UnknownPragmaHandler("#pragma GCC",
Callbacks));
Modified: cfe/trunk/tools/clang-cc/clang-cc.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/clang-cc/clang-cc.cpp?rev=72095&r1=72094&r2=72095&view=diff
==============================================================================
--- cfe/trunk/tools/clang-cc/clang-cc.cpp (original)
+++ cfe/trunk/tools/clang-cc/clang-cc.cpp Mon May 18 22:06:47 2009
@@ -1511,6 +1511,23 @@
static llvm::cl::opt<bool> OptNoWarnings("w");
//===----------------------------------------------------------------------===//
+// Preprocessing (-E mode) Options
+//===----------------------------------------------------------------------===//
+static llvm::cl::opt<bool>
+DisableLineMarkers("P", llvm::cl::desc("Disable linemarker output in -E mode"));
+static llvm::cl::opt<bool>
+EnableCommentOutput("C", llvm::cl::desc("Enable comment output in -E mode"));
+static llvm::cl::opt<bool>
+EnableMacroCommentOutput("CC",
+ llvm::cl::desc("Enable comment output in -E mode, "
+ "even from macro expansions"));
+static llvm::cl::opt<bool>
+DumpMacros("dM", llvm::cl::desc("Print macro definitions in -E mode instead of"
+ " normal output"));
+static llvm::cl::opt<bool>
+DumpDefines("dD", llvm::cl::desc("Print macro definitions in -E mode in "
+ "addition to normal output"));
+//===----------------------------------------------------------------------===//
// -dump-build-information Stuff
//===----------------------------------------------------------------------===//
@@ -1930,7 +1947,12 @@
ClearSourceMgr = true;
} else if (PA == PrintPreprocessedInput){ // -E mode.
llvm::TimeRegion Timer(ClangFrontendTimer);
- DoPrintPreprocessedInput(PP, OS.get());
+ if (DumpMacros)
+ DoPrintMacros(PP, OS.get());
+ else
+ DoPrintPreprocessedInput(PP, OS.get(), EnableCommentOutput,
+ EnableMacroCommentOutput,
+ DisableLineMarkers, DumpDefines);
ClearSourceMgr = true;
}
Modified: cfe/trunk/tools/clang-cc/clang-cc.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/clang-cc/clang-cc.h?rev=72095&r1=72094&r2=72095&view=diff
==============================================================================
--- cfe/trunk/tools/clang-cc/clang-cc.h (original)
+++ cfe/trunk/tools/clang-cc/clang-cc.h Mon May 18 22:06:47 2009
@@ -44,7 +44,11 @@
void DoPrintMacros(Preprocessor &PP, llvm::raw_ostream* OS);
/// DoPrintPreprocessedInput - Implement -E mode.
-void DoPrintPreprocessedInput(Preprocessor &PP, llvm::raw_ostream* OS);
+void DoPrintPreprocessedInput(Preprocessor &PP, llvm::raw_ostream* OS,
+ bool EnableCommentOutput,
+ bool EnableMacroCommentOutput,
+ bool DisableLineMarkers,
+ bool DumpDefines);
/// RewriteMacrosInInput - Implement -rewrite-macros mode.
void RewriteMacrosInInput(Preprocessor &PP, llvm::raw_ostream* OS);
More information about the cfe-commits
mailing list