- Fixing compile failure

Hi tareqsiraj, arielbernal,

http://llvm-reviews.chandlerc.com/D964

CHANGE SINCE LAST DIFF
  http://llvm-reviews.chandlerc.com/D964?vs=2379&id=2387#toc

Files:
  cpp11-migrate/AddOverride/AddOverride.cpp
  cpp11-migrate/AddOverride/AddOverride.h
  cpp11-migrate/Core/CMakeLists.txt
  cpp11-migrate/Core/FileOverrides.cpp
  cpp11-migrate/Core/FileOverrides.h
  cpp11-migrate/Core/SyntaxCheck.cpp
  cpp11-migrate/Core/SyntaxCheck.h
  cpp11-migrate/Core/Transform.cpp
  cpp11-migrate/Core/Transform.h
  cpp11-migrate/LoopConvert/LoopConvert.cpp
  cpp11-migrate/LoopConvert/LoopConvert.h
  cpp11-migrate/UseAuto/UseAuto.cpp
  cpp11-migrate/UseAuto/UseAuto.h
  cpp11-migrate/UseNullptr/UseNullptr.cpp
  cpp11-migrate/UseNullptr/UseNullptr.h
  cpp11-migrate/tool/Cpp11Migrate.cpp
  unittests/cpp11-migrate/PerfSupportTest.cpp
  unittests/cpp11-migrate/TransformTest.cpp
Index: cpp11-migrate/AddOverride/AddOverride.cpp
===================================================================
--- cpp11-migrate/AddOverride/AddOverride.cpp
+++ cpp11-migrate/AddOverride/AddOverride.cpp
@@ -29,12 +29,13 @@
 
 static llvm::cl::opt<bool> DetectMacros(
     "override-macros",
-    llvm::cl::desc("Detect and use macros that expand to the 'override' keyword."));
+    llvm::cl::desc(
+        "Detect and use macros that expand to the 'override' keyword."));
 
