[clang-tools-extra] r189832 - Rename clang-replace -> clang-apply-replacements
Edwin Vane
edwin.vane at intel.com
Tue Sep 3 10:58:20 PDT 2013
Author: revane
Date: Tue Sep 3 12:58:19 2013
New Revision: 189832
URL: http://llvm.org/viewvc/llvm-project?rev=189832&view=rev
Log:
Rename clang-replace -> clang-apply-replacements
Made changes throughout clang-tools-extra for the renaming of
clang-replace to clang-apply-replacements as per feedback from
community.
Added:
clang-tools-extra/trunk/clang-apply-replacements/
clang-tools-extra/trunk/clang-apply-replacements/CMakeLists.txt
clang-tools-extra/trunk/clang-apply-replacements/Makefile
clang-tools-extra/trunk/clang-apply-replacements/include/
clang-tools-extra/trunk/clang-apply-replacements/include/clang-apply-replacements/
clang-tools-extra/trunk/clang-apply-replacements/include/clang-apply-replacements/Tooling/
clang-tools-extra/trunk/clang-apply-replacements/include/clang-apply-replacements/Tooling/ApplyReplacements.h
clang-tools-extra/trunk/clang-apply-replacements/lib/
clang-tools-extra/trunk/clang-apply-replacements/lib/Tooling/
clang-tools-extra/trunk/clang-apply-replacements/lib/Tooling/ApplyReplacements.cpp
clang-tools-extra/trunk/clang-apply-replacements/lib/Tooling/Makefile
clang-tools-extra/trunk/clang-apply-replacements/tool/
clang-tools-extra/trunk/clang-apply-replacements/tool/CMakeLists.txt
clang-tools-extra/trunk/clang-apply-replacements/tool/ClangApplyReplacementsMain.cpp
clang-tools-extra/trunk/clang-apply-replacements/tool/Makefile
clang-tools-extra/trunk/test/clang-apply-replacements/
clang-tools-extra/trunk/test/clang-apply-replacements/Inputs/
clang-tools-extra/trunk/test/clang-apply-replacements/Inputs/basic/
clang-tools-extra/trunk/test/clang-apply-replacements/Inputs/basic/basic.h
clang-tools-extra/trunk/test/clang-apply-replacements/Inputs/basic/file1.yaml
clang-tools-extra/trunk/test/clang-apply-replacements/Inputs/basic/file2.yaml
clang-tools-extra/trunk/test/clang-apply-replacements/Inputs/conflict/
clang-tools-extra/trunk/test/clang-apply-replacements/Inputs/conflict/common.h
clang-tools-extra/trunk/test/clang-apply-replacements/Inputs/conflict/expected.txt
clang-tools-extra/trunk/test/clang-apply-replacements/Inputs/conflict/file1.yaml
clang-tools-extra/trunk/test/clang-apply-replacements/Inputs/conflict/file2.yaml
clang-tools-extra/trunk/test/clang-apply-replacements/Inputs/conflict/file3.yaml
clang-tools-extra/trunk/test/clang-apply-replacements/basic.cpp
clang-tools-extra/trunk/test/clang-apply-replacements/conflict.cpp
Removed:
clang-tools-extra/trunk/clang-replace/
clang-tools-extra/trunk/test/clang-replace/
Modified:
clang-tools-extra/trunk/CMakeLists.txt
clang-tools-extra/trunk/Makefile
clang-tools-extra/trunk/cpp11-migrate/CMakeLists.txt
clang-tools-extra/trunk/cpp11-migrate/Core/FileOverrides.h
clang-tools-extra/trunk/cpp11-migrate/Core/Makefile
clang-tools-extra/trunk/cpp11-migrate/tool/CMakeLists.txt
clang-tools-extra/trunk/cpp11-migrate/tool/Cpp11Migrate.cpp
clang-tools-extra/trunk/cpp11-migrate/tool/Makefile
clang-tools-extra/trunk/docs/Doxyfile
clang-tools-extra/trunk/test/CMakeLists.txt
clang-tools-extra/trunk/unittests/cpp11-migrate/CMakeLists.txt
clang-tools-extra/trunk/unittests/cpp11-migrate/Makefile
Modified: clang-tools-extra/trunk/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/CMakeLists.txt?rev=189832&r1=189831&r2=189832&view=diff
==============================================================================
--- clang-tools-extra/trunk/CMakeLists.txt (original)
+++ clang-tools-extra/trunk/CMakeLists.txt Tue Sep 3 12:58:19 2013
@@ -1,7 +1,7 @@
add_subdirectory(remove-cstr-calls)
add_subdirectory(tool-template)
+add_subdirectory(clang-apply-replacements)
add_subdirectory(cpp11-migrate)
-add_subdirectory(clang-replace)
add_subdirectory(modularize)
add_subdirectory(clang-tidy)
Modified: clang-tools-extra/trunk/Makefile
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/Makefile?rev=189832&r1=189831&r2=189832&view=diff
==============================================================================
--- clang-tools-extra/trunk/Makefile (original)
+++ clang-tools-extra/trunk/Makefile Tue Sep 3 12:58:19 2013
@@ -12,7 +12,7 @@ CLANG_LEVEL := ../..
include $(CLANG_LEVEL)/../../Makefile.config
PARALLEL_DIRS := remove-cstr-calls tool-template modularize
-DIRS := clang-replace cpp11-migrate clang-tidy unittests
+DIRS := clang-apply-replacements cpp11-migrate clang-tidy unittests
include $(CLANG_LEVEL)/Makefile
Added: clang-tools-extra/trunk/clang-apply-replacements/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-apply-replacements/CMakeLists.txt?rev=189832&view=auto
==============================================================================
--- clang-tools-extra/trunk/clang-apply-replacements/CMakeLists.txt (added)
+++ clang-tools-extra/trunk/clang-apply-replacements/CMakeLists.txt Tue Sep 3 12:58:19 2013
@@ -0,0 +1,22 @@
+set(LLVM_LINK_COMPONENTS
+ ${LLVM_TARGETS_TO_BUILD}
+ asmparser
+ bitreader
+ support
+ mc
+ )
+
+add_clang_library(clangApplyReplacements
+ lib/Tooling/ApplyReplacements.cpp
+ )
+target_link_libraries(clangApplyReplacements
+ clangTooling
+ clangBasic
+ clangRewriteFrontend
+ )
+
+include_directories(
+ ${CMAKE_CURRENT_SOURCE_DIR}
+ include
+ )
+add_subdirectory(tool)
Added: clang-tools-extra/trunk/clang-apply-replacements/Makefile
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-apply-replacements/Makefile?rev=189832&view=auto
==============================================================================
--- clang-tools-extra/trunk/clang-apply-replacements/Makefile (added)
+++ clang-tools-extra/trunk/clang-apply-replacements/Makefile Tue Sep 3 12:58:19 2013
@@ -0,0 +1,15 @@
+##===- clang-apply-replacements/Makefile -------------------*- Makefile -*-===##
+#
+# The LLVM Compiler Infrastructure
+#
+# This file is distributed under the University of Illinois Open Source
+# License. See LICENSE.TXT for details.
+#
+##===----------------------------------------------------------------------===##
+
+CLANG_LEVEL := ../../..
+include $(CLANG_LEVEL)/../../Makefile.config
+
+DIRS = lib/Tooling tool
+
+include $(CLANG_LEVEL)/Makefile
Added: clang-tools-extra/trunk/clang-apply-replacements/include/clang-apply-replacements/Tooling/ApplyReplacements.h
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-apply-replacements/include/clang-apply-replacements/Tooling/ApplyReplacements.h?rev=189832&view=auto
==============================================================================
--- clang-tools-extra/trunk/clang-apply-replacements/include/clang-apply-replacements/Tooling/ApplyReplacements.h (added)
+++ clang-tools-extra/trunk/clang-apply-replacements/include/clang-apply-replacements/Tooling/ApplyReplacements.h Tue Sep 3 12:58:19 2013
@@ -0,0 +1,114 @@
+//===-- ApplyReplacements.h - Deduplicate and apply replacements -- 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 the interface for deduplicating, detecting
+/// conflicts in, and applying collections of Replacements.
+///
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_CLANG_APPLYREPLACEMENTS_H
+#define LLVM_CLANG_APPLYREPLACEMENTS_H
+
+#include "clang/Tooling/Refactoring.h"
+#include "llvm/ADT/StringMap.h"
+#include "llvm/ADT/StringRef.h"
+#include "llvm/Support/system_error.h"
+#include <vector>
+#include <string>
+
+namespace clang {
+
+class DiagnosticsEngine;
+class Rewriter;
+
+namespace replace {
+
+/// \brief Collection of TranslationUnitReplacements.
+typedef std::vector<clang::tooling::TranslationUnitReplacements>
+TUReplacements;
+
+/// \brief Collection of TranslationUnitReplacement files.
+typedef std::vector<std::string> TUReplacementFiles;
+
+/// \brief Map mapping file name to Replacements targeting that file.
+typedef llvm::StringMap<std::vector<clang::tooling::Replacement> >
+FileToReplacementsMap;
+
+/// \brief Recursively descends through a directory structure rooted at \p
+/// Directory and attempts to deserialize *.yaml files as
+/// TranslationUnitReplacements. All docs that successfully deserialize are
+/// added to \p TUs.
+///
+/// Directories starting with '.' are ignored during traversal.
+///
+/// \param[in] Directory Directory to begin search for serialized
+/// TranslationUnitReplacements.
+/// \param[out] TUs Collection of all found and deserialized
+/// TranslationUnitReplacements.
+/// \param[out] TURFiles Collection of all TranslationUnitReplacement files
+/// found in \c Directory.
+/// \param[in] Diagnostics DiagnosticsEngine used for error output.
+///
+/// \returns An error_code indicating success or failure in navigating the
+/// directory structure.
+llvm::error_code
+collectReplacementsFromDirectory(const llvm::StringRef Directory,
+ TUReplacements &TUs,
+ TUReplacementFiles &TURFiles,
+ clang::DiagnosticsEngine &Diagnostics);
+
+/// \brief Deduplicate, check for conflicts, and apply all Replacements stored
+/// in \c TUs. If conflicts occur, no Replacements are applied.
+///
+/// \param[in] TUs Collection of TranslationUnitReplacements to merge,
+/// deduplicate, and test for conflicts.
+/// \param[out] GroupedReplacements Container grouping all Replacements by the
+/// file they target.
+/// \param[in] SM SourceManager required for conflict reporting.
+///
+/// \returns \li true If all changes were applied successfully.
+/// \li false If there were conflicts.
+bool mergeAndDeduplicate(const TUReplacements &TUs,
+ FileToReplacementsMap &GroupedReplacements,
+ clang::SourceManager &SM);
+
+/// \brief Apply all replacements in \c GroupedReplacements.
+///
+/// \param[in] GroupedReplacements Deduplicated and conflict free Replacements
+/// to apply.
+/// \param[out] Rewrites The results of applying replacements will be applied
+/// to this Rewriter.
+///
+/// \returns \li true If all changes were applied successfully.
+/// \li false If a replacement failed to apply.
+bool applyReplacements(const FileToReplacementsMap &GroupedReplacements,
+ clang::Rewriter &Rewrites);
+
+/// \brief Write the contents of \c FileContents to disk. Keys of the map are
+/// filenames and values are the new contents for those files.
+///
+/// \param[in] Rewrites Rewriter containing written files to write to disk.
+bool writeFiles(const clang::Rewriter &Rewrites);
+
+/// \brief Delete the replacement files.
+///
+/// \param[in] Files Replacement files to delete.
+/// \param[in] Diagnostics DiagnosticsEngine used for error output.
+///
+/// \returns \li true If all files have been deleted successfully.
+/// \li false If at least one or more failures occur when deleting
+/// files.
+bool deleteReplacementFiles(const TUReplacementFiles &Files,
+ clang::DiagnosticsEngine &Diagnostics);
+
+} // end namespace replace
+} // end namespace clang
+
+#endif // LLVM_CLANG_APPLYREPLACEMENTS_H
Added: clang-tools-extra/trunk/clang-apply-replacements/lib/Tooling/ApplyReplacements.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-apply-replacements/lib/Tooling/ApplyReplacements.cpp?rev=189832&view=auto
==============================================================================
--- clang-tools-extra/trunk/clang-apply-replacements/lib/Tooling/ApplyReplacements.cpp (added)
+++ clang-tools-extra/trunk/clang-apply-replacements/lib/Tooling/ApplyReplacements.cpp Tue Sep 3 12:58:19 2013
@@ -0,0 +1,254 @@
+//===-- ApplyReplacements.cpp - Apply and deduplicate replacements --------===//
+//
+// 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 the implementation for deduplicating, detecting
+/// conflicts in, and applying collections of Replacements.
+///
+/// FIXME: Use Diagnostics for output instead of llvm::errs().
+///
+//===----------------------------------------------------------------------===//
+#include "clang-apply-replacements/Tooling/ApplyReplacements.h"
+#include "clang/Basic/LangOptions.h"
+#include "clang/Basic/SourceManager.h"
+#include "clang/Rewrite/Core/Rewriter.h"
+#include "clang/Tooling/ReplacementsYaml.h"
+#include "llvm/ADT/ArrayRef.h"
+#include "llvm/Support/FileSystem.h"
+#include "llvm/Support/MemoryBuffer.h"
+#include "llvm/Support/Path.h"
+#include "llvm/Support/raw_ostream.h"
+
+using namespace llvm;
+using namespace clang;
+
+
+static void eatDiagnostics(const SMDiagnostic &, void *) {}
+
+namespace clang {
+namespace replace {
+
+
+llvm::error_code
+collectReplacementsFromDirectory(const llvm::StringRef Directory,
+ TUReplacements &TUs,
+ TUReplacementFiles & TURFiles,
+ clang::DiagnosticsEngine &Diagnostics) {
+ using namespace llvm::sys::fs;
+ using namespace llvm::sys::path;
+
+ error_code ErrorCode;
+
+ for (recursive_directory_iterator I(Directory, ErrorCode), E;
+ I != E && !ErrorCode; I.increment(ErrorCode)) {
+ if (filename(I->path())[0] == '.') {
+ // Indicate not to descend into directories beginning with '.'
+ I.no_push();
+ continue;
+ }
+
+ if (extension(I->path()) != ".yaml")
+ continue;
+
+ TURFiles.push_back(I->path());
+
+ OwningPtr<MemoryBuffer> Out;
+ error_code BufferError = MemoryBuffer::getFile(I->path(), Out);
+ if (BufferError) {
+ errs() << "Error reading " << I->path() << ": " << BufferError.message()
+ << "\n";
+ continue;
+ }
+
+ yaml::Input YIn(Out->getBuffer());
+ YIn.setDiagHandler(&eatDiagnostics);
+ tooling::TranslationUnitReplacements TU;
+ YIn >> TU;
+ if (YIn.error()) {
+ // File doesn't appear to be a header change description. Ignore it.
+ continue;
+ }
+
+ // Only keep files that properly parse.
+ TUs.push_back(TU);
+ }
+
+ return ErrorCode;
+}
+
+/// \brief Dumps information for a sequence of conflicting Replacements.
+///
+/// \param[in] File FileEntry for the file the conflicting Replacements are
+/// for.
+/// \param[in] ConflictingReplacements List of conflicting Replacements.
+/// \param[in] SM SourceManager used for reporting.
+static void reportConflict(
+ const FileEntry *File,
+ const llvm::ArrayRef<clang::tooling::Replacement> ConflictingReplacements,
+ SourceManager &SM) {
+ FileID FID = SM.translateFile(File);
+ if (FID.isInvalid())
+ FID = SM.createFileID(File, SourceLocation(), SrcMgr::C_User);
+
+ // FIXME: Output something a little more user-friendly (e.g. unified diff?)
+ errs() << "The following changes conflict:\n";
+ for (const tooling::Replacement *I = ConflictingReplacements.begin(),
+ *E = ConflictingReplacements.end();
+ I != E; ++I) {
+ if (I->getLength() == 0) {
+ errs() << " Insert at " << SM.getLineNumber(FID, I->getOffset()) << ":"
+ << SM.getColumnNumber(FID, I->getOffset()) << " "
+ << I->getReplacementText() << "\n";
+ } else {
+ if (I->getReplacementText().empty())
+ errs() << " Remove ";
+ else
+ errs() << " Replace ";
+
+ errs() << SM.getLineNumber(FID, I->getOffset()) << ":"
+ << SM.getColumnNumber(FID, I->getOffset()) << "-"
+ << SM.getLineNumber(FID, I->getOffset() + I->getLength() - 1)
+ << ":"
+ << SM.getColumnNumber(FID, I->getOffset() + I->getLength() - 1);
+
+ if (I->getReplacementText().empty())
+ errs() << "\n";
+ else
+ errs() << " with \"" << I->getReplacementText() << "\"\n";
+ }
+ }
+}
+
+/// \brief Deduplicates and tests for conflicts among the replacements for each
+/// file in \c Replacements. Any conflicts found are reported.
+///
+/// \param[in,out] Replacements Container of all replacements grouped by file
+/// to be deduplicated and checked for conflicts.
+/// \param[in] SM SourceManager required for conflict reporting.
+///
+/// \returns \li true if conflicts were detected
+/// \li false if no conflicts were detected
+static bool deduplicateAndDetectConflicts(FileToReplacementsMap &Replacements,
+ SourceManager &SM) {
+ bool conflictsFound = false;
+
+ for (FileToReplacementsMap::iterator I = Replacements.begin(),
+ E = Replacements.end();
+ I != E; ++I) {
+
+ const FileEntry *Entry = SM.getFileManager().getFile(I->getKey());
+ if (!Entry) {
+ errs() << "Described file '" << I->getKey()
+ << "' doesn't exist. Ignoring...\n";
+ continue;
+ }
+
+ std::vector<tooling::Range> Conflicts;
+ tooling::deduplicate(I->getValue(), Conflicts);
+
+ if (Conflicts.empty())
+ continue;
+
+ conflictsFound = true;
+
+ errs() << "There are conflicting changes to " << I->getKey() << ":\n";
+
+ for (std::vector<tooling::Range>::const_iterator
+ ConflictI = Conflicts.begin(),
+ ConflictE = Conflicts.end();
+ ConflictI != ConflictE; ++ConflictI) {
+ ArrayRef<tooling::Replacement> ConflictingReplacements(
+ &I->getValue()[ConflictI->getOffset()], ConflictI->getLength());
+ reportConflict(Entry, ConflictingReplacements, SM);
+ }
+ }
+
+ return conflictsFound;
+}
+
+bool mergeAndDeduplicate(const TUReplacements &TUs,
+ FileToReplacementsMap &GroupedReplacements,
+ clang::SourceManager &SM) {
+
+ // Group all replacements by target file.
+ for (TUReplacements::const_iterator TUI = TUs.begin(), TUE = TUs.end();
+ TUI != TUE; ++TUI)
+ for (std::vector<tooling::Replacement>::const_iterator
+ RI = TUI->Replacements.begin(),
+ RE = TUI->Replacements.end();
+ RI != RE; ++RI)
+ GroupedReplacements[RI->getFilePath()].push_back(*RI);
+
+
+ // Ask clang to deduplicate and report conflicts.
+ if (deduplicateAndDetectConflicts(GroupedReplacements, SM))
+ return false;
+
+ return true;
+}
+
+bool applyReplacements(const FileToReplacementsMap &GroupedReplacements,
+ clang::Rewriter &Rewrites) {
+
+ // Apply all changes
+ //
+ // FIXME: No longer certain GroupedReplacements is really the best kind of
+ // data structure for applying replacements. Rewriter certainly doesn't care.
+ // However, until we nail down the design of ReplacementGroups, might as well
+ // leave this as is.
+ for (FileToReplacementsMap::const_iterator I = GroupedReplacements.begin(),
+ E = GroupedReplacements.end();
+ I != E; ++I) {
+ if (!tooling::applyAllReplacements(I->getValue(), Rewrites))
+ return false;
+ }
+
+ return true;
+}
+
+bool writeFiles(const clang::Rewriter &Rewrites) {
+
+ for (Rewriter::const_buffer_iterator BufferI = Rewrites.buffer_begin(),
+ BufferE = Rewrites.buffer_end();
+ BufferI != BufferE; ++BufferI) {
+ const char *FileName =
+ Rewrites.getSourceMgr().getFileEntryForID(BufferI->first)->getName();
+
+ std::string ErrorInfo;
+
+ llvm::raw_fd_ostream FileStream(FileName, ErrorInfo);
+ if (!ErrorInfo.empty()) {
+ errs() << "Warning: Could not write to " << FileName << "\n";
+ continue;
+ }
+ BufferI->second.write(FileStream);
+ }
+
+ return true;
+}
+
+bool deleteReplacementFiles(const TUReplacementFiles &Files,
+ clang::DiagnosticsEngine &Diagnostics) {
+ bool Success = true;
+ for (TUReplacementFiles::const_iterator I = Files.begin(), E = Files.end();
+ I != E; ++I) {
+ error_code Error = llvm::sys::fs::remove(*I);
+ if (Error) {
+ Success = false;
+ // FIXME: Use Diagnostics for outputting errors.
+ errs() << "Error deleting file: " << *I << "\n";
+ errs() << Error.message() << "\n";
+ errs() << "Please delete the file manually\n";
+ }
+ }
+ return Success;
+}
+
+} // end namespace replace
+} // end namespace clang
Added: clang-tools-extra/trunk/clang-apply-replacements/lib/Tooling/Makefile
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-apply-replacements/lib/Tooling/Makefile?rev=189832&view=auto
==============================================================================
--- clang-tools-extra/trunk/clang-apply-replacements/lib/Tooling/Makefile (added)
+++ clang-tools-extra/trunk/clang-apply-replacements/lib/Tooling/Makefile Tue Sep 3 12:58:19 2013
@@ -0,0 +1,14 @@
+##===- clang-apply-replacements/lib/Tooling/Makefile -------*- Makefile -*-===##
+#
+# The LLVM Compiler Infrastructure
+#
+# This file is distributed under the University of Illinois Open Source
+# License. See LICENSE.TXT for details.
+#
+##===----------------------------------------------------------------------===##
+
+CLANG_LEVEL := ../../../../..
+LIBRARYNAME := clangApplyReplacements
+include $(CLANG_LEVEL)/../../Makefile.config
+include $(CLANG_LEVEL)/Makefile
+CPP.Flags += -I$(PROJ_SRC_DIR)/../../include
Added: clang-tools-extra/trunk/clang-apply-replacements/tool/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-apply-replacements/tool/CMakeLists.txt?rev=189832&view=auto
==============================================================================
--- clang-tools-extra/trunk/clang-apply-replacements/tool/CMakeLists.txt (added)
+++ clang-tools-extra/trunk/clang-apply-replacements/tool/CMakeLists.txt Tue Sep 3 12:58:19 2013
@@ -0,0 +1,17 @@
+set(LLVM_LINK_COMPONENTS
+ ${LLVM_TARGETS_TO_BUILD}
+ asmparser
+ bitreader
+ support
+ mc
+ )
+
+add_clang_executable(clang-apply-replacements
+ ClangApplyReplacementsMain.cpp
+ )
+target_link_libraries(clang-apply-replacements
+ clangApplyReplacements
+ )
+
+install(TARGETS clang-apply-replacements
+ RUNTIME DESTINATION bin)
Added: clang-tools-extra/trunk/clang-apply-replacements/tool/ClangApplyReplacementsMain.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-apply-replacements/tool/ClangApplyReplacementsMain.cpp?rev=189832&view=auto
==============================================================================
--- clang-tools-extra/trunk/clang-apply-replacements/tool/ClangApplyReplacementsMain.cpp (added)
+++ clang-tools-extra/trunk/clang-apply-replacements/tool/ClangApplyReplacementsMain.cpp Tue Sep 3 12:58:19 2013
@@ -0,0 +1,96 @@
+//===-- ClangApplyReplacementsMain.cpp - Main file for the tool -----------===//
+//
+// 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 the main function for the
+/// clang-apply-replacements tool.
+///
+//===----------------------------------------------------------------------===//
+
+#include "clang-apply-replacements/Tooling/ApplyReplacements.h"
+#include "clang/Basic/Diagnostic.h"
+#include "clang/Basic/DiagnosticOptions.h"
+#include "clang/Basic/SourceManager.h"
+#include "clang/Rewrite/Core/Rewriter.h"
+#include "llvm/Support/CommandLine.h"
+
+using namespace llvm;
+using namespace clang;
+using namespace clang::replace;
+
+static cl::opt<std::string> Directory(cl::Positional, cl::Required,
+ cl::desc("<Search Root Directory>"));
+
+static cl::opt<bool> RemoveTUReplacementFiles(
+ "remove-change-desc-files",
+ cl::desc("Remove the change description files regardless of successful\n"
+ "merging/replacing."),
+ cl::init(false));
+
+// Helper object to remove the TUReplacement files (triggered by
+// "remove-change-desc-files" command line option) when exiting current scope.
+class ScopedFileRemover {
+public:
+ ScopedFileRemover(const TUReplacementFiles &Files,
+ clang::DiagnosticsEngine &Diagnostics)
+ : TURFiles(Files), Diag(Diagnostics) {}
+
+ ~ScopedFileRemover() {
+ deleteReplacementFiles(TURFiles, Diag);
+ }
+
+private:
+ const TUReplacementFiles &TURFiles;
+ clang::DiagnosticsEngine &Diag;
+};
+
+int main(int argc, char **argv) {
+ cl::ParseCommandLineOptions(argc, argv);
+
+ IntrusiveRefCntPtr<DiagnosticOptions> DiagOpts(new DiagnosticOptions());
+ DiagnosticsEngine Diagnostics(
+ IntrusiveRefCntPtr<DiagnosticIDs>(new DiagnosticIDs()),
+ DiagOpts.getPtr());
+
+ TUReplacements TUs;
+ TUReplacementFiles TURFiles;
+
+ error_code ErrorCode =
+ collectReplacementsFromDirectory(Directory, TUs, TURFiles, Diagnostics);
+
+ if (ErrorCode) {
+ errs() << "Trouble iterating over directory '" << Directory
+ << "': " << ErrorCode.message() << "\n";
+ return false;
+ }
+
+ // Remove the TUReplacementFiles (triggered by "remove-change-desc-files"
+ // command line option) when exiting main().
+ OwningPtr<ScopedFileRemover> Remover;
+ if (RemoveTUReplacementFiles)
+ Remover.reset(new ScopedFileRemover(TURFiles, Diagnostics));
+
+ FileManager Files((FileSystemOptions()));
+ SourceManager SM(Diagnostics, Files);
+
+ FileToReplacementsMap GroupedReplacements;
+ if (!mergeAndDeduplicate(TUs, GroupedReplacements, SM))
+ return 1;
+
+ Rewriter DestRewriter(SM, LangOptions());
+ if (!applyReplacements(GroupedReplacements, DestRewriter)) {
+ errs() << "Failed to apply all replacements. No changes made.\n";
+ return 1;
+ }
+
+ if (!writeFiles(DestRewriter))
+ return 1;
+
+ return 0;
+}
Added: clang-tools-extra/trunk/clang-apply-replacements/tool/Makefile
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-apply-replacements/tool/Makefile?rev=189832&view=auto
==============================================================================
--- clang-tools-extra/trunk/clang-apply-replacements/tool/Makefile (added)
+++ clang-tools-extra/trunk/clang-apply-replacements/tool/Makefile Tue Sep 3 12:58:19 2013
@@ -0,0 +1,28 @@
+##===- clang-apply-replacements/tool/Makefile --------------*- Makefile -*-===##
+#
+# The LLVM Compiler Infrastructure
+#
+# This file is distributed under the University of Illinois Open Source
+# License. See LICENSE.TXT for details.
+#
+##===----------------------------------------------------------------------===##
+
+CLANG_LEVEL := ../../../..
+include $(CLANG_LEVEL)/../../Makefile.config
+
+TOOLNAME = clang-apply-replacements
+
+# No plugins, optimize startup time.
+TOOL_NO_EXPORTS = 1
+
+SOURCES = ClangApplyReplacementsMain.cpp
+
+LINK_COMPONENTS := $(TARGETS_TO_BUILD) asmparser bitreader support mc mcparser option
+USEDLIBS = clangApplyReplacements.a clangFormat.a clangTooling.a clangFrontend.a \
+ clangSerialization.a clangDriver.a clangRewriteFrontend.a \
+ clangRewriteCore.a clangParse.a clangSema.a clangAnalysis.a \
+ clangAST.a clangASTMatchers.a clangEdit.a clangLex.a clangBasic.a
+
+include $(CLANG_LEVEL)/Makefile
+
+CPP.Flags += -I$(PROJ_SRC_DIR)/../include
Modified: clang-tools-extra/trunk/cpp11-migrate/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/cpp11-migrate/CMakeLists.txt?rev=189832&r1=189831&r2=189832&view=diff
==============================================================================
--- clang-tools-extra/trunk/cpp11-migrate/CMakeLists.txt (original)
+++ clang-tools-extra/trunk/cpp11-migrate/CMakeLists.txt Tue Sep 3 12:58:19 2013
@@ -1,5 +1,5 @@
get_filename_component(ClangReplaceLocation
- "${CMAKE_CURRENT_SOURCE_DIR}/../clang-replace/include" ABSOLUTE)
+ "${CMAKE_CURRENT_SOURCE_DIR}/../clang-apply-replacements/include" ABSOLUTE)
include_directories(
${CMAKE_CURRENT_SOURCE_DIR}
Modified: clang-tools-extra/trunk/cpp11-migrate/Core/FileOverrides.h
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/cpp11-migrate/Core/FileOverrides.h?rev=189832&r1=189831&r2=189832&view=diff
==============================================================================
--- clang-tools-extra/trunk/cpp11-migrate/Core/FileOverrides.h (original)
+++ clang-tools-extra/trunk/cpp11-migrate/Core/FileOverrides.h Tue Sep 3 12:58:19 2013
@@ -17,7 +17,7 @@
#define CPP11_MIGRATE_FILE_OVERRIDES_H
#include "Core/Refactoring.h"
-#include "clang-replace/Tooling/ApplyReplacements.h"
+#include "clang-apply-replacements/Tooling/ApplyReplacements.h"
#include "clang/Tooling/ReplacementsYaml.h"
#include "llvm/ADT/StringMap.h"
Modified: clang-tools-extra/trunk/cpp11-migrate/Core/Makefile
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/cpp11-migrate/Core/Makefile?rev=189832&r1=189831&r2=189832&view=diff
==============================================================================
--- clang-tools-extra/trunk/cpp11-migrate/Core/Makefile (original)
+++ clang-tools-extra/trunk/cpp11-migrate/Core/Makefile Tue Sep 3 12:58:19 2013
@@ -11,4 +11,4 @@ LIBRARYNAME := migrateCore
include $(CLANG_LEVEL)/Makefile
-CPP.Flags += -I$(PROJ_SRC_DIR)/.. -I$(PROJ_SRC_DIR)/../../clang-replace/include
+CPP.Flags += -I$(PROJ_SRC_DIR)/.. -I$(PROJ_SRC_DIR)/../../clang-apply-replacements/include
Modified: clang-tools-extra/trunk/cpp11-migrate/tool/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/cpp11-migrate/tool/CMakeLists.txt?rev=189832&r1=189831&r2=189832&view=diff
==============================================================================
--- clang-tools-extra/trunk/cpp11-migrate/tool/CMakeLists.txt (original)
+++ clang-tools-extra/trunk/cpp11-migrate/tool/CMakeLists.txt Tue Sep 3 12:58:19 2013
@@ -34,7 +34,7 @@ add_dependencies(cpp11-migrate
)
target_link_libraries(cpp11-migrate
- clangReplace
+ clangApplyReplacements
migrateCore
)
Modified: clang-tools-extra/trunk/cpp11-migrate/tool/Cpp11Migrate.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/cpp11-migrate/tool/Cpp11Migrate.cpp?rev=189832&r1=189831&r2=189832&view=diff
==============================================================================
--- clang-tools-extra/trunk/cpp11-migrate/tool/Cpp11Migrate.cpp (original)
+++ clang-tools-extra/trunk/cpp11-migrate/tool/Cpp11Migrate.cpp Tue Sep 3 12:58:19 2013
@@ -28,7 +28,7 @@
#include "clang/Rewrite/Core/Rewriter.h"
#include "clang/Tooling/CommonOptionsParser.h"
#include "clang/Tooling/Tooling.h"
-#include "clang-replace/Tooling/ApplyReplacements.h"
+#include "clang-apply-replacements/Tooling/ApplyReplacements.h"
#include "llvm/ADT/STLExtras.h"
#include "llvm/ADT/StringSwitch.h"
#include "llvm/Support/MemoryBuffer.h"
Modified: clang-tools-extra/trunk/cpp11-migrate/tool/Makefile
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/cpp11-migrate/tool/Makefile?rev=189832&r1=189831&r2=189832&view=diff
==============================================================================
--- clang-tools-extra/trunk/cpp11-migrate/tool/Makefile (original)
+++ clang-tools-extra/trunk/cpp11-migrate/tool/Makefile Tue Sep 3 12:58:19 2013
@@ -36,14 +36,14 @@ SOURCES += $(addprefix ../ReplaceAutoPtr
BUILT_SOURCES += $(ObjDir)/../ReplaceAutoPtr/.objdir
LINK_COMPONENTS := $(TARGETS_TO_BUILD) asmparser bitreader support mc mcparser option
-USEDLIBS = migrateCore.a clangFormat.a clangReplace.a clangTooling.a clangFrontend.a \
+USEDLIBS = migrateCore.a clangFormat.a clangApplyReplacements.a clangTooling.a clangFrontend.a \
clangSerialization.a clangDriver.a clangRewriteFrontend.a \
clangRewriteCore.a clangParse.a clangSema.a clangAnalysis.a \
clangAST.a clangASTMatchers.a clangEdit.a clangLex.a clangBasic.a
include $(CLANG_LEVEL)/Makefile
-CPP.Flags += -I$(PROJ_SRC_DIR)/.. -I$(PROJ_SRC_DIR)/../../clang-replace/include
+CPP.Flags += -I$(PROJ_SRC_DIR)/.. -I$(PROJ_SRC_DIR)/../../clang-apply-replacements/include
# BUILT_SOURCES gets used as a prereq for many top-level targets. However, at
# the point those targets are defined, $(ObjDir) hasn't been defined and so the
Modified: clang-tools-extra/trunk/docs/Doxyfile
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/docs/Doxyfile?rev=189832&r1=189831&r2=189832&view=diff
==============================================================================
--- clang-tools-extra/trunk/docs/Doxyfile (original)
+++ clang-tools-extra/trunk/docs/Doxyfile Tue Sep 3 12:58:19 2013
@@ -648,7 +648,7 @@ WARN_LOGFILE =
# directories like "/usr/src/myproject". Separate the files or directories
# with spaces.
-INPUT = ../cpp11-migrate ../clang-replace
+INPUT = ../cpp11-migrate ../clang-apply-replacements
# This tag can be used to specify the character encoding of the source files
# that doxygen parses. Internally doxygen uses the UTF-8 encoding, which is
Modified: clang-tools-extra/trunk/test/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/CMakeLists.txt?rev=189832&r1=189831&r2=189832&view=diff
==============================================================================
--- clang-tools-extra/trunk/test/CMakeLists.txt (original)
+++ clang-tools-extra/trunk/test/CMakeLists.txt Tue Sep 3 12:58:19 2013
@@ -27,7 +27,7 @@ set(CLANG_TOOLS_TEST_DEPS
clang clang-headers FileCheck count not
# Individual tools we test.
- remove-cstr-calls clang-replace cpp11-migrate modularize clang-tidy
+ remove-cstr-calls clang-apply-replacements cpp11-migrate modularize clang-tidy
# Unit tests
ExtraToolsUnitTests
Added: clang-tools-extra/trunk/test/clang-apply-replacements/Inputs/basic/basic.h
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-apply-replacements/Inputs/basic/basic.h?rev=189832&view=auto
==============================================================================
--- clang-tools-extra/trunk/test/clang-apply-replacements/Inputs/basic/basic.h (added)
+++ clang-tools-extra/trunk/test/clang-apply-replacements/Inputs/basic/basic.h Tue Sep 3 12:58:19 2013
@@ -0,0 +1,32 @@
+#ifndef BASIC_H
+#define BASIC_H
+
+
+class Parent {
+public:
+ virtual void func() {}
+};
+
+class Derived : public Parent {
+public:
+ virtual void func() {}
+ // CHECK: virtual void func() override {}
+};
+
+extern void ext(int (&)[5], const Parent &);
+
+void func(int t) {
+ int ints[5];
+ for (unsigned i = 0; i < 5; ++i) {
+ int &e = ints[i];
+ e = t;
+ // CHECK: for (auto & elem : ints) {
+ // CHECK-NEXT: elem = t;
+ }
+
+ Derived d;
+
+ ext(ints, d);
+}
+
+#endif // BASIC_H
Added: clang-tools-extra/trunk/test/clang-apply-replacements/Inputs/basic/file1.yaml
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-apply-replacements/Inputs/basic/file1.yaml?rev=189832&view=auto
==============================================================================
--- clang-tools-extra/trunk/test/clang-apply-replacements/Inputs/basic/file1.yaml (added)
+++ clang-tools-extra/trunk/test/clang-apply-replacements/Inputs/basic/file1.yaml Tue Sep 3 12:58:19 2013
@@ -0,0 +1,16 @@
+---
+MainSourceFile: "source1.cpp"
+Replacements:
+ - FilePath: "$(path)/basic.h"
+ Offset: 242
+ Length: 26
+ ReplacementText: "auto & elem : ints"
+ - FilePath: "$(path)/basic.h"
+ Offset: 276
+ Length: 22
+ ReplacementText: ""
+ - FilePath: "$(path)/basic.h"
+ Offset: 298
+ Length: 1
+ ReplacementText: "elem"
+...
Added: clang-tools-extra/trunk/test/clang-apply-replacements/Inputs/basic/file2.yaml
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-apply-replacements/Inputs/basic/file2.yaml?rev=189832&view=auto
==============================================================================
--- clang-tools-extra/trunk/test/clang-apply-replacements/Inputs/basic/file2.yaml (added)
+++ clang-tools-extra/trunk/test/clang-apply-replacements/Inputs/basic/file2.yaml Tue Sep 3 12:58:19 2013
@@ -0,0 +1,8 @@
+---
+MainSourceFile: "source2.cpp"
+Replacements:
+ - FilePath: "$(path)/basic.h"
+ Offset: 148
+ Length: 0
+ ReplacementText: "override "
+...
Added: clang-tools-extra/trunk/test/clang-apply-replacements/Inputs/conflict/common.h
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-apply-replacements/Inputs/conflict/common.h?rev=189832&view=auto
==============================================================================
--- clang-tools-extra/trunk/test/clang-apply-replacements/Inputs/conflict/common.h (added)
+++ clang-tools-extra/trunk/test/clang-apply-replacements/Inputs/conflict/common.h Tue Sep 3 12:58:19 2013
@@ -0,0 +1,17 @@
+#ifndef COMMON_H
+#define COMMON_H
+
+extern void ext(int (&)[5]);
+
+void func(int t) {
+ int ints[5];
+ for (unsigned i = 0; i < 5; ++i) {
+ ints[i] = t;
+ }
+
+ int *i = 0;
+
+ ext(ints);
+}
+
+#endif // COMMON_H
Added: clang-tools-extra/trunk/test/clang-apply-replacements/Inputs/conflict/expected.txt
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-apply-replacements/Inputs/conflict/expected.txt?rev=189832&view=auto
==============================================================================
--- clang-tools-extra/trunk/test/clang-apply-replacements/Inputs/conflict/expected.txt (added)
+++ clang-tools-extra/trunk/test/clang-apply-replacements/Inputs/conflict/expected.txt Tue Sep 3 12:58:19 2013
@@ -0,0 +1,11 @@
+There are conflicting changes to $(path)/common.h:
+The following changes conflict:
+ Replace 8:8-8:33 with "auto & i : ints"
+ Replace 8:8-8:33 with "int & elem : ints"
+The following changes conflict:
+ Replace 9:5-9:11 with "elem"
+ Replace 9:5-9:11 with "i"
+The following changes conflict:
+ Remove 12:3-12:14
+ Insert at 12:12 (int*)
+ Replace 12:12-12:12 with "nullptr"
Added: clang-tools-extra/trunk/test/clang-apply-replacements/Inputs/conflict/file1.yaml
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-apply-replacements/Inputs/conflict/file1.yaml?rev=189832&view=auto
==============================================================================
--- clang-tools-extra/trunk/test/clang-apply-replacements/Inputs/conflict/file1.yaml (added)
+++ clang-tools-extra/trunk/test/clang-apply-replacements/Inputs/conflict/file1.yaml Tue Sep 3 12:58:19 2013
@@ -0,0 +1,16 @@
+---
+MainSourceFile: "source1.cpp"
+Replacements:
+ - FilePath: "$(path)/common.h"
+ Offset: 106
+ Length: 26
+ ReplacementText: "auto & i : ints"
+ - FilePath: "$(path)/common.h"
+ Offset: 140
+ Length: 7
+ ReplacementText: "i"
+ - FilePath: "$(path)/common.h"
+ Offset: 160
+ Length: 12
+ ReplacementText: ""
+...
Added: clang-tools-extra/trunk/test/clang-apply-replacements/Inputs/conflict/file2.yaml
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-apply-replacements/Inputs/conflict/file2.yaml?rev=189832&view=auto
==============================================================================
--- clang-tools-extra/trunk/test/clang-apply-replacements/Inputs/conflict/file2.yaml (added)
+++ clang-tools-extra/trunk/test/clang-apply-replacements/Inputs/conflict/file2.yaml Tue Sep 3 12:58:19 2013
@@ -0,0 +1,16 @@
+---
+MainSourceFile: "source2.cpp"
+Replacements:
+ - FilePath: "$(path)/common.h"
+ Offset: 106
+ Length: 26
+ ReplacementText: "int & elem : ints"
+ - FilePath: "$(path)/common.h"
+ Offset: 140
+ Length: 7
+ ReplacementText: "elem"
+ - FilePath: "$(path)/common.h"
+ Offset: 169
+ Length: 1
+ ReplacementText: "nullptr"
+...
Added: clang-tools-extra/trunk/test/clang-apply-replacements/Inputs/conflict/file3.yaml
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-apply-replacements/Inputs/conflict/file3.yaml?rev=189832&view=auto
==============================================================================
--- clang-tools-extra/trunk/test/clang-apply-replacements/Inputs/conflict/file3.yaml (added)
+++ clang-tools-extra/trunk/test/clang-apply-replacements/Inputs/conflict/file3.yaml Tue Sep 3 12:58:19 2013
@@ -0,0 +1,8 @@
+---
+MainSourceFile: "source1.cpp"
+Replacements:
+ - FilePath: "$(path)/common.h"
+ Offset: 169
+ Length: 0
+ ReplacementText: "(int*)"
+...
Added: clang-tools-extra/trunk/test/clang-apply-replacements/basic.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-apply-replacements/basic.cpp?rev=189832&view=auto
==============================================================================
--- clang-tools-extra/trunk/test/clang-apply-replacements/basic.cpp (added)
+++ clang-tools-extra/trunk/test/clang-apply-replacements/basic.cpp Tue Sep 3 12:58:19 2013
@@ -0,0 +1,17 @@
+// RUN: mkdir -p %T/Inputs/basic
+// RUN: grep -Ev "// *[A-Z-]+:" %S/Inputs/basic/basic.h > %T/Inputs/basic/basic.h
+// RUN: sed "s#\$(path)#%/T/Inputs/basic#" %S/Inputs/basic/file1.yaml > %T/Inputs/basic/file1.yaml
+// RUN: sed "s#\$(path)#%/T/Inputs/basic#" %S/Inputs/basic/file2.yaml > %T/Inputs/basic/file2.yaml
+// RUN: clang-apply-replacements %T/Inputs/basic
+// RUN: FileCheck -input-file=%T/Inputs/basic/basic.h %S/Inputs/basic/basic.h
+//
+// Check that the yaml files are *not* deleted after running clang-apply-replacements without remove-change-desc-files.
+// RUN: ls -1 %T/Inputs/basic | FileCheck %s --check-prefix=YAML
+//
+// Check that the yaml files *are* deleted after running clang-apply-replacements with remove-change-desc-files.
+// RUN: grep -Ev "// *[A-Z-]+:" %S/Inputs/basic/basic.h > %T/Inputs/basic/basic.h
+// RUN: clang-apply-replacements -remove-change-desc-files %T/Inputs/basic
+// RUN: ls -1 %T/Inputs/basic | FileCheck %s --check-prefix=NO_YAML
+//
+// YAML: {{^file.\.yaml$}}
+// NO_YAML-NOT: {{^file.\.yaml$}}
Added: clang-tools-extra/trunk/test/clang-apply-replacements/conflict.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-apply-replacements/conflict.cpp?rev=189832&view=auto
==============================================================================
--- clang-tools-extra/trunk/test/clang-apply-replacements/conflict.cpp (added)
+++ clang-tools-extra/trunk/test/clang-apply-replacements/conflict.cpp Tue Sep 3 12:58:19 2013
@@ -0,0 +1,17 @@
+// RUN: mkdir -p %T/Inputs/conflict
+// RUN: sed "s#\$(path)#%/S/Inputs/conflict#" %S/Inputs/conflict/file1.yaml > %T/Inputs/conflict/file1.yaml
+// RUN: sed "s#\$(path)#%/S/Inputs/conflict#" %S/Inputs/conflict/file2.yaml > %T/Inputs/conflict/file2.yaml
+// RUN: sed "s#\$(path)#%/S/Inputs/conflict#" %S/Inputs/conflict/file3.yaml > %T/Inputs/conflict/file3.yaml
+// RUN: sed "s#\$(path)#%/S/Inputs/conflict#" %S/Inputs/conflict/expected.txt > %T/Inputs/conflict/expected.txt
+// RUN: not clang-apply-replacements %T/Inputs/conflict > %T/Inputs/conflict/output.txt 2>&1
+// RUN: diff -b %T/Inputs/conflict/output.txt %T/Inputs/conflict/expected.txt
+//
+// Check that the yaml files are *not* deleted after running clang-apply-replacements without remove-change-desc-files even when there is a failure.
+// RUN: ls -1 %T/Inputs/conflict | FileCheck %s --check-prefix=YAML
+//
+// Check that the yaml files *are* deleted after running clang-apply-replacements with remove-change-desc-files even when there is a failure.
+// RUN: not clang-apply-replacements %T/Inputs/conflict -remove-change-desc-files > %T/Inputs/conflict/output.txt 2>&1
+// RUN: ls -1 %T/Inputs/conflict | FileCheck %s --check-prefix=NO_YAML
+//
+// YAML: {{^file.\.yaml$}}
+// NO_YAML-NOT: {{^file.\.yaml$}}
Modified: clang-tools-extra/trunk/unittests/cpp11-migrate/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/unittests/cpp11-migrate/CMakeLists.txt?rev=189832&r1=189831&r2=189832&view=diff
==============================================================================
--- clang-tools-extra/trunk/unittests/cpp11-migrate/CMakeLists.txt (original)
+++ clang-tools-extra/trunk/unittests/cpp11-migrate/CMakeLists.txt Tue Sep 3 12:58:19 2013
@@ -5,7 +5,7 @@ set(LLVM_LINK_COMPONENTS
get_filename_component(CPP11_MIGRATE_SOURCE_DIR
${CMAKE_CURRENT_SOURCE_DIR}/../../cpp11-migrate REALPATH)
get_filename_component(ClangReplaceLocation
- "${CMAKE_CURRENT_SOURCE_DIR}/../../clang-replace/include" REALPATH)
+ "${CMAKE_CURRENT_SOURCE_DIR}/../../clang-apply-replacements/include" REALPATH)
include_directories(
${CPP11_MIGRATE_SOURCE_DIR}
${ClangReplaceLocation}
Modified: clang-tools-extra/trunk/unittests/cpp11-migrate/Makefile
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/unittests/cpp11-migrate/Makefile?rev=189832&r1=189831&r2=189832&view=diff
==============================================================================
--- clang-tools-extra/trunk/unittests/cpp11-migrate/Makefile (original)
+++ clang-tools-extra/trunk/unittests/cpp11-migrate/Makefile Tue Sep 3 12:58:19 2013
@@ -13,7 +13,7 @@ include $(CLANG_LEVEL)/../../Makefile.co
TESTNAME = Cpp11MigrateTests
LINK_COMPONENTS := asmparser bitreader support MC MCParser option \
TransformUtils
-USEDLIBS = migrateCore.a clangFormat.a clangReplace.a clangTooling.a clangFrontend.a \
+USEDLIBS = migrateCore.a clangFormat.a clangApplyReplacements.a clangTooling.a clangFrontend.a \
clangSerialization.a clangDriver.a clangRewriteFrontend.a \
clangRewriteCore.a clangParse.a clangSema.a clangAnalysis.a \
clangAST.a clangASTMatchers.a clangEdit.a clangLex.a \
@@ -21,5 +21,5 @@ USEDLIBS = migrateCore.a clangFormat.a c
include $(CLANG_LEVEL)/Makefile
MAKEFILE_UNITTEST_NO_INCLUDE_COMMON := 1
-CPP.Flags += -I$(PROJ_SRC_DIR)/../../cpp11-migrate -I$(PROJ_SRC_DIR)/../../clang-replace/include
+CPP.Flags += -I$(PROJ_SRC_DIR)/../../cpp11-migrate -I$(PROJ_SRC_DIR)/../../clang-apply-replacements/include
include $(LLVM_SRC_ROOT)/unittests/Makefile.unittest
More information about the cfe-commits
mailing list