Skip to content

Commit 8d50311

Browse files
committed
StringLiteral-to-StringRef
Signed-off-by: Benoit Jacob <[email protected]>
1 parent 0aa831e commit 8d50311

File tree

535 files changed

+2421
-2643
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

535 files changed

+2421
-2643
lines changed

clang-tools-extra/clang-query/QueryParser.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ template <typename T> struct QueryParser::LexOrCompleteWord {
7272
}
7373
}
7474

75-
LexOrCompleteWord &Case(llvm::StringLiteral CaseStr, const T &Value,
75+
LexOrCompleteWord &Case(llvm::StringRef CaseStr, const T &Value,
7676
bool IsCompletion = true) {
7777

7878
if (WordCompletionPos == StringRef::npos)

clang-tools-extra/clang-tidy/ClangTidyCheck.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ std::optional<int64_t> ClangTidyCheck::OptionsView::getEnumInt(
202202
return std::nullopt;
203203
}
204204

205-
static constexpr llvm::StringLiteral ConfigWarning(
205+
static constexpr llvm::StringRef ConfigWarning(
206206
"invalid configuration value '%0' for option '%1'%select{|; expected a "
207207
"bool|; expected an integer|; did you mean '%3'?}2");
208208

clang-tools-extra/clang-tidy/NoLintDirectiveHandler.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ class NoLintToken {
110110

111111
// Consume the entire buffer and return all `NoLintToken`s that were found.
112112
static SmallVector<NoLintToken> getNoLints(StringRef Buffer) {
113-
static constexpr llvm::StringLiteral NOLINT = "NOLINT";
113+
static constexpr llvm::StringRef NOLINT = "NOLINT";
114114
SmallVector<NoLintToken> NoLints;
115115

116116
size_t Pos = 0;

clang-tools-extra/clang-tidy/abseil/AbseilMatcher.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ AST_POLYMORPHIC_MATCHER(
4141
// Determine whether filepath contains "absl/[absl-library]" substring, where
4242
// [absl-library] is AbseilLibraries list entry.
4343
StringRef Path = FileEntry->getName();
44-
static constexpr llvm::StringLiteral AbslPrefix("absl/");
44+
static constexpr llvm::StringRef AbslPrefix("absl/");
4545
size_t PrefixPosition = Path.find(AbslPrefix);
4646
if (PrefixPosition == StringRef::npos)
4747
return false;

clang-tools-extra/clang-tidy/abseil/FasterStrsplitDelimiterCheck.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@ namespace clang::tidy::abseil {
1818

1919
namespace {
2020

21-
AST_MATCHER(StringLiteral, lengthIsOne) { return Node.getLength() == 1; }
21+
AST_MATCHER(StringRef, lengthIsOne) { return Node.getLength() == 1; }
2222

23-
std::optional<std::string> makeCharacterLiteral(const StringLiteral *Literal,
23+
std::optional<std::string> makeCharacterLiteral(const StringRef *Literal,
2424
const ASTContext &Context) {
2525
assert(Literal->getLength() == 1 &&
2626
"Only single character string should be matched");
@@ -29,7 +29,7 @@ std::optional<std::string> makeCharacterLiteral(const StringLiteral *Literal,
2929
std::string Result = clang::tooling::fixit::getText(*Literal, Context).str();
3030
bool IsRawStringLiteral = StringRef(Result).starts_with(R"(R")");
3131
// Since raw string literal might contain unescaped non-printable characters,
32-
// we normalize them using `StringLiteral::outputString`.
32+
// we normalize them using `StringRef::outputString`.
3333
if (IsRawStringLiteral) {
3434
Result.clear();
3535
llvm::raw_string_ostream Stream(Result);
@@ -99,7 +99,7 @@ void FasterStrsplitDelimiterCheck::registerMatchers(MatchFinder *Finder) {
9999

100100
void FasterStrsplitDelimiterCheck::check(
101101
const MatchFinder::MatchResult &Result) {
102-
const auto *Literal = Result.Nodes.getNodeAs<StringLiteral>("Literal");
102+
const auto *Literal = Result.Nodes.getNodeAs<StringRef>("Literal");
103103

104104
if (Literal->getBeginLoc().isMacroID() || Literal->getEndLoc().isMacroID())
105105
return;

clang-tools-extra/clang-tidy/android/CloexecCheck.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ std::string buildFixMsgForStringFlag(const Expr *Arg, const SourceManager &SM,
2929
" \"" + Twine(Mode) + "\"")
3030
.str();
3131

32-
StringRef SR = cast<StringLiteral>(Arg->IgnoreParenCasts())->getString();
32+
StringRef SR = cast<StringRef>(Arg->IgnoreParenCasts())->getString();
3333
return ("\"" + SR + Twine(Mode) + "\"").str();
3434
}
3535
} // namespace
@@ -84,7 +84,7 @@ void CloexecCheck::insertStringFlag(
8484
const auto *ModeArg = MatchedCall->getArg(ArgPos);
8585

8686
// Check if the <Mode> may be in the mode string.
87-
const auto *ModeStr = dyn_cast<StringLiteral>(ModeArg->IgnoreParenCasts());
87+
const auto *ModeStr = dyn_cast<StringRef>(ModeArg->IgnoreParenCasts());
8888
if (!ModeStr || ModeStr->getString().contains(Mode))
8989
return;
9090

clang-tools-extra/clang-tidy/android/CloexecFopenCheck.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ namespace clang::tidy::android {
1616
/// fopen() is suggested to include "e" in their mode string; like "re" would be
1717
/// better than "r".
1818
///
19-
/// This check only works when corresponding argument is StringLiteral. No
19+
/// This check only works when corresponding argument is StringRef. No
2020
/// constant propagation.
2121
///
2222
/// http://clang.llvm.org/extra/clang-tidy/checks/android/cloexec-fopen.html

clang-tools-extra/clang-tidy/bugprone/ArgumentCommentCheck.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,7 @@ bool ArgumentCommentCheck::shouldAddComment(const Expr *Arg) const {
254254
(CommentFloatLiterals && isa<FloatingLiteral>(Arg)) ||
255255
(CommentUserDefinedLiterals && isa<UserDefinedLiteral>(Arg)) ||
256256
(CommentCharacterLiterals && isa<CharacterLiteral>(Arg)) ||
257-
(CommentStringLiterals && isa<StringLiteral>(Arg)) ||
257+
(CommentStringLiterals && isa<StringRef>(Arg)) ||
258258
(CommentNullPtrs && isa<CXXNullPtrLiteralExpr>(Arg));
259259
}
260260

clang-tools-extra/clang-tidy/bugprone/BranchCloneCheck.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -293,8 +293,8 @@ static bool isIdenticalStmt(const ASTContext &Ctx, const Stmt *Stmt1,
293293
return FloatLit1->getValue().bitwiseIsEqual(FloatLit2->getValue());
294294
}
295295
case Stmt::StringLiteralClass: {
296-
const auto *StringLit1 = cast<StringLiteral>(Stmt1);
297-
const auto *StringLit2 = cast<StringLiteral>(Stmt2);
296+
const auto *StringLit1 = cast<StringRef>(Stmt1);
297+
const auto *StringLit2 = cast<StringRef>(Stmt2);
298298
return StringLit1->getBytes() == StringLit2->getBytes();
299299
}
300300
case Stmt::MemberExprClass: {

clang-tools-extra/clang-tidy/bugprone/EasilySwappableParametersCheck.cpp

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -24,24 +24,24 @@ namespace optutils = clang::tidy::utils::options;
2424
static constexpr std::size_t DefaultMinimumLength = 2;
2525

2626
/// The default value for ignored parameter names.
27-
static constexpr llvm::StringLiteral DefaultIgnoredParameterNames = "\"\";"
28-
"iterator;"
29-
"Iterator;"
30-
"begin;"
31-
"Begin;"
32-
"end;"
33-
"End;"
34-
"first;"
35-
"First;"
36-
"last;"
37-
"Last;"
38-
"lhs;"
39-
"LHS;"
40-
"rhs;"
41-
"RHS";
27+
static constexpr llvm::StringRef DefaultIgnoredParameterNames = "\"\";"
28+
"iterator;"
29+
"Iterator;"
30+
"begin;"
31+
"Begin;"
32+
"end;"
33+
"End;"
34+
"first;"
35+
"First;"
36+
"last;"
37+
"Last;"
38+
"lhs;"
39+
"LHS;"
40+
"rhs;"
41+
"RHS";
4242

4343
/// The default value for ignored parameter type suffixes.
44-
static constexpr llvm::StringLiteral DefaultIgnoredParameterTypeSuffixes =
44+
static constexpr llvm::StringRef DefaultIgnoredParameterTypeSuffixes =
4545
"bool;"
4646
"Bool;"
4747
"_Bool;"

0 commit comments

Comments
 (0)