Skip to content

Commit 5da28bd

Browse files
authored
[clang-tidy][NFC] Make a few std::strings into StringRefs (#160961)
Following up 12cb540. Also, that commit left behind a few cases where a temporary `StringRef` was being constructed from those variables just to use its `.split()` function, so this PR cleans those up too.
1 parent 0f70b44 commit 5da28bd

9 files changed

+12
-12
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ ComparisonInTempFailureRetryCheck::ComparisonInTempFailureRetryCheck(
1919
StringRef Name, ClangTidyContext *Context)
2020
: ClangTidyCheck(Name, Context),
2121
RawRetryList(Options.get("RetryMacros", "TEMP_FAILURE_RETRY")) {
22-
StringRef(RawRetryList).split(RetryMacros, ",", -1, false);
22+
RawRetryList.split(RetryMacros, ",", -1, false);
2323
}
2424

2525
void ComparisonInTempFailureRetryCheck::storeOptions(

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ AssertSideEffectCheck::AssertSideEffectCheck(StringRef Name,
9292
RawAssertList(Options.get("AssertMacros", "assert,NSAssert,NSCAssert")),
9393
IgnoredFunctions(utils::options::parseListPair(
9494
"__builtin_expect;", Options.get("IgnoredFunctions", ""))) {
95-
StringRef(RawAssertList).split(AssertMacros, ",", -1, false);
95+
RawAssertList.split(AssertMacros, ",", -1, false);
9696
}
9797

9898
// The options are explained in AssertSideEffectCheck.h.

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,12 +39,12 @@ ExceptionEscapeCheck::ExceptionEscapeCheck(StringRef Name,
3939
RawIgnoredExceptions(Options.get("IgnoredExceptions", "")) {
4040
llvm::SmallVector<StringRef, 8> FunctionsThatShouldNotThrowVec,
4141
IgnoredExceptionsVec;
42-
StringRef(RawFunctionsThatShouldNotThrow)
43-
.split(FunctionsThatShouldNotThrowVec, ",", -1, false);
42+
RawFunctionsThatShouldNotThrow.split(FunctionsThatShouldNotThrowVec, ",", -1,
43+
false);
4444
FunctionsThatShouldNotThrow.insert_range(FunctionsThatShouldNotThrowVec);
4545

4646
llvm::StringSet<> IgnoredExceptions;
47-
StringRef(RawIgnoredExceptions).split(IgnoredExceptionsVec, ",", -1, false);
47+
RawIgnoredExceptions.split(IgnoredExceptionsVec, ",", -1, false);
4848
IgnoredExceptions.insert_range(IgnoredExceptionsVec);
4949
Tracer.ignoreExceptions(std::move(IgnoredExceptions));
5050
Tracer.ignoreBadAlloc(true);

clang-tools-extra/clang-tidy/bugprone/ExceptionEscapeCheck.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@ class ExceptionEscapeCheck : public ClangTidyCheck {
3333
void check(const ast_matchers::MatchFinder::MatchResult &Result) override;
3434

3535
private:
36-
std::string RawFunctionsThatShouldNotThrow;
37-
std::string RawIgnoredExceptions;
36+
StringRef RawFunctionsThatShouldNotThrow;
37+
StringRef RawIgnoredExceptions;
3838

3939
llvm::StringSet<> FunctionsThatShouldNotThrow;
4040
utils::ExceptionAnalyzer Tracer;

clang-tools-extra/clang-tidy/cert/ProperlySeededRandomGeneratorCheck.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ ProperlySeededRandomGeneratorCheck::ProperlySeededRandomGeneratorCheck(
2020
: ClangTidyCheck(Name, Context),
2121
RawDisallowedSeedTypes(
2222
Options.get("DisallowedSeedTypes", "time_t,std::time_t")) {
23-
StringRef(RawDisallowedSeedTypes).split(DisallowedSeedTypes, ',');
23+
RawDisallowedSeedTypes.split(DisallowedSeedTypes, ',');
2424
}
2525

2626
void ProperlySeededRandomGeneratorCheck::storeOptions(

clang-tools-extra/clang-tidy/cert/ProperlySeededRandomGeneratorCheck.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ class ProperlySeededRandomGeneratorCheck : public ClangTidyCheck {
3333
void checkSeed(const ast_matchers::MatchFinder::MatchResult &Result,
3434
const T *Func);
3535

36-
std::string RawDisallowedSeedTypes;
36+
StringRef RawDisallowedSeedTypes;
3737
SmallVector<StringRef, 5> DisallowedSeedTypes;
3838
};
3939

clang-tools-extra/clang-tidy/modernize/UseNullptrCheck.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -494,7 +494,7 @@ UseNullptrCheck::UseNullptrCheck(StringRef Name, ClangTidyContext *Context)
494494
NullMacrosStr(Options.get("NullMacros", "NULL")),
495495
IgnoredTypes(utils::options::parseStringList(Options.get(
496496
"IgnoredTypes", "_CmpUnspecifiedParam;^std::__cmp_cat::__unspec"))) {
497-
StringRef(NullMacrosStr).split(NullMacros, ",");
497+
NullMacrosStr.split(NullMacros, ",");
498498
}
499499

500500
void UseNullptrCheck::storeOptions(ClangTidyOptions::OptionMap &Opts) {

clang-tools-extra/clang-tidy/openmp/ExceptionEscapeCheck.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ ExceptionEscapeCheck::ExceptionEscapeCheck(StringRef Name,
2323
llvm::SmallVector<StringRef, 8> IgnoredExceptionsVec;
2424

2525
llvm::StringSet<> IgnoredExceptions;
26-
StringRef(RawIgnoredExceptions).split(IgnoredExceptionsVec, ",", -1, false);
26+
RawIgnoredExceptions.split(IgnoredExceptionsVec, ",", -1, false);
2727
llvm::transform(IgnoredExceptionsVec, IgnoredExceptionsVec.begin(),
2828
[](StringRef S) { return S.trim(); });
2929
IgnoredExceptions.insert_range(IgnoredExceptionsVec);

clang-tools-extra/clang-tidy/openmp/ExceptionEscapeCheck.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ class ExceptionEscapeCheck : public ClangTidyCheck {
3030
void check(const ast_matchers::MatchFinder::MatchResult &Result) override;
3131

3232
private:
33-
std::string RawIgnoredExceptions;
33+
StringRef RawIgnoredExceptions;
3434

3535
utils::ExceptionAnalyzer Tracer;
3636
};

0 commit comments

Comments
 (0)