-int AddOverrideTransform::apply(const FileContentsByPath &InputStates,
+int AddOverrideTransform::apply(const FileOverrides &InputStates,
                                 const CompilationDatabase &Database,
                                 const std::vector<std::string> &SourcePaths,
-                                FileContentsByPath &ResultStates) {
+                                FileOverrides &ResultStates) {
   RefactoringTool AddOverrideTool(Database, SourcePaths);
 
   unsigned AcceptedChanges = 0;
Index: cpp11-migrate/AddOverride/AddOverride.h
===================================================================
--- cpp11-migrate/AddOverride/AddOverride.h
+++ cpp11-migrate/AddOverride/AddOverride.h
@@ -30,10 +30,10 @@
       : Transform("AddOverride", Options) {}
 
   /// \see Transform::run().
-  virtual int apply(const FileContentsByPath &InputStates,
+  virtual int apply(const FileOverrides &InputStates,
                     const clang::tooling::CompilationDatabase &Database,
                     const std::vector<std::string> &SourcePaths,
-                    FileContentsByPath &ResultStates) LLVM_OVERRIDE;
+                    FileOverrides &ResultStates) LLVM_OVERRIDE;
 
   virtual bool handleBeginSource(clang::CompilerInstance &CI,
                                  llvm::StringRef Filename) LLVM_OVERRIDE;
Index: cpp11-migrate/Core/CMakeLists.txt
===================================================================
--- cpp11-migrate/Core/CMakeLists.txt
+++ cpp11-migrate/Core/CMakeLists.txt
@@ -1,6 +1,8 @@
 set(LLVM_LINK_COMPONENTS support)
 
 add_clang_library(migrateCore
+  FileOverrides.cpp
+  SyntaxCheck.cpp
   Transforms.cpp
   Transform.cpp
   IncludeExcludeInfo.cpp
Index: cpp11-migrate/Core/FileOverrides.cpp
===================================================================
--- /dev/null
+++ cpp11-migrate/Core/FileOverrides.cpp
@@ -0,0 +1,10 @@
+#include "Core/FileOverrides.h"
+#include "clang/Basic/SourceManager.h"
+
+void SourceOverrides::applyOverrides(clang::SourceManager &SM,
+                                     clang::FileManager &FM) const {
+  assert(!MainFileOverride.empty() &&
+         "Main source file override should exist!");
+  SM.overrideFileContents(FM.getFile(MainFileName),
+                          llvm::MemoryBuffer::getMemBuffer(MainFileOverride));
+}
Index: cpp11-migrate/Core/FileOverrides.h
===================================================================
--- /dev/null
+++ cpp11-migrate/Core/FileOverrides.h
@@ -0,0 +1,46 @@
+//===-- Core/FileOverrides.h ------------------------------------*- C++ -*-===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+///
+/// \file
+/// \brief This file provides types and functionality for dealing with source
+/// and header file content overrides.
+///
+//===----------------------------------------------------------------------===//
+#ifndef CPP11_MIGRATE_FILE_OVERRIDES_H
+#define CPP11_MIGRATE_FILE_OVERRIDES_H
+
+#include <map>
+#include <string>
+
+// Forward Declarations
+namespace clang {
+class SourceManager;
+class FileManager;
+} // namespace clang
+
+
+/// \brief Container storing the file content overrides for a source file.
+struct SourceOverrides {
+  //SourceOverrides() {}
+
+  SourceOverrides(const char *MainFileName)
+      : MainFileName(MainFileName) {}
+
+  /// \brief Convenience function for applying this source's overrides to
+  /// the given SourceManager.
+  void applyOverrides(clang::SourceManager &SM, clang::FileManager &FM) const;
+
+  std::string MainFileName;
+  std::string MainFileOverride;
+};
+
+/// \brief Maps source file names to content override information.
+typedef std::map<std::string, SourceOverrides> FileOverrides;
+
+#endif // CPP11_MIGRATE_FILE_OVERRIDES_H
Index: cpp11-migrate/Core/SyntaxCheck.cpp
===================================================================
--- /dev/null
+++ cpp11-migrate/Core/SyntaxCheck.cpp
@@ -0,0 +1,59 @@
+#include "SyntaxCheck.h"
+#include "clang/Frontend/CompilerInstance.h"
+#include "clang/Frontend/FrontendActions.h"
+#include "clang/Tooling/Tooling.h"
+
+using namespace clang;
+using namespace tooling;
+
+class FinalSyntaxCheck : public SyntaxOnlyAction {
+public:
+  FinalSyntaxCheck(const FileOverrides &FinalState) : FinalState(FinalState) {}
+
+  virtual bool BeginSourceFileAction(CompilerInstance &CI, StringRef Filename) {
+    if (!SyntaxOnlyAction::BeginSourceFileAction(CI, Filename))
+      return false;
+
+    FileOverrides::const_iterator I = FinalState.find(Filename);
+    if (I != FinalState.end())
+      I->second.applyOverrides(CI.getSourceManager(), CI.getFileManager());
+
+    return true;
+  }
+
+private:
+  const FileOverrides &FinalState;
+};
+
+class FinalSyntaxCheckFactory : public FrontendActionFactory {
+public:
+  FinalSyntaxCheckFactory(const FileOverrides &FinalState)
+      : FinalState(FinalState) {}
+
+  virtual FrontendAction *create() { return new FinalSyntaxCheck(FinalState); }
+
+private:
+  const FileOverrides &FinalState;
+};
+
+class EndSyntaxArgumentsAdjuster : public ArgumentsAdjuster {
+  CommandLineArguments Adjust(const CommandLineArguments &Args) {
+    CommandLineArguments AdjustedArgs = Args;
+    AdjustedArgs.push_back("-fsyntax-only");
+    AdjustedArgs.push_back("-std=c++11");
+    return AdjustedArgs;
+  }
+};
+
+bool doSyntaxCheck(const CompilationDatabase &Database,
+                        const std::vector<std::string> &SourcePaths,
+                        const FileOverrides &Overrides) {
+  ClangTool EndSyntaxTool(Database, SourcePaths);
+
+  // Ensure C++11 support is enabled.
+  // FIXME: This isn't necessary anymore since the Migrator requires C++11
+  // to be enabled in the CompilationDatabase. Remove later.
+  EndSyntaxTool.setArgumentsAdjuster(new EndSyntaxArgumentsAdjuster);
+
+  return EndSyntaxTool.run(new FinalSyntaxCheckFactory(Overrides)) == 0;
+}
Index: cpp11-migrate/Core/SyntaxCheck.h
===================================================================
--- /dev/null
+++ cpp11-migrate/Core/SyntaxCheck.h
@@ -0,0 +1,35 @@
+//===-- Core/SyntaxCheck.h --------------------------------------*- C++ -*-===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+///
+/// \file
+/// \brief This file exposes functionaliy for doing a syntax-only check on
+/// files with overridden contents.
+///
+//===----------------------------------------------------------------------===//
+#ifndef CPP11_MIGRATE_SYNTAX_CHECK_H
+#define CPP11_MIGRATE_SYNTAX_CHECK_H
+
+#include <vector>
+#include "Core/FileOverrides.h"
+
+// Forward Declarations
+namespace clang {
+namespace tooling {
+class CompilationDatabase;
+} // namespace tooling
+} // namespace clang
+
+/// \brief Perform a syntax-only check over all files in \c SourcePaths using
+/// options provided by \c Database using file contents from \c Overrides if
+/// available.
+extern bool doSyntaxCheck(const clang::tooling::CompilationDatabase &Database,
+                          const std::vector<std::string> &SourcePaths,
+                          const FileOverrides &Overrides);
+
+#endif // CPP11_MIGRATE_SYNTAX_CHECK_H
Index: cpp11-migrate/Core/Transform.cpp
===================================================================
--- cpp11-migrate/Core/Transform.cpp
+++ cpp11-migrate/Core/Transform.cpp
@@ -1,7 +1,5 @@
 #include "Core/Transform.h"
 #include "clang/ASTMatchers/ASTMatchFinder.h"
-#include "clang/Basic/FileManager.h"
-#include "clang/Basic/SourceManager.h"
 #include "clang/Frontend/CompilerInstance.h"
 #include "clang/Rewrite/Core/Rewriter.h"
 #include "llvm/Support/raw_ostream.h"
@@ -22,7 +20,7 @@
 /// SourceFileCallbacks.
 class ActionFactory : public clang::tooling::FrontendActionFactory {
 public:
-  ActionFactory(MatchFinder &Finder, const FileContentsByPath &Overrides,
+  ActionFactory(MatchFinder &Finder, const FileOverrides &Overrides,
                 SourceFileCallbacks &Callbacks)
   : Finder(Finder), Overrides(Overrides), Callbacks(Callbacks) {}
 
@@ -33,7 +31,7 @@
 private:
   class FactoryAdaptor : public ASTFrontendAction {
   public:
-    FactoryAdaptor(MatchFinder &Finder, const FileContentsByPath &Overrides,
+    FactoryAdaptor(MatchFinder &Finder, const FileOverrides &Overrides,
                   SourceFileCallbacks &Callbacks)
         : Finder(Finder), Overrides(Overrides), Callbacks(Callbacks) {}
 
@@ -46,12 +44,10 @@
       if (!ASTFrontendAction::BeginSourceFileAction(CI, Filename))
         return false;
 
-      FileContentsByPath::const_iterator I = Overrides.find(Filename.str());
-      if (I != Overrides.end())
-        // If an override exists, use it.
-        CI.getSourceManager()
-            .overrideFileContents(CI.getFileManager().getFile(I->first),
-                                  llvm::MemoryBuffer::getMemBuffer(I->second));
+      FileOverrides::const_iterator I = Overrides.find(Filename.str());
+      if (I != Overrides.end()) {
+        I->second.applyOverrides(CI.getSourceManager(), CI.getFileManager());
+      }
 
       return Callbacks.handleBeginSource(CI, Filename);
     }
@@ -63,38 +59,34 @@
 
   private:
     MatchFinder &Finder;
-    const FileContentsByPath &Overrides;
+    const FileOverrides &Overrides;
     SourceFileCallbacks &Callbacks;
   };
 
   MatchFinder &Finder;
-  const FileContentsByPath &Overrides;
+  const FileOverrides &Overrides;
   SourceFileCallbacks &Callbacks;
 };
 
 } // namespace
 
 RewriterContainer::RewriterContainer(clang::FileManager &Files,
-                                     const FileContentsByPath &InputStates)
+                                     const FileOverrides &InputStates)
     : DiagOpts(new clang::DiagnosticOptions()),
       DiagnosticPrinter(llvm::errs(), DiagOpts.getPtr()),
       Diagnostics(llvm::IntrusiveRefCntPtr<clang::DiagnosticIDs>(
                       new clang::DiagnosticIDs()),
                   DiagOpts.getPtr(), &DiagnosticPrinter, false),
       Sources(Diagnostics, Files), Rewrite(Sources, DefaultLangOptions) {
-
-  // Overwrite source manager's file contents with data from InputStates
-  for (FileContentsByPath::const_iterator I = InputStates.begin(),
-                                          E = InputStates.end();
-       I != E; ++I) {
-    Sources.overrideFileContents(Files.getFile(I->first),
-                                 llvm::MemoryBuffer::getMemBuffer(I->second));
-  }
+  for (FileOverrides::const_iterator I = InputStates.begin(),
+                                       E = InputStates.end();
+       I != E; ++I)
+    I->second.applyOverrides(Sources, Files);
 }
 
 void collectResults(clang::Rewriter &Rewrite,
-                    const FileContentsByPath &InputStates,
-                    FileContentsByPath &Results) {
+                    const FileOverrides &InputStates,
+                    FileOverrides &Results) {
   // Copy the contents of InputStates to be modified.
   Results = InputStates;
 
@@ -106,6 +98,12 @@
     assert(Entry->getName() != 0 &&
            "Unexpected NULL return from FileEntry::getName()");
 
+    FileOverrides::iterator OverrideI = Results.find(Entry->getName());
+    if (OverrideI == Results.end()) {
+      OverrideI = Results.insert(FileOverrides::value_type(
+          Entry->getName(), Entry->getName())).first;
+    }
+
     std::string ResultBuf;
 
     // Get a copy of the rewritten buffer from the Rewriter.
@@ -118,7 +116,7 @@
     // FIXME: Use move semantics to avoid copies of the buffer contents if
     // benchmarking shows the copies are expensive, especially for large source
     // files.
-    Results[Entry->getName()] = ResultBuf;
+    OverrideI->second.MainFileOverride = ResultBuf;
   }
 }
 
@@ -144,6 +142,6 @@
 
 FrontendActionFactory *
 Transform::createActionFactory(MatchFinder &Finder,
-                               const FileContentsByPath &InputStates) {
+                               const FileOverrides &InputStates) {
   return new ActionFactory(Finder, InputStates, *this);
 }
Index: cpp11-migrate/Core/Transform.h
===================================================================
--- cpp11-migrate/Core/Transform.h
+++ cpp11-migrate/Core/Transform.h
@@ -17,7 +17,9 @@
 
 #include <string>
 #include <vector>
-#include "IncludeExcludeInfo.h"
+#include "Core/IncludeExcludeInfo.h"
+#include "Core/FileOverrides.h"
+#include "clang/ASTMatchers/ASTMatchFinder.h"
 #include "clang/Tooling/Tooling.h"
 #include "llvm/Support/Timer.h"
 
@@ -54,18 +56,15 @@
 } // namespace ast_matchers
 } // namespace clang
 
