mirror of
https://github.com/intel/llvm.git
synced 2026-01-26 12:26:52 +08:00
[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:
committed by
GitHub
parent
0f70b44016
commit
5da28bd331
@@ -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(
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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(
|
||||
|
||||
@@ -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;
|
||||
};
|
||||
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -30,7 +30,7 @@ public:
|
||||
void check(const ast_matchers::MatchFinder::MatchResult &Result) override;
|
||||
|
||||
private:
|
||||
std::string RawIgnoredExceptions;
|
||||
StringRef RawIgnoredExceptions;
|
||||
|
||||
utils::ExceptionAnalyzer Tracer;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user