summaryrefslogtreecommitdiffstats
path: root/unittests
diff options
context:
space:
mode:
authorZachary Turner <zturner@google.com>2017-10-11 23:33:06 +0000
committerZachary Turner <zturner@google.com>2017-10-11 23:33:06 +0000
commit29b9ec05e6c5cea54aa7dd4b7a8d586915ed55f1 (patch)
tree8e3e8cad36a31a6a80f83a90e076a62dc6dd940e /unittests
parentf8e070853ea3632dad727597ce2177fd62346d5c (diff)
[ADT] Make Twine's copy constructor private.
There's a lot of misuse of Twine scattered around LLVM. This ranges in severity from benign (returning a Twine from a function by value that is just a string literal) to pretty sketchy (storing a Twine by value in a class). While there are some uses for copying Twines, most of the very compelling ones are confined to the Twine class implementation itself, and other uses are either dubious or easily worked around. This patch makes Twine's copy constructor private, and fixes up all callsites. Differential Revision: https://reviews.llvm.org/D38767 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@315530 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'unittests')
-rw-r--r--unittests/Tooling/TestVisitor.h14
1 files changed, 7 insertions, 7 deletions
diff --git a/unittests/Tooling/TestVisitor.h b/unittests/Tooling/TestVisitor.h
index fb6a76ccad..a3a50cf0d4 100644
--- a/unittests/Tooling/TestVisitor.h
+++ b/unittests/Tooling/TestVisitor.h
@@ -128,7 +128,7 @@ public:
/// \brief Expect 'Match' *not* to occur at the given 'Line' and 'Column'.
///
/// Any number of matches can be disallowed.
- void DisallowMatch(Twine Match, unsigned Line, unsigned Column) {
+ void DisallowMatch(const Twine &Match, unsigned Line, unsigned Column) {
DisallowedMatches.push_back(MatchCandidate(Match, Line, Column));
}
@@ -138,7 +138,7 @@ public:
/// Each is expected to be matched 'Times' number of times. (This is useful in
/// cases in which different AST nodes can match at the same source code
/// location.)
- void ExpectMatch(Twine Match, unsigned Line, unsigned Column,
+ void ExpectMatch(const Twine &Match, unsigned Line, unsigned Column,
unsigned Times = 1) {
ExpectedMatches.push_back(ExpectedMatch(Match, Line, Column, Times));
}
@@ -180,10 +180,10 @@ protected:
unsigned LineNumber;
unsigned ColumnNumber;
- MatchCandidate(Twine Name, unsigned LineNumber, unsigned ColumnNumber)
- : ExpectedName(Name.str()), LineNumber(LineNumber),
- ColumnNumber(ColumnNumber) {
- }
+ MatchCandidate(const Twine &Name, unsigned LineNumber,
+ unsigned ColumnNumber)
+ : ExpectedName(Name.str()), LineNumber(LineNumber),
+ ColumnNumber(ColumnNumber) {}
bool Matches(StringRef Name, FullSourceLoc const &Location) const {
return MatchesName(Name) && MatchesLocation(Location);
@@ -211,7 +211,7 @@ protected:
};
struct ExpectedMatch {
- ExpectedMatch(Twine Name, unsigned LineNumber, unsigned ColumnNumber,
+ ExpectedMatch(const Twine &Name, unsigned LineNumber, unsigned ColumnNumber,
unsigned Times)
: Candidate(Name, LineNumber, ColumnNumber), TimesExpected(Times),
TimesSeen(0) {}