From 301fe5f69b0442769ca2a6cc9f554d316e3c595d Mon Sep 17 00:00:00 2001 From: David Blaikie Date: Wed, 17 Jul 2013 18:29:58 +0000 Subject: [PATCH] Constify Replacements parameter to applyAllReplacements. http://llvm-reviews.chandlerc.com/D1169 Patch by Guillaume Papin. llvm-svn: 186526 --- clang/include/clang/Tooling/Refactoring.h | 4 ++-- clang/lib/Tooling/Refactoring.cpp | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/clang/include/clang/Tooling/Refactoring.h b/clang/include/clang/Tooling/Refactoring.h index d1a9e1e..0eaef95 100644 --- a/clang/include/clang/Tooling/Refactoring.h +++ b/clang/include/clang/Tooling/Refactoring.h @@ -124,13 +124,13 @@ typedef std::set 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. diff --git a/clang/lib/Tooling/Refactoring.cpp b/clang/lib/Tooling/Refactoring.cpp index 843e4bb..a61bf9a 100644 --- a/clang/lib/Tooling/Refactoring.cpp +++ b/clang/lib/Tooling/Refactoring.cpp @@ -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(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("", I->getOffset(), I->getLength(), I->getReplacementText()); if (!Replace.apply(Rewrite)) -- 2.7.4