mirror of
https://github.com/capstone-engine/llvm-capstone.git
synced 2024-12-22 23:39:24 +00:00
[clang-tidy] Convert config options that are bools to use the bool overload of get(GlobalOrLocal)?
Summary: This was done with a script that looks for calls to Options.get(GlobalOrLocal) that take an integer for the second argument and the result is either compared not equal to 0 or implicitly converted to bool. There may be other occurances Reviewers: aaron.ballman, alexfh, gribozavr2 Reviewed By: aaron.ballman Subscribers: wuzish, nemanjai, xazax.hun, kbarton, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D77831
This commit is contained in:
parent
8e2daa0c7f
commit
672207c319
@ -23,16 +23,16 @@ namespace bugprone {
|
||||
ArgumentCommentCheck::ArgumentCommentCheck(StringRef Name,
|
||||
ClangTidyContext *Context)
|
||||
: ClangTidyCheck(Name, Context),
|
||||
StrictMode(Options.getLocalOrGlobal("StrictMode", 0) != 0),
|
||||
IgnoreSingleArgument(Options.get("IgnoreSingleArgument", 0) != 0),
|
||||
CommentBoolLiterals(Options.get("CommentBoolLiterals", 0) != 0),
|
||||
CommentIntegerLiterals(Options.get("CommentIntegerLiterals", 0) != 0),
|
||||
CommentFloatLiterals(Options.get("CommentFloatLiterals", 0) != 0),
|
||||
CommentStringLiterals(Options.get("CommentStringLiterals", 0) != 0),
|
||||
CommentUserDefinedLiterals(Options.get("CommentUserDefinedLiterals", 0) !=
|
||||
0),
|
||||
CommentCharacterLiterals(Options.get("CommentCharacterLiterals", 0) != 0),
|
||||
CommentNullPtrs(Options.get("CommentNullPtrs", 0) != 0),
|
||||
StrictMode(Options.getLocalOrGlobal("StrictMode", false)),
|
||||
IgnoreSingleArgument(Options.get("IgnoreSingleArgument", false)),
|
||||
CommentBoolLiterals(Options.get("CommentBoolLiterals", false)),
|
||||
CommentIntegerLiterals(Options.get("CommentIntegerLiterals", false)),
|
||||
CommentFloatLiterals(Options.get("CommentFloatLiterals", false)),
|
||||
CommentStringLiterals(Options.get("CommentStringLiterals", false)),
|
||||
CommentUserDefinedLiterals(
|
||||
Options.get("CommentUserDefinedLiterals", false)),
|
||||
CommentCharacterLiterals(Options.get("CommentCharacterLiterals", false)),
|
||||
CommentNullPtrs(Options.get("CommentNullPtrs", false)),
|
||||
IdentRE("^(/\\* *)([_A-Za-z][_A-Za-z0-9]*)( *= *\\*/)$") {}
|
||||
|
||||
void ArgumentCommentCheck::storeOptions(ClangTidyOptions::OptionMap &Opts) {
|
||||
|
@ -499,7 +499,7 @@ static void insertNullTerminatorExpr(StringRef Name,
|
||||
NotNullTerminatedResultCheck::NotNullTerminatedResultCheck(
|
||||
StringRef Name, ClangTidyContext *Context)
|
||||
: ClangTidyCheck(Name, Context),
|
||||
WantToUseSafeFunctions(Options.get("WantToUseSafeFunctions", 1)) {}
|
||||
WantToUseSafeFunctions(Options.get("WantToUseSafeFunctions", true)) {}
|
||||
|
||||
void NotNullTerminatedResultCheck::storeOptions(
|
||||
ClangTidyOptions::OptionMap &Opts) {
|
||||
|
@ -36,7 +36,7 @@ private:
|
||||
// If non-zero it is specifying if the target environment is considered to
|
||||
// implement '_s' suffixed memory and string handler functions which are safer
|
||||
// than older version (e.g. 'memcpy_s()'). The default value is '1'.
|
||||
const int WantToUseSafeFunctions;
|
||||
const bool WantToUseSafeFunctions;
|
||||
|
||||
bool UseSafeFunctions = false;
|
||||
|
||||
|
@ -60,12 +60,12 @@ CharUnits getSizeOfType(const ASTContext &Ctx, const Type *Ty) {
|
||||
SizeofExpressionCheck::SizeofExpressionCheck(StringRef Name,
|
||||
ClangTidyContext *Context)
|
||||
: ClangTidyCheck(Name, Context),
|
||||
WarnOnSizeOfConstant(Options.get("WarnOnSizeOfConstant", 1) != 0),
|
||||
WarnOnSizeOfConstant(Options.get("WarnOnSizeOfConstant", true)),
|
||||
WarnOnSizeOfIntegerExpression(
|
||||
Options.get("WarnOnSizeOfIntegerExpression", 0) != 0),
|
||||
WarnOnSizeOfThis(Options.get("WarnOnSizeOfThis", 1) != 0),
|
||||
Options.get("WarnOnSizeOfIntegerExpression", false)),
|
||||
WarnOnSizeOfThis(Options.get("WarnOnSizeOfThis", true)),
|
||||
WarnOnSizeOfCompareToConstant(
|
||||
Options.get("WarnOnSizeOfCompareToConstant", 1) != 0) {}
|
||||
Options.get("WarnOnSizeOfCompareToConstant", true)) {}
|
||||
|
||||
void SizeofExpressionCheck::storeOptions(ClangTidyOptions::OptionMap &Opts) {
|
||||
Options.store(Opts, "WarnOnSizeOfConstant", WarnOnSizeOfConstant);
|
||||
|
@ -26,7 +26,7 @@ AST_MATCHER_P(IntegerLiteral, isBiggerThan, unsigned, N) {
|
||||
StringConstructorCheck::StringConstructorCheck(StringRef Name,
|
||||
ClangTidyContext *Context)
|
||||
: ClangTidyCheck(Name, Context),
|
||||
WarnOnLargeLength(Options.get("WarnOnLargeLength", 1) != 0),
|
||||
WarnOnLargeLength(Options.get("WarnOnLargeLength", true)),
|
||||
LargeLengthThreshold(Options.get("LargeLengthThreshold", 0x800000)) {}
|
||||
|
||||
void StringConstructorCheck::storeOptions(ClangTidyOptions::OptionMap &Opts) {
|
||||
|
@ -110,7 +110,7 @@ static bool isPossiblyBitMask(const EnumDecl *EnumDec) {
|
||||
SuspiciousEnumUsageCheck::SuspiciousEnumUsageCheck(StringRef Name,
|
||||
ClangTidyContext *Context)
|
||||
: ClangTidyCheck(Name, Context),
|
||||
StrictMode(Options.getLocalOrGlobal("StrictMode", 0)) {}
|
||||
StrictMode(Options.getLocalOrGlobal("StrictMode", false)) {}
|
||||
|
||||
void SuspiciousEnumUsageCheck::storeOptions(ClangTidyOptions::OptionMap &Opts) {
|
||||
Options.store(Opts, "StrictMode", StrictMode);
|
||||
|
@ -69,8 +69,9 @@ static const char KnownStringCompareFunctions[] = "__builtin_memcmp;"
|
||||
SuspiciousStringCompareCheck::SuspiciousStringCompareCheck(
|
||||
StringRef Name, ClangTidyContext *Context)
|
||||
: ClangTidyCheck(Name, Context),
|
||||
WarnOnImplicitComparison(Options.get("WarnOnImplicitComparison", 1)),
|
||||
WarnOnLogicalNotComparison(Options.get("WarnOnLogicalNotComparison", 0)),
|
||||
WarnOnImplicitComparison(Options.get("WarnOnImplicitComparison", true)),
|
||||
WarnOnLogicalNotComparison(
|
||||
Options.get("WarnOnLogicalNotComparison", false)),
|
||||
StringCompareLikeFunctions(
|
||||
Options.get("StringCompareLikeFunctions", "")) {}
|
||||
|
||||
|
@ -27,8 +27,8 @@ public:
|
||||
MacroUsageCheck(StringRef Name, ClangTidyContext *Context)
|
||||
: ClangTidyCheck(Name, Context),
|
||||
AllowedRegexp(Options.get("AllowedRegexp", "^DEBUG_*")),
|
||||
CheckCapsOnly(Options.get("CheckCapsOnly", 0)),
|
||||
IgnoreCommandLineMacros(Options.get("IgnoreCommandLineMacros", 1)) {}
|
||||
CheckCapsOnly(Options.get("CheckCapsOnly", false)),
|
||||
IgnoreCommandLineMacros(Options.get("IgnoreCommandLineMacros", true)) {}
|
||||
bool isLanguageVersionSupported(const LangOptions &LangOpts) const override {
|
||||
return LangOpts.CPlusPlus11;
|
||||
}
|
||||
|
@ -26,8 +26,8 @@ NarrowingConversionsCheck::NarrowingConversionsCheck(StringRef Name,
|
||||
ClangTidyContext *Context)
|
||||
: ClangTidyCheck(Name, Context),
|
||||
WarnOnFloatingPointNarrowingConversion(
|
||||
Options.get("WarnOnFloatingPointNarrowingConversion", 1)),
|
||||
PedanticMode(Options.get("PedanticMode", 0)) {}
|
||||
Options.get("WarnOnFloatingPointNarrowingConversion", true)),
|
||||
PedanticMode(Options.get("PedanticMode", false)) {}
|
||||
|
||||
void NarrowingConversionsCheck::registerMatchers(MatchFinder *Finder) {
|
||||
// ceil() and floor() are guaranteed to return integers, even though the type
|
||||
|
@ -23,11 +23,11 @@ namespace cppcoreguidelines {
|
||||
|
||||
SpecialMemberFunctionsCheck::SpecialMemberFunctionsCheck(
|
||||
StringRef Name, ClangTidyContext *Context)
|
||||
: ClangTidyCheck(Name, Context),
|
||||
AllowMissingMoveFunctions(Options.get("AllowMissingMoveFunctions", 0)),
|
||||
AllowSoleDefaultDtor(Options.get("AllowSoleDefaultDtor", 0)),
|
||||
: ClangTidyCheck(Name, Context), AllowMissingMoveFunctions(Options.get(
|
||||
"AllowMissingMoveFunctions", false)),
|
||||
AllowSoleDefaultDtor(Options.get("AllowSoleDefaultDtor", false)),
|
||||
AllowMissingMoveFunctionsWhenCopyIsDeleted(
|
||||
Options.get("AllowMissingMoveFunctionsWhenCopyIsDeleted", 0)) {}
|
||||
Options.get("AllowMissingMoveFunctionsWhenCopyIsDeleted", false)) {}
|
||||
|
||||
void SpecialMemberFunctionsCheck::storeOptions(
|
||||
ClangTidyOptions::OptionMap &Opts) {
|
||||
|
@ -27,7 +27,7 @@ class MultiwayPathsCoveredCheck : public ClangTidyCheck {
|
||||
public:
|
||||
MultiwayPathsCoveredCheck(StringRef Name, ClangTidyContext *Context)
|
||||
: ClangTidyCheck(Name, Context),
|
||||
WarnOnMissingElse(Options.get("WarnOnMissingElse", 0)) {}
|
||||
WarnOnMissingElse(Options.get("WarnOnMissingElse", false)) {}
|
||||
void storeOptions(ClangTidyOptions::OptionMap &Opts) override;
|
||||
void registerMatchers(ast_matchers::MatchFinder *Finder) override;
|
||||
void check(const ast_matchers::MatchFinder::MatchResult &Result) override;
|
||||
|
@ -123,7 +123,7 @@ UnusedParametersCheck::~UnusedParametersCheck() = default;
|
||||
UnusedParametersCheck::UnusedParametersCheck(StringRef Name,
|
||||
ClangTidyContext *Context)
|
||||
: ClangTidyCheck(Name, Context),
|
||||
StrictMode(Options.getLocalOrGlobal("StrictMode", 0) != 0) {}
|
||||
StrictMode(Options.getLocalOrGlobal("StrictMode", false)) {}
|
||||
|
||||
void UnusedParametersCheck::storeOptions(ClangTidyOptions::OptionMap &Opts) {
|
||||
Options.store(Opts, "StrictMode", StrictMode);
|
||||
|
@ -576,7 +576,7 @@ getForwardedArgumentList(const LambdaProperties &P) {
|
||||
}
|
||||
AvoidBindCheck::AvoidBindCheck(StringRef Name, ClangTidyContext *Context)
|
||||
: ClangTidyCheck(Name, Context),
|
||||
PermissiveParameterList(Options.get("PermissiveParameterList", 0) != 0) {}
|
||||
PermissiveParameterList(Options.get("PermissiveParameterList", false)) {}
|
||||
|
||||
void AvoidBindCheck::registerMatchers(MatchFinder *Finder) {
|
||||
Finder->addMatcher(
|
||||
|
@ -123,7 +123,7 @@ PassByValueCheck::PassByValueCheck(StringRef Name, ClangTidyContext *Context)
|
||||
IncludeStyle(Options.getLocalOrGlobal("IncludeStyle",
|
||||
utils::IncludeSorter::getMapping(),
|
||||
utils::IncludeSorter::IS_LLVM)),
|
||||
ValuesOnly(Options.get("ValuesOnly", 0) != 0) {}
|
||||
ValuesOnly(Options.get("ValuesOnly", false)) {}
|
||||
|
||||
void PassByValueCheck::storeOptions(ClangTidyOptions::OptionMap &Opts) {
|
||||
Options.store(Opts, "IncludeStyle", IncludeStyle,
|
||||
|
@ -317,7 +317,7 @@ StatementMatcher makeCombinedMatcher() {
|
||||
UseAutoCheck::UseAutoCheck(StringRef Name, ClangTidyContext *Context)
|
||||
: ClangTidyCheck(Name, Context),
|
||||
MinTypeNameLength(Options.get("MinTypeNameLength", 5)),
|
||||
RemoveStars(Options.get("RemoveStars", 0)) {}
|
||||
RemoveStars(Options.get("RemoveStars", false)) {}
|
||||
|
||||
void UseAutoCheck::storeOptions(ClangTidyOptions::OptionMap &Opts) {
|
||||
Options.store(Opts, "MinTypeNameLength", MinTypeNameLength);
|
||||
|
@ -186,8 +186,8 @@ static bool sameValue(const Expr *E1, const Expr *E2) {
|
||||
UseDefaultMemberInitCheck::UseDefaultMemberInitCheck(StringRef Name,
|
||||
ClangTidyContext *Context)
|
||||
: ClangTidyCheck(Name, Context),
|
||||
UseAssignment(Options.get("UseAssignment", 0) != 0),
|
||||
IgnoreMacros(Options.getLocalOrGlobal("IgnoreMacros", true) != 0) {}
|
||||
UseAssignment(Options.get("UseAssignment", false)),
|
||||
IgnoreMacros(Options.getLocalOrGlobal("IgnoreMacros", true)) {}
|
||||
|
||||
void UseDefaultMemberInitCheck::storeOptions(
|
||||
ClangTidyOptions::OptionMap &Opts) {
|
||||
|
@ -28,8 +28,8 @@ const auto DefaultTupleMakeFunctions = "::std::make_pair; ::std::make_tuple";
|
||||
} // namespace
|
||||
|
||||
UseEmplaceCheck::UseEmplaceCheck(StringRef Name, ClangTidyContext *Context)
|
||||
: ClangTidyCheck(Name, Context),
|
||||
IgnoreImplicitConstructors(Options.get("IgnoreImplicitConstructors", 0)),
|
||||
: ClangTidyCheck(Name, Context), IgnoreImplicitConstructors(Options.get(
|
||||
"IgnoreImplicitConstructors", false)),
|
||||
ContainersWithPushBack(utils::options::parseStringList(Options.get(
|
||||
"ContainersWithPushBack", DefaultContainersWithPushBack))),
|
||||
SmartPointers(utils::options::parseStringList(
|
||||
|
@ -201,7 +201,7 @@ static bool bodyEmpty(const ASTContext *Context, const CompoundStmt *Body) {
|
||||
UseEqualsDefaultCheck::UseEqualsDefaultCheck(StringRef Name,
|
||||
ClangTidyContext *Context)
|
||||
: ClangTidyCheck(Name, Context),
|
||||
IgnoreMacros(Options.getLocalOrGlobal("IgnoreMacros", true) != 0) {}
|
||||
IgnoreMacros(Options.getLocalOrGlobal("IgnoreMacros", true)) {}
|
||||
|
||||
void UseEqualsDefaultCheck::storeOptions(ClangTidyOptions::OptionMap &Opts) {
|
||||
Options.store(Opts, "IgnoreMacros", IgnoreMacros);
|
||||
|
@ -38,7 +38,7 @@ class UseEqualsDeleteCheck : public ClangTidyCheck {
|
||||
public:
|
||||
UseEqualsDeleteCheck(StringRef Name, ClangTidyContext *Context)
|
||||
: ClangTidyCheck(Name, Context),
|
||||
IgnoreMacros(Options.getLocalOrGlobal("IgnoreMacros", 1) != 0) {}
|
||||
IgnoreMacros(Options.getLocalOrGlobal("IgnoreMacros", true)) {}
|
||||
bool isLanguageVersionSupported(const LangOptions &LangOpts) const override {
|
||||
return LangOpts.CPlusPlus;
|
||||
}
|
||||
|
@ -18,7 +18,7 @@ namespace modernize {
|
||||
|
||||
UseTransparentFunctorsCheck::UseTransparentFunctorsCheck(
|
||||
StringRef Name, ClangTidyContext *Context)
|
||||
: ClangTidyCheck(Name, Context), SafeMode(Options.get("SafeMode", 0)) {}
|
||||
: ClangTidyCheck(Name, Context), SafeMode(Options.get("SafeMode", false)) {}
|
||||
|
||||
void UseTransparentFunctorsCheck::storeOptions(
|
||||
ClangTidyOptions::OptionMap &Opts) {
|
||||
|
@ -23,7 +23,7 @@ namespace performance {
|
||||
|
||||
ForRangeCopyCheck::ForRangeCopyCheck(StringRef Name, ClangTidyContext *Context)
|
||||
: ClangTidyCheck(Name, Context),
|
||||
WarnOnAllAutoCopies(Options.get("WarnOnAllAutoCopies", 0)),
|
||||
WarnOnAllAutoCopies(Options.get("WarnOnAllAutoCopies", false)),
|
||||
AllowedTypes(
|
||||
utils::options::parseStringList(Options.get("AllowedTypes", ""))) {}
|
||||
|
||||
|
@ -24,7 +24,7 @@ void InefficientStringConcatenationCheck::storeOptions(
|
||||
InefficientStringConcatenationCheck::InefficientStringConcatenationCheck(
|
||||
StringRef Name, ClangTidyContext *Context)
|
||||
: ClangTidyCheck(Name, Context),
|
||||
StrictMode(Options.getLocalOrGlobal("StrictMode", 0)) {}
|
||||
StrictMode(Options.getLocalOrGlobal("StrictMode", false)) {}
|
||||
|
||||
void InefficientStringConcatenationCheck::registerMatchers(
|
||||
MatchFinder *Finder) {
|
||||
|
@ -85,7 +85,7 @@ static StringRef TrySuggestX86(StringRef Name) {
|
||||
SIMDIntrinsicsCheck::SIMDIntrinsicsCheck(StringRef Name,
|
||||
ClangTidyContext *Context)
|
||||
: ClangTidyCheck(Name, Context), Std(Options.get("Std", "")),
|
||||
Suggest(Options.get("Suggest", 0) != 0) {}
|
||||
Suggest(Options.get("Suggest", false)) {}
|
||||
|
||||
void SIMDIntrinsicsCheck::storeOptions(ClangTidyOptions::OptionMap &Opts) {
|
||||
Options.store(Opts, "Std", "");
|
||||
|
@ -139,8 +139,8 @@ private:
|
||||
IdentifierNamingCheck::IdentifierNamingCheck(StringRef Name,
|
||||
ClangTidyContext *Context)
|
||||
: RenamerClangTidyCheck(Name, Context),
|
||||
IgnoreFailedSplit(Options.get("IgnoreFailedSplit", 0)),
|
||||
IgnoreMainLikeFunctions(Options.get("IgnoreMainLikeFunctions", 0)) {
|
||||
IgnoreFailedSplit(Options.get("IgnoreFailedSplit", false)),
|
||||
IgnoreMainLikeFunctions(Options.get("IgnoreMainLikeFunctions", false)) {
|
||||
|
||||
for (auto const &Name : StyleNames) {
|
||||
auto CaseOptional = [&]() -> llvm::Optional<CaseType> {
|
||||
|
@ -27,8 +27,8 @@ public:
|
||||
InconsistentDeclarationParameterNameCheck(StringRef Name,
|
||||
ClangTidyContext *Context)
|
||||
: ClangTidyCheck(Name, Context),
|
||||
IgnoreMacros(Options.getLocalOrGlobal("IgnoreMacros", 1) != 0),
|
||||
Strict(Options.getLocalOrGlobal("Strict", 0) != 0) {}
|
||||
IgnoreMacros(Options.getLocalOrGlobal("IgnoreMacros", true)),
|
||||
Strict(Options.getLocalOrGlobal("Strict", false)) {}
|
||||
|
||||
void storeOptions(ClangTidyOptions::OptionMap &Opts) override;
|
||||
void registerMatchers(ast_matchers::MatchFinder *Finder) override;
|
||||
|
@ -25,7 +25,7 @@ public:
|
||||
RedundantMemberInitCheck(StringRef Name, ClangTidyContext *Context)
|
||||
: ClangTidyCheck(Name, Context),
|
||||
IgnoreBaseInCopyConstructors(
|
||||
Options.get("IgnoreBaseInCopyConstructors", 0)) {}
|
||||
Options.get("IgnoreBaseInCopyConstructors", false)) {}
|
||||
bool isLanguageVersionSupported(const LangOptions &LangOpts) const override {
|
||||
return LangOpts.CPlusPlus;
|
||||
}
|
||||
|
@ -28,7 +28,7 @@ class RedundantSmartptrGetCheck : public ClangTidyCheck {
|
||||
public:
|
||||
RedundantSmartptrGetCheck(StringRef Name, ClangTidyContext *Context)
|
||||
: ClangTidyCheck(Name, Context),
|
||||
IgnoreMacros(Options.getLocalOrGlobal("IgnoreMacros", 1) != 0) {}
|
||||
IgnoreMacros(Options.getLocalOrGlobal("IgnoreMacros", true)) {}
|
||||
bool isLanguageVersionSupported(const LangOptions &LangOpts) const override {
|
||||
return LangOpts.CPlusPlus;
|
||||
}
|
||||
|
@ -333,13 +333,12 @@ class SimplifyBooleanExprCheck::Visitor : public RecursiveASTVisitor<Visitor> {
|
||||
const MatchFinder::MatchResult &Result;
|
||||
};
|
||||
|
||||
|
||||
SimplifyBooleanExprCheck::SimplifyBooleanExprCheck(StringRef Name,
|
||||
ClangTidyContext *Context)
|
||||
: ClangTidyCheck(Name, Context),
|
||||
ChainedConditionalReturn(Options.get("ChainedConditionalReturn", 0U)),
|
||||
ChainedConditionalReturn(Options.get("ChainedConditionalReturn", false)),
|
||||
ChainedConditionalAssignment(
|
||||
Options.get("ChainedConditionalAssignment", 0U)) {}
|
||||
Options.get("ChainedConditionalAssignment", false)) {}
|
||||
|
||||
bool containsBoolLiteral(const Expr *E) {
|
||||
if (!E)
|
||||
|
@ -183,7 +183,7 @@ UppercaseLiteralSuffixCheck::UppercaseLiteralSuffixCheck(
|
||||
: ClangTidyCheck(Name, Context),
|
||||
NewSuffixes(
|
||||
utils::options::parseStringList(Options.get("NewSuffixes", ""))),
|
||||
IgnoreMacros(Options.getLocalOrGlobal("IgnoreMacros", 1) != 0) {}
|
||||
IgnoreMacros(Options.getLocalOrGlobal("IgnoreMacros", true)) {}
|
||||
|
||||
void UppercaseLiteralSuffixCheck::storeOptions(
|
||||
ClangTidyOptions::OptionMap &Opts) {
|
||||
|
Loading…
Reference in New Issue
Block a user