summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--clang/Driver/ASTConsumers.h1
-rw-r--r--clang/Driver/RewriteBlocks.cpp31
-rw-r--r--clang/Driver/clang.cpp6
3 files changed, 27 insertions, 11 deletions
diff --git a/clang/Driver/ASTConsumers.h b/clang/Driver/ASTConsumers.h
index 8375a8d6700..c1bf2300ceb 100644
--- a/clang/Driver/ASTConsumers.h
+++ b/clang/Driver/ASTConsumers.h
@@ -59,6 +59,7 @@ ASTConsumer *CreateASTSerializer(const std::string& InFile,
Diagnostic &Diags);
ASTConsumer *CreateBlockRewriter(const std::string& InFile,
+ const std::string& OutFile,
Diagnostic &Diags,
const LangOptions &LangOpts);
} // end clang namespace
diff --git a/clang/Driver/RewriteBlocks.cpp b/clang/Driver/RewriteBlocks.cpp
index 753f4ffa2ef..4f91606bfa4 100644
--- a/clang/Driver/RewriteBlocks.cpp
+++ b/clang/Driver/RewriteBlocks.cpp
@@ -55,17 +55,11 @@ class RewriteBlocks : public ASTConsumer {
ObjCMethodDecl *CurMethodDef;
bool IsHeader;
+ std::string InFileName;
+ std::string OutFileName;
public:
- RewriteBlocks(bool isHeader, Diagnostic &D, const LangOptions &LOpts) :
- Diags(D), LangOpts(LOpts) {
- IsHeader = isHeader;
- CurFunctionDef = 0;
- CurMethodDef = 0;
- RewriteFailedDiag = Diags.getCustomDiagID(Diagnostic::Warning,
- "rewriting failed");
- NoNestedBlockCalls = Diags.getCustomDiagID(Diagnostic::Warning,
- "Rewrite support for closure calls nested within closure blocks is incomplete");
- }
+ RewriteBlocks(std::string inFile, std::string outFile, Diagnostic &D,
+ const LangOptions &LOpts);
~RewriteBlocks() {
// Get the buffer corresponding to MainFileID.
// If we haven't changed it, then we are done.
@@ -155,10 +149,25 @@ static bool IsHeaderFile(const std::string &Filename) {
return Ext == "h" || Ext == "hh" || Ext == "H";
}
+RewriteBlocks::RewriteBlocks(std::string inFile, std::string outFile,
+ Diagnostic &D, const LangOptions &LOpts) :
+ Diags(D), LangOpts(LOpts) {
+ IsHeader = IsHeaderFile(inFile);
+ InFileName = inFile;
+ OutFileName = outFile;
+ CurFunctionDef = 0;
+ CurMethodDef = 0;
+ RewriteFailedDiag = Diags.getCustomDiagID(Diagnostic::Warning,
+ "rewriting failed");
+ NoNestedBlockCalls = Diags.getCustomDiagID(Diagnostic::Warning,
+ "Rewrite support for closure calls nested within closure blocks is incomplete");
+}
+
ASTConsumer *clang::CreateBlockRewriter(const std::string& InFile,
+ const std::string& OutFile,
Diagnostic &Diags,
const LangOptions &LangOpts) {
- return new RewriteBlocks(IsHeaderFile(InFile), Diags, LangOpts);
+ return new RewriteBlocks(InFile, OutFile, Diags, LangOpts);
}
void RewriteBlocks::Initialize(ASTContext &context) {
diff --git a/clang/Driver/clang.cpp b/clang/Driver/clang.cpp
index 0efe56a3507..ff98bff9dc8 100644
--- a/clang/Driver/clang.cpp
+++ b/clang/Driver/clang.cpp
@@ -61,6 +61,7 @@ Stats("print-stats",
enum ProgActions {
RewriteObjC, // ObjC->C Rewriter.
+ RewriteBlocks, // ObjC->C Rewriter for Blocks.
RewriteMacros, // Expand macros but not #includes.
HTMLTest, // HTML displayer testing stuff.
EmitLLVM, // Emit a .ll file.
@@ -116,6 +117,8 @@ ProgAction(llvm::cl::desc("Choose output type:"), llvm::cl::ZeroOrMore,
"Rewrite ObjC into C (code rewriter example)"),
clEnumValN(RewriteMacros, "rewrite-macros",
"Expand macros without full preprocessing"),
+ clEnumValN(RewriteBlocks, "rewrite-blocks",
+ "Rewrite Blocks to C"),
clEnumValEnd));
@@ -989,6 +992,9 @@ static ASTConsumer* CreateASTConsumer(const std::string& InFile,
case RewriteObjC:
return CreateCodeRewriterTest(InFile, OutputFile, Diag, LangOpts);
+
+ case RewriteBlocks:
+ return CreateBlockRewriter(InFile, OutputFile, Diag, LangOpts);
case RunAnalysis:
assert (!AnalysisList.empty());
OpenPOWER on IntegriCloud