[arcmt] Introduce new '-ccc-arcmt-migrate <path>' ARC migration driver option.
This is a new mode of migration, where we avoid modifying the original files but
we emit temporary files instead.
<path> will be used to keep migration process metadata. Currently the temporary files
that are produced are put in the system's temp directory but we can put them
in the <path> if is necessary.
Also introduce new ARC migration functions in libclang whose only purpose,
currently, is to accept <path> and provide pairs of original file/transformed file
to map from the originals to the files after transformations are applied.
Finally introduce the c-arcmt-test utility that exercises the new libclang functions,
update arcmt-test, and add tests for the whole process.
rdar://9735086.
llvm-svn: 134844
diff --git a/clang/lib/ARCMigrate/FileRemapper.cpp b/clang/lib/ARCMigrate/FileRemapper.cpp
index ae5d3a3..c1dbe92 100644
--- a/clang/lib/ARCMigrate/FileRemapper.cpp
+++ b/clang/lib/ARCMigrate/FileRemapper.cpp
@@ -71,11 +71,8 @@
fin >> fromFilename >> timeModified >> toFilename;
if (fin.eof())
break;
- if (!fin.good()) {
- if (ignoreIfFilesChanged)
- return false;
+ if (!fin.good())
return report(std::string("Error in format of file: ") + infoFile, Diag);
- }
const FileEntry *origFE = FileMgr->getFile(fromFilename);
if (!origFE) {
@@ -115,8 +112,7 @@
std::string errMsg;
std::string infoFile = getRemapInfoFile(outputDir);
- llvm::raw_fd_ostream infoOut(infoFile.c_str(), errMsg,
- llvm::raw_fd_ostream::F_Binary);
+ llvm::raw_fd_ostream infoOut(infoFile.c_str(), errMsg);
if (!errMsg.empty() || infoOut.has_error())
return report(errMsg, Diag);
@@ -124,11 +120,15 @@
I = FromToMappings.begin(), E = FromToMappings.end(); I != E; ++I) {
const FileEntry *origFE = I->first;
- infoOut << origFE->getName() << '\n';
+ llvm::SmallString<200> origPath = llvm::StringRef(origFE->getName());
+ fs::make_absolute(origPath);
+ infoOut << origPath << '\n';
infoOut << (uint64_t)origFE->getModificationTime() << '\n';
if (const FileEntry *FE = I->second.dyn_cast<const FileEntry *>()) {
- infoOut << FE->getName() << '\n';
+ llvm::SmallString<200> newPath = llvm::StringRef(FE->getName());
+ fs::make_absolute(newPath);
+ infoOut << newPath << '\n';
} else {
llvm::SmallString<64> tempPath;