[cfe-commits] r86828 - in /cfe/trunk: include/clang/Frontend/CompilerInvocation.h include/clang/Frontend/Utils.h lib/Frontend/PrintPreprocessedOutput.cpp tools/clang-cc/Options.cpp tools/clang-cc/Options.h tools/clang-cc/clang-cc.cpp
Daniel Dunbar
daniel at zuster.org
Wed Nov 11 02:07:44 PST 2009
Author: ddunbar
Date: Wed Nov 11 04:07:44 2009
New Revision: 86828
URL: http://llvm.org/viewvc/llvm-project?rev=86828&view=rev
Log:
Add PreprocessorOutputOptions to CompilerInvocation, and move initialization to
clang-cc/Options.cpp
Modified:
cfe/trunk/include/clang/Frontend/CompilerInvocation.h
cfe/trunk/include/clang/Frontend/Utils.h
cfe/trunk/lib/Frontend/PrintPreprocessedOutput.cpp
cfe/trunk/tools/clang-cc/Options.cpp
cfe/trunk/tools/clang-cc/Options.h
cfe/trunk/tools/clang-cc/clang-cc.cpp
Modified: cfe/trunk/include/clang/Frontend/CompilerInvocation.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Frontend/CompilerInvocation.h?rev=86828&r1=86827&r2=86828&view=diff
==============================================================================
--- cfe/trunk/include/clang/Frontend/CompilerInvocation.h (original)
+++ cfe/trunk/include/clang/Frontend/CompilerInvocation.h Wed Nov 11 04:07:44 2009
@@ -15,6 +15,7 @@
#include "clang/Frontend/DiagnosticOptions.h"
#include "clang/Frontend/HeaderSearchOptions.h"
#include "clang/Frontend/PreprocessorOptions.h"
+#include "clang/Frontend/PreprocessorOutputOptions.h"
#include "llvm/ADT/StringMap.h"
#include <string>
@@ -42,13 +43,13 @@
/// Options controlling the preprocessor (aside from #include handling).
PreprocessorOptions PreprocessorOpts;
+ /// Options controlling preprocessed output.
+ PreprocessorOutputOptions PreprocessorOutputOpts;
+
/// The location for the output file. This is optional only for compiler
/// invocations which have no output.
std::string OutputFile;
- /// Set of target-specific code generation features to enable/disable.
- llvm::StringMap<bool> TargetFeatures;
-
public:
CompilerInvocation() {}
@@ -58,11 +59,6 @@
std::string &getOutputFile() { return OutputFile; }
const std::string &getOutputFile() const { return OutputFile; }
- llvm::StringMap<bool> &getTargetFeatures() { return TargetFeatures; }
- const llvm::StringMap<bool> &getTargetFeatures() const {
- return TargetFeatures;
- }
-
/// @}
/// @name Option Subgroups
/// @{
@@ -88,6 +84,13 @@
return PreprocessorOpts;
}
+ PreprocessorOutputOptions &getPreprocessorOutputOpts() {
+ return PreprocessorOutputOpts;
+ }
+ const PreprocessorOutputOptions &getPreprocessorOutputOpts() const {
+ return PreprocessorOutputOpts;
+ }
+
/// @}
};
Modified: cfe/trunk/include/clang/Frontend/Utils.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Frontend/Utils.h?rev=86828&r1=86827&r2=86828&view=diff
==============================================================================
--- cfe/trunk/include/clang/Frontend/Utils.h (original)
+++ cfe/trunk/include/clang/Frontend/Utils.h Wed Nov 11 04:07:44 2009
@@ -59,7 +59,7 @@
/// DoPrintPreprocessedInput - Implement -E mode.
void DoPrintPreprocessedInput(Preprocessor &PP, llvm::raw_ostream* OS,
- PreprocessorOutputOptions &Opts);
+ const PreprocessorOutputOptions &Opts);
/// RewriteMacrosInInput - Implement -rewrite-macros mode.
void RewriteMacrosInInput(Preprocessor &PP, llvm::raw_ostream* OS);
Modified: cfe/trunk/lib/Frontend/PrintPreprocessedOutput.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/PrintPreprocessedOutput.cpp?rev=86828&r1=86827&r2=86828&view=diff
==============================================================================
--- cfe/trunk/lib/Frontend/PrintPreprocessedOutput.cpp (original)
+++ cfe/trunk/lib/Frontend/PrintPreprocessedOutput.cpp Wed Nov 11 04:07:44 2009
@@ -468,7 +468,7 @@
/// DoPrintPreprocessedInput - This implements -E mode.
///
void clang::DoPrintPreprocessedInput(Preprocessor &PP, llvm::raw_ostream *OS,
- PreprocessorOutputOptions &Opts) {
+ const PreprocessorOutputOptions &Opts) {
// Show macros with no output is handled specially.
if (!Opts.ShowCPP) {
assert(Opts.ShowMacros && "Not yet implemented!");
Modified: cfe/trunk/tools/clang-cc/Options.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/clang-cc/Options.cpp?rev=86828&r1=86827&r2=86828&view=diff
==============================================================================
--- cfe/trunk/tools/clang-cc/Options.cpp (original)
+++ cfe/trunk/tools/clang-cc/Options.cpp Wed Nov 11 04:07:44 2009
@@ -20,6 +20,7 @@
#include "clang/Frontend/HeaderSearchOptions.h"
#include "clang/Frontend/PCHReader.h"
#include "clang/Frontend/PreprocessorOptions.h"
+#include "clang/Frontend/PreprocessorOutputOptions.h"
#include "llvm/ADT/STLExtras.h"
#include "llvm/ADT/StringMap.h"
#include "llvm/Support/CommandLine.h"
@@ -527,6 +528,31 @@
}
//===----------------------------------------------------------------------===//
+// Preprocessed Output Options
+//===----------------------------------------------------------------------===//
+
+namespace preprocessoroutputoptions {
+
+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"));
+
+}
+
+//===----------------------------------------------------------------------===//
// Option Object Construction
//===----------------------------------------------------------------------===//
@@ -1010,3 +1036,15 @@
Target.setForcedLangOptions(Options);
}
+
+void
+clang::InitializePreprocessorOutputOptions(PreprocessorOutputOptions &Opts) {
+ using namespace preprocessoroutputoptions;
+
+ Opts.ShowCPP = !DumpMacros;
+ Opts.ShowMacros = DumpMacros || DumpDefines;
+ Opts.ShowLineMarkers = !DisableLineMarkers;
+ Opts.ShowComments = EnableCommentOutput;
+ Opts.ShowMacroComments = EnableMacroCommentOutput;
+}
+
Modified: cfe/trunk/tools/clang-cc/Options.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/clang-cc/Options.h?rev=86828&r1=86827&r2=86828&view=diff
==============================================================================
--- cfe/trunk/tools/clang-cc/Options.h (original)
+++ cfe/trunk/tools/clang-cc/Options.h Wed Nov 11 04:07:44 2009
@@ -20,6 +20,7 @@
class HeaderSearchOptions;
class LangOptions;
class PreprocessorOptions;
+class PreprocessorOutputOptions;
class TargetInfo;
enum LangKind {
@@ -55,6 +56,8 @@
void InitializePreprocessorOptions(PreprocessorOptions &Opts);
+void InitializePreprocessorOutputOptions(PreprocessorOutputOptions &Opts);
+
} // end namespace clang
#endif
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=86828&r1=86827&r2=86828&view=diff
==============================================================================
--- cfe/trunk/tools/clang-cc/clang-cc.cpp (original)
+++ cfe/trunk/tools/clang-cc/clang-cc.cpp Wed Nov 11 04:07:44 2009
@@ -455,26 +455,9 @@
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"));
-
-//===----------------------------------------------------------------------===//
// Dependency file options
//===----------------------------------------------------------------------===//
+
static llvm::cl::opt<std::string>
DependencyFile("dependency-file",
llvm::cl::desc("Filename (or -) to write dependency output to"));
@@ -920,13 +903,8 @@
case PrintPreprocessedInput: {
llvm::TimeRegion Timer(ClangFrontendTimer);
- PreprocessorOutputOptions Opts;
- Opts.ShowCPP = !DumpMacros;
- Opts.ShowMacros = DumpMacros || DumpDefines;
- Opts.ShowLineMarkers = !DisableLineMarkers;
- Opts.ShowComments = EnableCommentOutput;
- Opts.ShowMacroComments = EnableMacroCommentOutput;
- DoPrintPreprocessedInput(PP, OS.get(), Opts);
+ DoPrintPreprocessedInput(PP, OS.get(),
+ CompOpts.getPreprocessorOutputOpts());
ClearSourceMgr = true;
}
@@ -1123,6 +1101,9 @@
// Initialize the other preprocessor options.
InitializePreprocessorOptions(Opts.getPreprocessorOpts());
+ // Initialize the preprocessed output options.
+ InitializePreprocessorOutputOptions(Opts.getPreprocessorOutputOpts());
+
// Finalize some code generation options.
FinalizeCompileOptions(Opts.getCompileOpts(), Opts.getLangOpts());
}
More information about the cfe-commits
mailing list