Move the Wno-rewrite-macros option out of RewriteObjC.cpp in prepration
for moving ASTConsumers.h to include/clang/Frontend.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@72059 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/tools/clang-cc/ASTConsumers.h b/tools/clang-cc/ASTConsumers.h
index 73c3b83..6d4373e 100644
--- a/tools/clang-cc/ASTConsumers.h
+++ b/tools/clang-cc/ASTConsumers.h
@@ -58,7 +58,8 @@
ASTConsumer *CreateObjCRewriter(const std::string& InFile,
llvm::raw_ostream* OS,
Diagnostic &Diags,
- const LangOptions &LOpts);
+ const LangOptions &LOpts,
+ bool SilenceRewriteMacroWarning);
// LLVM code generator: uses the code generation backend to generate LLVM
// assembly. This runs optimizations depending on the CompileOptions
diff --git a/tools/clang-cc/RewriteObjC.cpp b/tools/clang-cc/RewriteObjC.cpp
index 394e6b7..493f565 100644
--- a/tools/clang-cc/RewriteObjC.cpp
+++ b/tools/clang-cc/RewriteObjC.cpp
@@ -31,10 +31,6 @@
using namespace clang;
using llvm::utostr;
-static llvm::cl::opt<bool>
-SilenceRewriteMacroWarning("Wno-rewrite-macros", llvm::cl::init(false),
- llvm::cl::desc("Silence ObjC rewriting warnings"));
-
namespace {
class RewriteObjC : public ASTConsumer {
Rewriter Rewrite;
@@ -94,7 +90,9 @@
std::string InFileName;
llvm::raw_ostream* OutFile;
-
+
+ bool SilenceRewriteMacroWarning;
+
std::string Preamble;
// Block expressions.
@@ -137,7 +135,8 @@
void HandleTopLevelSingleDecl(Decl *D);
void HandleDeclInMainFile(Decl *D);
RewriteObjC(std::string inFile, llvm::raw_ostream *OS,
- Diagnostic &D, const LangOptions &LOpts);
+ Diagnostic &D, const LangOptions &LOpts,
+ bool silenceMacroWarn);
~RewriteObjC() {}
@@ -417,8 +416,10 @@
}
RewriteObjC::RewriteObjC(std::string inFile, llvm::raw_ostream* OS,
- Diagnostic &D, const LangOptions &LOpts)
- : Diags(D), LangOpts(LOpts), InFileName(inFile), OutFile(OS) {
+ Diagnostic &D, const LangOptions &LOpts,
+ bool silenceMacroWarn)
+ : Diags(D), LangOpts(LOpts), InFileName(inFile), OutFile(OS),
+ SilenceRewriteMacroWarning(silenceMacroWarn) {
IsHeader = IsHeaderFile(inFile);
RewriteFailedDiag = Diags.getCustomDiagID(Diagnostic::Warning,
"rewriting sub-expression within a macro (may not be correct)");
@@ -430,8 +431,9 @@
ASTConsumer *clang::CreateObjCRewriter(const std::string& InFile,
llvm::raw_ostream* OS,
Diagnostic &Diags,
- const LangOptions &LOpts) {
- return new RewriteObjC(InFile, OS, Diags, LOpts);
+ const LangOptions &LOpts,
+ bool SilenceRewriteMacroWarning) {
+ return new RewriteObjC(InFile, OS, Diags, LOpts, SilenceRewriteMacroWarning);
}
void RewriteObjC::Initialize(ASTContext &context) {
diff --git a/tools/clang-cc/clang-cc.cpp b/tools/clang-cc/clang-cc.cpp
index e60ece8..fdc370e 100644
--- a/tools/clang-cc/clang-cc.cpp
+++ b/tools/clang-cc/clang-cc.cpp
@@ -1490,6 +1490,13 @@
llvm::cl::desc("Perform Fix-It modifications at the given source location"));
//===----------------------------------------------------------------------===//
+// ObjC Rewriter Options
+//===----------------------------------------------------------------------===//
+static llvm::cl::opt<bool>
+SilenceRewriteMacroWarning("Wno-rewrite-macros", llvm::cl::init(false),
+ llvm::cl::desc("Silence ObjC rewriting warnings"));
+
+//===----------------------------------------------------------------------===//
// -dump-build-information Stuff
//===----------------------------------------------------------------------===//
@@ -1692,7 +1699,8 @@
case RewriteObjC:
OS.reset(ComputeOutFile(InFile, "cpp", true, OutPath));
Consumer.reset(CreateObjCRewriter(InFile, OS.get(), PP.getDiagnostics(),
- PP.getLangOptions()));
+ PP.getLangOptions(),
+ SilenceRewriteMacroWarning));
break;
case RewriteBlocks: