r202964 - Added a const qualifier to SourceManager& parameters.
Alexander Kornienko
alexfh at google.com
Wed Mar 5 02:38:27 PST 2014
Author: alexfh
Date: Wed Mar 5 04:38:27 2014
New Revision: 202964
URL: http://llvm.org/viewvc/llvm-project?rev=202964&view=rev
Log:
Added a const qualifier to SourceManager& parameters.
Modified:
cfe/trunk/include/clang/Tooling/Refactoring.h
cfe/trunk/lib/Tooling/Refactoring.cpp
Modified: cfe/trunk/include/clang/Tooling/Refactoring.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Tooling/Refactoring.h?rev=202964&r1=202963&r2=202964&view=diff
==============================================================================
--- cfe/trunk/include/clang/Tooling/Refactoring.h (original)
+++ cfe/trunk/include/clang/Tooling/Refactoring.h Wed Mar 5 04:38:27 2014
@@ -83,16 +83,16 @@ public:
/// \brief Creates a Replacement of the range [Start, Start+Length) with
/// ReplacementText.
- Replacement(SourceManager &Sources, SourceLocation Start, unsigned Length,
+ Replacement(const SourceManager &Sources, SourceLocation Start, unsigned Length,
StringRef ReplacementText);
/// \brief Creates a Replacement of the given range with ReplacementText.
- Replacement(SourceManager &Sources, const CharSourceRange &Range,
+ Replacement(const SourceManager &Sources, const CharSourceRange &Range,
StringRef ReplacementText);
/// \brief Creates a Replacement of the node with ReplacementText.
template <typename Node>
- Replacement(SourceManager &Sources, const Node &NodeToReplace,
+ Replacement(const SourceManager &Sources, const Node &NodeToReplace,
StringRef ReplacementText);
/// \brief Returns whether this replacement can be applied to a file.
@@ -115,9 +115,10 @@ public:
std::string toString() const;
private:
- void setFromSourceLocation(SourceManager &Sources, SourceLocation Start,
+ void setFromSourceLocation(const SourceManager &Sources, SourceLocation Start,
unsigned Length, StringRef ReplacementText);
- void setFromSourceRange(SourceManager &Sources, const CharSourceRange &Range,
+ void setFromSourceRange(const SourceManager &Sources,
+ const CharSourceRange &Range,
StringRef ReplacementText);
std::string FilePath;
@@ -230,8 +231,8 @@ private:
};
template <typename Node>
-Replacement::Replacement(SourceManager &Sources, const Node &NodeToReplace,
- StringRef ReplacementText) {
+Replacement::Replacement(const SourceManager &Sources,
+ const Node &NodeToReplace, StringRef ReplacementText) {
const CharSourceRange Range =
CharSourceRange::getTokenRange(NodeToReplace->getSourceRange());
setFromSourceRange(Sources, Range, ReplacementText);
Modified: cfe/trunk/lib/Tooling/Refactoring.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Tooling/Refactoring.cpp?rev=202964&r1=202963&r2=202964&view=diff
==============================================================================
--- cfe/trunk/lib/Tooling/Refactoring.cpp (original)
+++ cfe/trunk/lib/Tooling/Refactoring.cpp Wed Mar 5 04:38:27 2014
@@ -35,12 +35,13 @@ Replacement::Replacement(StringRef FileP
: FilePath(FilePath), ReplacementRange(Offset, Length),
ReplacementText(ReplacementText) {}
-Replacement::Replacement(SourceManager &Sources, SourceLocation Start,
+Replacement::Replacement(const SourceManager &Sources, SourceLocation Start,
unsigned Length, StringRef ReplacementText) {
setFromSourceLocation(Sources, Start, Length, ReplacementText);
}
-Replacement::Replacement(SourceManager &Sources, const CharSourceRange &Range,
+Replacement::Replacement(const SourceManager &Sources,
+ const CharSourceRange &Range,
StringRef ReplacementText) {
setFromSourceRange(Sources, Range, ReplacementText);
}
@@ -99,7 +100,7 @@ bool operator==(const Replacement &LHS,
LHS.getReplacementText() == RHS.getReplacementText();
}
-void Replacement::setFromSourceLocation(SourceManager &Sources,
+void Replacement::setFromSourceLocation(const SourceManager &Sources,
SourceLocation Start, unsigned Length,
StringRef ReplacementText) {
const std::pair<FileID, unsigned> DecomposedLocation =
@@ -121,7 +122,8 @@ void Replacement::setFromSourceLocation(
// FIXME: This should go into the Lexer, but we need to figure out how
// to handle ranges for refactoring in general first - there is no obvious
// good way how to integrate this into the Lexer yet.
-static int getRangeSize(SourceManager &Sources, const CharSourceRange &Range) {
+static int getRangeSize(const SourceManager &Sources,
+ const CharSourceRange &Range) {
SourceLocation SpellingBegin = Sources.getSpellingLoc(Range.getBegin());
SourceLocation SpellingEnd = Sources.getSpellingLoc(Range.getEnd());
std::pair<FileID, unsigned> Start = Sources.getDecomposedLoc(SpellingBegin);
@@ -133,7 +135,7 @@ static int getRangeSize(SourceManager &S
return End.second - Start.second;
}
-void Replacement::setFromSourceRange(SourceManager &Sources,
+void Replacement::setFromSourceRange(const SourceManager &Sources,
const CharSourceRange &Range,
StringRef ReplacementText) {
setFromSourceLocation(Sources, Sources.getSpellingLoc(Range.getBegin()),
More information about the cfe-commits
mailing list