]> granicus.if.org Git - clang/commitdiff
Constify Replacements parameter to applyAllReplacements.
authorDavid Blaikie <dblaikie@gmail.com>
Wed, 17 Jul 2013 18:29:58 +0000 (18:29 +0000)
committerDavid Blaikie <dblaikie@gmail.com>
Wed, 17 Jul 2013 18:29:58 +0000 (18:29 +0000)
http://llvm-reviews.chandlerc.com/D1169

Patch by Guillaume Papin.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@186526 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/Tooling/Refactoring.h
lib/Tooling/Refactoring.cpp

index d1a9e1edd081f49d98e83dafb5e6b00ca0e5f08a..0eaef95d37bdaf923dc251dd1abe2fa8046c76c2 100644 (file)
@@ -124,13 +124,13 @@ typedef std::set<Replacement, Replacement::Less> Replacements;
 /// other applications.
 ///
 /// \returns true if all replacements apply. false otherwise.
-bool applyAllReplacements(Replacements &Replaces, Rewriter &Rewrite);
+bool applyAllReplacements(const Replacements &Replaces, Rewriter &Rewrite);
 
 /// \brief Applies all replacements in \p Replaces to \p Code.
 ///
 /// This completely ignores the path stored in each replacement. If one or more
 /// replacements cannot be applied, this returns an empty \c string.
-std::string applyAllReplacements(StringRef Code, Replacements &Replaces);
+std::string applyAllReplacements(StringRef Code, const Replacements &Replaces);
 
 /// \brief Calculates how a code \p Position is shifted when \p Replaces are
 /// applied.
index 843e4bb192449bda6f43ec11101e86079949653f..a61bf9aa34c6bd54b0575da95622da493618de88 100644 (file)
@@ -123,7 +123,7 @@ void Replacement::setFromSourceRange(SourceManager &Sources,
                         getRangeSize(Sources, Range), ReplacementText);
 }
 
-bool applyAllReplacements(Replacements &Replaces, Rewriter &Rewrite) {
+bool applyAllReplacements(const Replacements &Replaces, Rewriter &Rewrite) {
   bool Result = true;
   for (Replacements::const_iterator I = Replaces.begin(),
                                     E = Replaces.end();
@@ -137,7 +137,7 @@ bool applyAllReplacements(Replacements &Replaces, Rewriter &Rewrite) {
   return Result;
 }
 
-std::string applyAllReplacements(StringRef Code, Replacements &Replaces) {
+std::string applyAllReplacements(StringRef Code, const Replacements &Replaces) {
   FileManager Files((FileSystemOptions()));
   DiagnosticsEngine Diagnostics(
       IntrusiveRefCntPtr<DiagnosticIDs>(new DiagnosticIDs),
@@ -152,8 +152,8 @@ std::string applyAllReplacements(StringRef Code, Replacements &Replaces) {
   SourceMgr.overrideFileContents(Entry, Buf);
   FileID ID =
       SourceMgr.createFileID(Entry, SourceLocation(), clang::SrcMgr::C_User);
-  for (Replacements::iterator I = Replaces.begin(), E = Replaces.end(); I != E;
-       ++I) {
+  for (Replacements::const_iterator I = Replaces.begin(), E = Replaces.end();
+       I != E; ++I) {
     Replacement Replace("<stdin>", I->getOffset(), I->getLength(),
                         I->getReplacementText());
     if (!Replace.apply(Rewrite))