-/// \brief The key is the path of a file, which is mapped to a
-/// buffer with the possibly modified contents of that file.
-typedef std::map<std::string, std::string> FileContentsByPath;
 
 /// \brief In \p Results place copies of the buffers resulting from applying
 /// all rewrites represented by \p Rewrite.
 ///
 /// \p Results is made up of pairs {filename, buffer contents}. Pairs are
 /// simply appended to \p Results.
 void collectResults(clang::Rewriter &Rewrite,
-                    const FileContentsByPath &InputStates,
-                    FileContentsByPath &Results);
+                    const FileOverrides &InputStates,
+                    FileOverrides &Results);
 
 /// \brief Class for containing a Rewriter instance and all of
 /// its lifetime dependencies.
@@ -80,7 +79,7 @@
 class RewriterContainer {
 public:
   RewriterContainer(clang::FileManager &Files,
-                    const FileContentsByPath &InputStates);
+                    const FileOverrides &InputStates);
 
   clang::Rewriter &getRewriter() { return Rewrite; }
 
@@ -140,10 +139,10 @@
   /// SourcePaths and should take precedence over content of files on disk.
   /// Upon return, \p ResultStates shall contain the result of performing this
   /// transform on the files listed in \p SourcePaths.
-  virtual int apply(const FileContentsByPath &InputStates,
+  virtual int apply(const FileOverrides &InputStates,
                     const clang::tooling::CompilationDatabase &Database,
                     const std::vector<std::string> &SourcePaths,
-                    FileContentsByPath &ResultStates) = 0;
+                    FileOverrides &ResultStates) = 0;
 
   /// \brief Query if changes were made during the last call to apply().
   bool getChangesMade() const { return AcceptedChanges > 0; }
