Moved generation of the name of the serialized AST file into
CreateASTSerializer.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@45201 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/Driver/ASTConsumers.cpp b/Driver/ASTConsumers.cpp
index 49bf59b..184f29a 100644
--- a/Driver/ASTConsumers.cpp
+++ b/Driver/ASTConsumers.cpp
@@ -637,8 +637,20 @@
 } // end anonymous namespace
 
 
-ASTConsumer *clang::CreateASTSerializer(const llvm::sys::Path& FName,
+ASTConsumer* clang::CreateASTSerializer(const std::string& InFile,
                                         Diagnostic &Diags,
                                         const LangOptions &Features) {
+    
+  // FIXME: This is a hack: "/" separator not portable.
+  std::string::size_type idx = InFile.rfind("/");
+  
+  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 new ASTSerializer(FName, Diags, Features);
 }