[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.
This commit is contained in:
Victor Chernyakin
2025-09-29 11:28:20 -07:00
committed by GitHub
parent 0f70b44016
commit 5da28bd331
9 changed files with 12 additions and 12 deletions

View File

@@ -19,7 +19,7 @@ ComparisonInTempFailureRetryCheck::ComparisonInTempFailureRetryCheck(
StringRef Name, ClangTidyContext *Context)
: ClangTidyCheck(Name, Context),
RawRetryList(Options.get("RetryMacros", "TEMP_FAILURE_RETRY")) {
StringRef(RawRetryList).split(RetryMacros, ",", -1, false);
RawRetryList.split(RetryMacros, ",", -1, false);
}
void ComparisonInTempFailureRetryCheck::storeOptions(

View File

@@ -92,7 +92,7 @@ AssertSideEffectCheck::AssertSideEffectCheck(StringRef Name,
RawAssertList(Options.get("AssertMacros", "assert,NSAssert,NSCAssert")),
IgnoredFunctions(utils::options::parseListPair(
"__builtin_expect;", Options.get("IgnoredFunctions", ""))) {
StringRef(RawAssertList).split(AssertMacros, ",", -1, false);
RawAssertList.split(AssertMacros, ",", -1, false);
}
// The options are explained in AssertSideEffectCheck.h.

View File

@@ -39,12 +39,12 @@ ExceptionEscapeCheck::ExceptionEscapeCheck(StringRef Name,
RawIgnoredExceptions(Options.get("IgnoredExceptions", "")) {
llvm::SmallVector<StringRef, 8> FunctionsThatShouldNotThrowVec,
IgnoredExceptionsVec;
StringRef(RawFunctionsThatShouldNotThrow)
.split(FunctionsThatShouldNotThrowVec, ",", -1, false);
RawFunctionsThatShouldNotThrow.split(FunctionsThatShouldNotThrowVec, ",", -1,
false);
FunctionsThatShouldNotThrow.insert_range(FunctionsThatShouldNotThrowVec);
llvm::StringSet<> IgnoredExceptions;
StringRef(RawIgnoredExceptions).split(IgnoredExceptionsVec, ",", -1, false);
RawIgnoredExceptions.split(IgnoredExceptionsVec, ",", -1, false);
IgnoredExceptions.insert_range(IgnoredExceptionsVec);
Tracer.ignoreExceptions(std::move(IgnoredExceptions));
Tracer.ignoreBadAlloc(true);

View File

@@ -33,8 +33,8 @@ public:
void check(const ast_matchers::MatchFinder::MatchResult &Result) override;
private:
std::string RawFunctionsThatShouldNotThrow;
std::string RawIgnoredExceptions;
StringRef RawFunctionsThatShouldNotThrow;
StringRef RawIgnoredExceptions;
llvm::StringSet<> FunctionsThatShouldNotThrow;
utils::ExceptionAnalyzer Tracer;

View File

@@ -20,7 +20,7 @@ ProperlySeededRandomGeneratorCheck::ProperlySeededRandomGeneratorCheck(
: ClangTidyCheck(Name, Context),
RawDisallowedSeedTypes(
Options.get("DisallowedSeedTypes", "time_t,std::time_t")) {
StringRef(RawDisallowedSeedTypes).split(DisallowedSeedTypes, ',');
RawDisallowedSeedTypes.split(DisallowedSeedTypes, ',');
}
void ProperlySeededRandomGeneratorCheck::storeOptions(

View File

@@ -33,7 +33,7 @@ private:
void checkSeed(const ast_matchers::MatchFinder::MatchResult &Result,
const T *Func);
std::string RawDisallowedSeedTypes;
StringRef RawDisallowedSeedTypes;
SmallVector<StringRef, 5> DisallowedSeedTypes;
};

View File

@@ -494,7 +494,7 @@ UseNullptrCheck::UseNullptrCheck(StringRef Name, ClangTidyContext *Context)
NullMacrosStr(Options.get("NullMacros", "NULL")),
IgnoredTypes(utils::options::parseStringList(Options.get(
"IgnoredTypes", "_CmpUnspecifiedParam;^std::__cmp_cat::__unspec"))) {
StringRef(NullMacrosStr).split(NullMacros, ",");
NullMacrosStr.split(NullMacros, ",");
}
void UseNullptrCheck::storeOptions(ClangTidyOptions::OptionMap &Opts) {

View File

@@ -23,7 +23,7 @@ ExceptionEscapeCheck::ExceptionEscapeCheck(StringRef Name,
llvm::SmallVector<StringRef, 8> IgnoredExceptionsVec;
llvm::StringSet<> IgnoredExceptions;
StringRef(RawIgnoredExceptions).split(IgnoredExceptionsVec, ",", -1, false);
RawIgnoredExceptions.split(IgnoredExceptionsVec, ",", -1, false);
llvm::transform(IgnoredExceptionsVec, IgnoredExceptionsVec.begin(),
[](StringRef S) { return S.trim(); });
IgnoredExceptions.insert_range(IgnoredExceptionsVec);

View File

@@ -30,7 +30,7 @@ public:
void check(const ast_matchers::MatchFinder::MatchResult &Result) override;
private:
std::string RawIgnoredExceptions;
StringRef RawIgnoredExceptions;
utils::ExceptionAnalyzer Tracer;
};