[cfe-commits] r56305 - in /cfe/trunk/Driver: ASTConsumers.h RewriteBlocks.cpp clang.cpp

Steve Naroff snaroff at apple.com
Thu Sep 18 07:10:15 PDT 2008


Author: snaroff
Date: Thu Sep 18 09:10:13 2008
New Revision: 56305

URL: http://llvm.org/viewvc/llvm-project?rev=56305&view=rev
Log:
Add driver support for invoking block rewriter.
Also tweaked the create function to take an explicit output file.

Modified:
    cfe/trunk/Driver/ASTConsumers.h
    cfe/trunk/Driver/RewriteBlocks.cpp
    cfe/trunk/Driver/clang.cpp

Modified: cfe/trunk/Driver/ASTConsumers.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Driver/ASTConsumers.h?rev=56305&r1=56304&r2=56305&view=diff

==============================================================================
--- cfe/trunk/Driver/ASTConsumers.h (original)
+++ cfe/trunk/Driver/ASTConsumers.h Thu Sep 18 09:10:13 2008
@@ -59,6 +59,7 @@
                                  Diagnostic &Diags);
 
 ASTConsumer *CreateBlockRewriter(const std::string& InFile,
+                                 const std::string& OutFile,
                                  Diagnostic &Diags,
                                  const LangOptions &LangOpts);
 } // end clang namespace

Modified: cfe/trunk/Driver/RewriteBlocks.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Driver/RewriteBlocks.cpp?rev=56305&r1=56304&r2=56305&view=diff

==============================================================================
--- cfe/trunk/Driver/RewriteBlocks.cpp (original)
+++ cfe/trunk/Driver/RewriteBlocks.cpp Thu Sep 18 09:10:13 2008
@@ -55,17 +55,11 @@
   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 @@
   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) {

Modified: cfe/trunk/Driver/clang.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Driver/clang.cpp?rev=56305&r1=56304&r2=56305&view=diff

==============================================================================
--- cfe/trunk/Driver/clang.cpp (original)
+++ cfe/trunk/Driver/clang.cpp Thu Sep 18 09:10:13 2008
@@ -61,6 +61,7 @@
 
 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 @@
                         "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 @@
       
     case RewriteObjC:
       return CreateCodeRewriterTest(InFile, OutputFile, Diag, LangOpts);
+
+    case RewriteBlocks:
+      return CreateBlockRewriter(InFile, OutputFile, Diag, LangOpts);
       
     case RunAnalysis:
       assert (!AnalysisList.empty());





More information about the cfe-commits mailing list