@@ -225,7 +224,7 @@
   /// for overriding source file contents with results of previous transforms.
   clang::tooling::FrontendActionFactory *
       createActionFactory(clang::ast_matchers::MatchFinder &Finder,
-                          const FileContentsByPath &InputStates);
+                          const FileOverrides &InputStates);
 
 private:
   const std::string Name;
Index: cpp11-migrate/LoopConvert/LoopConvert.cpp
===================================================================
--- cpp11-migrate/LoopConvert/LoopConvert.cpp
+++ cpp11-migrate/LoopConvert/LoopConvert.cpp
@@ -25,10 +25,10 @@
 using namespace clang::tooling;
 using namespace clang;
 
-int LoopConvertTransform::apply(const FileContentsByPath &InputStates,
+int LoopConvertTransform::apply(const FileOverrides &InputStates,
                                 const CompilationDatabase &Database,
                                 const std::vector<std::string> &SourcePaths,
-                                FileContentsByPath &ResultStates) {
+                                FileOverrides &ResultStates) {
   RefactoringTool LoopTool(Database, SourcePaths);
 
   StmtAncestorASTVisitor ParentFinder;
Index: cpp11-migrate/LoopConvert/LoopConvert.h
===================================================================
--- cpp11-migrate/LoopConvert/LoopConvert.h
+++ cpp11-migrate/LoopConvert/LoopConvert.h
@@ -27,10 +27,10 @@
       : Transform("LoopConvert", Options) {}
 
   /// \see Transform::run().
-  virtual int apply(const FileContentsByPath &InputStates,
+  virtual int apply(const FileOverrides &InputStates,
                     const clang::tooling::CompilationDatabase &Database,
                     const std::vector<std::string> &SourcePaths,
-                    FileContentsByPath &ResultStates) LLVM_OVERRIDE;
+                    FileOverrides &ResultStates) LLVM_OVERRIDE;
 };
 
 #endif // LLVM_TOOLS_CLANG_TOOLS_EXTRA_CPP11_MIGRATE_LOOP_CONVERT_H
Index: cpp11-migrate/UseAuto/UseAuto.cpp
===================================================================
--- cpp11-migrate/UseAuto/UseAuto.cpp
+++ cpp11-migrate/UseAuto/UseAuto.cpp
@@ -20,10 +20,10 @@
 using namespace clang;
 using namespace clang::tooling;
 
-int UseAutoTransform::apply(const FileContentsByPath &InputStates,
+int UseAutoTransform::apply(const FileOverrides &InputStates,
                             const clang::tooling::CompilationDatabase &Database,
                             const std::vector<std::string> &SourcePaths,
-                            FileContentsByPath &ResultStates) {
+                            FileOverrides &ResultStates) {
   RefactoringTool UseAutoTool(Database, SourcePaths);
 
   unsigned AcceptedChanges = 0;
Index: cpp11-migrate/UseAuto/UseAuto.h
===================================================================
--- cpp11-migrate/UseAuto/UseAuto.h
+++ cpp11-migrate/UseAuto/UseAuto.h
@@ -32,10 +32,10 @@
   UseAutoTransform(const TransformOptions &Options) : Transform("UseAuto", Options) {}
 
   /// \see Transform::run().
-  virtual int apply(const FileContentsByPath &InputStates,
+  virtual int apply(const FileOverrides &InputStates,
                     const clang::tooling::CompilationDatabase &Database,
                     const std::vector<std::string> &SourcePaths,
-                    FileContentsByPath &ResultStates) LLVM_OVERRIDE;
+                    FileOverrides &ResultStates) LLVM_OVERRIDE;
 };
 
 #endif // LLVM_TOOLS_CLANG_TOOLS_EXTRA_CPP11_MIGRATE_USE_AUTO_H
Index: cpp11-migrate/UseNullptr/UseNullptr.cpp
===================================================================
--- cpp11-migrate/UseNullptr/UseNullptr.cpp
+++ cpp11-migrate/UseNullptr/UseNullptr.cpp
@@ -25,10 +25,10 @@
 using namespace clang::tooling;
 using namespace clang;
 
-int UseNullptrTransform::apply(const FileContentsByPath &InputStates,
+int UseNullptrTransform::apply(const FileOverrides &InputStates,
                                const CompilationDatabase &Database,
                                const std::vector<std::string> &SourcePaths,
-                               FileContentsByPath &ResultStates) {
+                               FileOverrides &ResultStates) {
   RefactoringTool UseNullptrTool(Database, SourcePaths);
 
   unsigned AcceptedChanges = 0;
Index: cpp11-migrate/UseNullptr/UseNullptr.h
===================================================================
--- cpp11-migrate/UseNullptr/UseNullptr.h
+++ cpp11-migrate/UseNullptr/UseNullptr.h
@@ -27,10 +27,10 @@
       : Transform("UseNullptr", Options) {}
 
   /// \see Transform::run().
-  virtual int apply(const FileContentsByPath &InputStates,
+  virtual int apply(const FileOverrides &InputStates,
                     const clang::tooling::CompilationDatabase &Database,
                     const std::vector<std::string> &SourcePaths,
-                    FileContentsByPath &ResultStates) LLVM_OVERRIDE;
+                    FileOverrides &ResultStates) LLVM_OVERRIDE;
 };
 
 #endif // LLVM_TOOLS_CLANG_TOOLS_EXTRA_CPP11_MIGRATE_USE_NULLPTR_H
Index: cpp11-migrate/tool/Cpp11Migrate.cpp
===================================================================
--- cpp11-migrate/tool/Cpp11Migrate.cpp
+++ cpp11-migrate/tool/Cpp11Migrate.cpp
@@ -15,6 +15,7 @@
 ///
 //===----------------------------------------------------------------------===//
 
+#include "Core/SyntaxCheck.h"
 #include "Core/Transforms.h"
 #include "Core/Transform.h"
 #include "Core/PerfSupport.h"
@@ -88,15 +89,6 @@
     cl::location(GlobalOptions.EnableHeaderModifications),
     cl::init(false));
 
-class EndSyntaxArgumentsAdjuster : public ArgumentsAdjuster {
-  CommandLineArguments Adjust(const CommandLineArguments &Args) {
-    CommandLineArguments AdjustedArgs = Args;
-    AdjustedArgs.push_back("-fsyntax-only");
-    AdjustedArgs.push_back("-std=c++11");
-    return AdjustedArgs;
-  }
-};
-
 int main(int argc, const char **argv) {
   llvm::sys::PrintStackTraceOnErrorSignal();
   Transforms TransformManager;
@@ -138,7 +130,7 @@
     return 1;
   }
 
-  FileContentsByPath FileStates1, FileStates2,
+  FileOverrides FileStates1, FileStates2,
       *InputFileStates = &FileStates1, *OutputFileStates = &FileStates2;
 
   SourcePerfData PerfData;
@@ -173,35 +165,20 @@
     OutputFileStates->clear();
   }
 
-  // Final state of files is pointed at by InputFileStates.
-
-  if (FinalSyntaxCheck) {
-    ClangTool EndSyntaxTool(OptionsParser.getCompilations(),
-                            OptionsParser.getSourcePathList());
-
-    // Add c++11 support to clang.
-    EndSyntaxTool.setArgumentsAdjuster(new EndSyntaxArgumentsAdjuster);
-
-    for (FileContentsByPath::const_iterator I = InputFileStates->begin(),
-                                            E = InputFileStates->end();
-         I != E; ++I) {
-      EndSyntaxTool.mapVirtualFile(I->first, I->second);
-    }
-
-    if (EndSyntaxTool.run(newFrontendActionFactory<clang::SyntaxOnlyAction>())
-        != 0) {
+  if (FinalSyntaxCheck)
+    // Final state of files is pointed at by InputFileStates.
+    if (!doSyntaxCheck(OptionsParser.getCompilations(),
+                       OptionsParser.getSourcePathList(), *InputFileStates))
       return 1;
-    }
-  }
 
   // Write results to file.
-  for (FileContentsByPath::const_iterator I = InputFileStates->begin(),
-                                          E = InputFileStates->end();
+  for (FileOverrides::const_iterator I = InputFileStates->begin(),
+                                     E = InputFileStates->end();
        I != E; ++I) {
     std::string ErrorInfo;
     llvm::raw_fd_ostream FileStream(I->first.c_str(), ErrorInfo,
                                     llvm::raw_fd_ostream::F_Binary);
-    FileStream << I->second;
+    FileStream << I->second.MainFileOverride;
   }
 
   // Report execution times.
Index: unittests/cpp11-migrate/PerfSupportTest.cpp
===================================================================
--- unittests/cpp11-migrate/PerfSupportTest.cpp
+++ unittests/cpp11-migrate/PerfSupportTest.cpp
@@ -9,9 +9,9 @@
   TransformA(const TransformOptions &Options)
       : Transform("TransformA", Options) {}
 
-  virtual int apply(const FileContentsByPath &,
+  virtual int apply(const FileOverrides &,
                     const tooling::CompilationDatabase &,
-                    const std::vector<std::string> &, FileContentsByPath &) {
+                    const std::vector<std::string> &, FileOverrides &) {
     return 0;
   }
 
@@ -25,9 +25,9 @@
   TransformB(const TransformOptions &Options)
       : Transform("TransformB", Options) {}
 
-  virtual int apply(const FileContentsByPath &,
+  virtual int apply(const FileOverrides &,
                     const tooling::CompilationDatabase &,
-                    const std::vector<std::string> &, FileContentsByPath &) {
+                    const std::vector<std::string> &, FileOverrides &) {
     return 0;
   }
 
Index: unittests/cpp11-migrate/TransformTest.cpp
===================================================================
--- unittests/cpp11-migrate/TransformTest.cpp
+++ unittests/cpp11-migrate/TransformTest.cpp
@@ -13,10 +13,10 @@
   DummyTransform(llvm::StringRef Name, const TransformOptions &Options)
       : Transform(Name, Options) {}
 
-  virtual int apply(const FileContentsByPath &,
+  virtual int apply(const FileOverrides &,
                     const tooling::CompilationDatabase &,
                     const std::vector<std::string> &,
-                    FileContentsByPath &) { return 0; }
+                    FileOverrides &) { return 0; }
 
   void setAcceptedChanges(unsigned Changes) {
     Transform::setAcceptedChanges(Changes);
_______________________________________________
cfe-commits mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits

Reply via email to