[cfe-commits] r45004 - in /cfe/trunk/Driver: ASTConsumers.cpp clang.cpp

Ted Kremenek kremenek at apple.com
Thu Dec 13 09:50:11 PST 2007


Author: kremenek
Date: Thu Dec 13 11:50:11 2007
New Revision: 45004

URL: http://llvm.org/viewvc/llvm-project?rev=45004&view=rev
Log:
Changed -serialize-ast to not create a temporary directory, but instead
create a .ast file in the current working directory.  This mirrors the behavior
of the -c option for gcc.  Later we should add the ability to write the
serialized file anywhere.

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

Modified: cfe/trunk/Driver/ASTConsumers.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Driver/ASTConsumers.cpp?rev=45004&r1=45003&r2=45004&view=diff

==============================================================================
--- cfe/trunk/Driver/ASTConsumers.cpp (original)
+++ cfe/trunk/Driver/ASTConsumers.cpp Thu Dec 13 11:50:11 2007
@@ -552,7 +552,6 @@
 #include "llvm/Module.h"
 #include "llvm/Target/TargetData.h"
 #include "llvm/Target/TargetMachine.h"
-#include <iostream>
 
 namespace {
   class LLVMEmitter : public ASTConsumer {
@@ -596,7 +595,7 @@
       CodeGen::Terminate(Builder);
       
       // Print the generated code.
-      M->print(std::cout);
+      M->print(llvm::cout.stream());
       delete M;
     }
   }; 

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

==============================================================================
--- cfe/trunk/Driver/clang.cpp (original)
+++ cfe/trunk/Driver/clang.cpp Thu Dec 13 11:50:11 2007
@@ -856,15 +856,16 @@
       
     case SerializeAST: {
       // FIXME: Allow user to tailor where the file is written.
-      llvm::sys::Path FName = llvm::sys::Path::GetTemporaryDirectory(NULL);
-      FName.appendComponent((InFile + ".ast").c_str());
+      // FIXME: This is a hack: "/" separator not portable.
+      std::string::size_type idx = InFile.rfind("/");
       
-      if (FName.makeUnique(true,NULL)) {
-        fprintf (stderr, "error: cannot create serialized file: '%s'\n",
-                 FName.c_str());
-        
+      if (idx != std::string::npos && idx == InFile.size()-1)
         return NULL;
-      }
+      
+      std::string TargetPrefix( idx == std::string::npos ?
+                                InFile : InFile.substr(idx+1));
+
+      llvm::sys::Path FName = llvm::sys::Path((TargetPrefix + ".ast").c_str());
       
       return CreateASTSerializer(FName, Diag, LangOpts);
     }





More information about the cfe-commits mailing list