Author: Nathan James Date: 2020-06-21T19:01:11+01:00 New Revision: db90d315706b5d5a06cb79607cef1a8d581d0ba8
URL: https://github.com/llvm/llvm-project/commit/db90d315706b5d5a06cb79607cef1a8d581d0ba8 DIFF: https://github.com/llvm/llvm-project/commit/db90d315706b5d5a06cb79607cef1a8d581d0ba8.diff LOG: [clang-tidy] Implement storeOptions for checks missing it. Just adds the storeOptions for Checks that weren't already storing their options. Reviewed By: aaron.ballman Differential Revision: https://reviews.llvm.org/D82223 Added: Modified: clang-tools-extra/clang-tidy/bugprone/TooSmallLoopVariableCheck.cpp clang-tools-extra/clang-tidy/cppcoreguidelines/InitVariablesCheck.cpp clang-tools-extra/clang-tidy/cppcoreguidelines/InitVariablesCheck.h clang-tools-extra/clang-tidy/cppcoreguidelines/NarrowingConversionsCheck.cpp clang-tools-extra/clang-tidy/cppcoreguidelines/NarrowingConversionsCheck.h clang-tools-extra/clang-tidy/misc/NonPrivateMemberVariablesInClassesCheck.cpp clang-tools-extra/clang-tidy/misc/NonPrivateMemberVariablesInClassesCheck.h clang-tools-extra/clang-tidy/misc/ThrowByValueCatchByReferenceCheck.cpp clang-tools-extra/clang-tidy/misc/ThrowByValueCatchByReferenceCheck.h clang-tools-extra/clang-tidy/modernize/AvoidBindCheck.cpp clang-tools-extra/clang-tidy/modernize/AvoidBindCheck.h clang-tools-extra/clang-tidy/modernize/LoopConvertCheck.cpp clang-tools-extra/clang-tidy/modernize/RawStringLiteralCheck.cpp clang-tools-extra/clang-tidy/modernize/UseAutoCheck.cpp clang-tools-extra/clang-tidy/modernize/UseBoolLiteralsCheck.cpp clang-tools-extra/clang-tidy/modernize/UseBoolLiteralsCheck.h clang-tools-extra/clang-tidy/modernize/UseEmplaceCheck.cpp clang-tools-extra/clang-tidy/modernize/UseTransparentFunctorsCheck.cpp clang-tools-extra/clang-tidy/modernize/UseUsingCheck.cpp clang-tools-extra/clang-tidy/modernize/UseUsingCheck.h clang-tools-extra/clang-tidy/readability/MagicNumbersCheck.cpp clang-tools-extra/clang-tidy/readability/MagicNumbersCheck.h clang-tools-extra/clang-tidy/readability/RedundantDeclarationCheck.cpp clang-tools-extra/clang-tidy/readability/RedundantDeclarationCheck.h clang-tools-extra/clang-tidy/readability/StaticAccessedThroughInstanceCheck.h clang-tools-extra/clang-tidy/utils/HeaderGuard.cpp clang-tools-extra/clang-tidy/utils/HeaderGuard.h Removed: ################################################################################ diff --git a/clang-tools-extra/clang-tidy/bugprone/TooSmallLoopVariableCheck.cpp b/clang-tools-extra/clang-tidy/bugprone/TooSmallLoopVariableCheck.cpp index be5a4697e94b..06332af92e37 100644 --- a/clang-tools-extra/clang-tidy/bugprone/TooSmallLoopVariableCheck.cpp +++ b/clang-tools-extra/clang-tidy/bugprone/TooSmallLoopVariableCheck.cpp @@ -30,8 +30,7 @@ static constexpr llvm::StringLiteral LoopIncrementName = TooSmallLoopVariableCheck::TooSmallLoopVariableCheck(StringRef Name, ClangTidyContext *Context) : ClangTidyCheck(Name, Context), - MagnitudeBitsUpperLimit(Options.get<unsigned>( - "MagnitudeBitsUpperLimit", 16)) {} + MagnitudeBitsUpperLimit(Options.get("MagnitudeBitsUpperLimit", 16U)) {} void TooSmallLoopVariableCheck::storeOptions( ClangTidyOptions::OptionMap &Opts) { diff --git a/clang-tools-extra/clang-tidy/cppcoreguidelines/InitVariablesCheck.cpp b/clang-tools-extra/clang-tidy/cppcoreguidelines/InitVariablesCheck.cpp index a5756ff634bb..608df8a0ab44 100644 --- a/clang-tools-extra/clang-tidy/cppcoreguidelines/InitVariablesCheck.cpp +++ b/clang-tools-extra/clang-tidy/cppcoreguidelines/InitVariablesCheck.cpp @@ -29,6 +29,12 @@ InitVariablesCheck::InitVariablesCheck(StringRef Name, utils::IncludeSorter::IS_LLVM)), MathHeader(Options.get("MathHeader", "math.h")) {} +void InitVariablesCheck::storeOptions(ClangTidyOptions::OptionMap &Opts) { + Options.store(Opts, "IncludeStyle", IncludeStyle, + utils::IncludeSorter::getMapping()); + Options.store(Opts, "MathHeader", MathHeader); +} + void InitVariablesCheck::registerMatchers(MatchFinder *Finder) { std::string BadDecl = "badDecl"; Finder->addMatcher( @@ -102,7 +108,6 @@ void InitVariablesCheck::check(const MatchFinder::MatchResult &Result) { } } } - } // namespace cppcoreguidelines } // namespace tidy } // namespace clang diff --git a/clang-tools-extra/clang-tidy/cppcoreguidelines/InitVariablesCheck.h b/clang-tools-extra/clang-tidy/cppcoreguidelines/InitVariablesCheck.h index 0cacf9e533cf..61521b118a99 100644 --- a/clang-tools-extra/clang-tidy/cppcoreguidelines/InitVariablesCheck.h +++ b/clang-tools-extra/clang-tidy/cppcoreguidelines/InitVariablesCheck.h @@ -24,6 +24,7 @@ namespace cppcoreguidelines { class InitVariablesCheck : public ClangTidyCheck { public: InitVariablesCheck(StringRef Name, ClangTidyContext *Context); + void storeOptions(ClangTidyOptions::OptionMap &Opts) override; void registerPPCallbacks(const SourceManager &SM, Preprocessor *PP, Preprocessor *ModuleExpanderPP) override; void registerMatchers(ast_matchers::MatchFinder *Finder) override; diff --git a/clang-tools-extra/clang-tidy/cppcoreguidelines/NarrowingConversionsCheck.cpp b/clang-tools-extra/clang-tidy/cppcoreguidelines/NarrowingConversionsCheck.cpp index 2ae21a303ef7..aa860b30fe75 100644 --- a/clang-tools-extra/clang-tidy/cppcoreguidelines/NarrowingConversionsCheck.cpp +++ b/clang-tools-extra/clang-tidy/cppcoreguidelines/NarrowingConversionsCheck.cpp @@ -29,6 +29,13 @@ NarrowingConversionsCheck::NarrowingConversionsCheck(StringRef Name, Options.get("WarnOnFloatingPointNarrowingConversion", true)), PedanticMode(Options.get("PedanticMode", false)) {} +void NarrowingConversionsCheck::storeOptions( + ClangTidyOptions::OptionMap &Opts) { + Options.store(Opts, "WarnOnFloatingPointNarrowingConversion", + WarnOnFloatingPointNarrowingConversion); + Options.store(Opts, "PedanticMode", PedanticMode); +} + void NarrowingConversionsCheck::registerMatchers(MatchFinder *Finder) { // ceil() and floor() are guaranteed to return integers, even though the type // is not integral. @@ -442,7 +449,6 @@ void NarrowingConversionsCheck::check(const MatchFinder::MatchResult &Result) { return handleImplicitCast(*Result.Context, *Cast); llvm_unreachable("must be binary operator or cast expression"); } - } // namespace cppcoreguidelines } // namespace tidy } // namespace clang diff --git a/clang-tools-extra/clang-tidy/cppcoreguidelines/NarrowingConversionsCheck.h b/clang-tools-extra/clang-tidy/cppcoreguidelines/NarrowingConversionsCheck.h index cc598edd5380..6a9f38bb5d50 100644 --- a/clang-tools-extra/clang-tidy/cppcoreguidelines/NarrowingConversionsCheck.h +++ b/clang-tools-extra/clang-tidy/cppcoreguidelines/NarrowingConversionsCheck.h @@ -25,6 +25,8 @@ class NarrowingConversionsCheck : public ClangTidyCheck { public: NarrowingConversionsCheck(StringRef Name, ClangTidyContext *Context); + void storeOptions(ClangTidyOptions::OptionMap &Opts) override; + void registerMatchers(ast_matchers::MatchFinder *Finder) override; void check(const ast_matchers::MatchFinder::MatchResult &Result) override; diff --git a/clang-tools-extra/clang-tidy/misc/NonPrivateMemberVariablesInClassesCheck.cpp b/clang-tools-extra/clang-tidy/misc/NonPrivateMemberVariablesInClassesCheck.cpp index 5b6988509742..ed736d111762 100644 --- a/clang-tools-extra/clang-tidy/misc/NonPrivateMemberVariablesInClassesCheck.cpp +++ b/clang-tools-extra/clang-tidy/misc/NonPrivateMemberVariablesInClassesCheck.cpp @@ -48,6 +48,14 @@ NonPrivateMemberVariablesInClassesCheck:: IgnorePublicMemberVariables( Options.get("IgnorePublicMemberVariables", false)) {} +void NonPrivateMemberVariablesInClassesCheck::storeOptions( + ClangTidyOptions::OptionMap &Opts) { + Options.store(Opts, "IgnoreClassesWithAllMemberVariablesBeingPublic", + IgnoreClassesWithAllMemberVariablesBeingPublic); + Options.store(Opts, "IgnorePublicMemberVariables", + IgnorePublicMemberVariables); +} + void NonPrivateMemberVariablesInClassesCheck::registerMatchers( MatchFinder *Finder) { // We can ignore structs/classes with all member variables being public. diff --git a/clang-tools-extra/clang-tidy/misc/NonPrivateMemberVariablesInClassesCheck.h b/clang-tools-extra/clang-tidy/misc/NonPrivateMemberVariablesInClassesCheck.h index 70658e1355fb..b50872c943d3 100644 --- a/clang-tools-extra/clang-tidy/misc/NonPrivateMemberVariablesInClassesCheck.h +++ b/clang-tools-extra/clang-tidy/misc/NonPrivateMemberVariablesInClassesCheck.h @@ -33,6 +33,7 @@ class NonPrivateMemberVariablesInClassesCheck : public ClangTidyCheck { bool isLanguageVersionSupported(const LangOptions &LangOpts) const override { return LangOpts.CPlusPlus; } + void storeOptions(ClangTidyOptions::OptionMap &Opts) override; void registerMatchers(ast_matchers::MatchFinder *Finder) override; void check(const ast_matchers::MatchFinder::MatchResult &Result) override; diff --git a/clang-tools-extra/clang-tidy/misc/ThrowByValueCatchByReferenceCheck.cpp b/clang-tools-extra/clang-tidy/misc/ThrowByValueCatchByReferenceCheck.cpp index 02cbf273b73a..a63598fe1129 100644 --- a/clang-tools-extra/clang-tidy/misc/ThrowByValueCatchByReferenceCheck.cpp +++ b/clang-tools-extra/clang-tidy/misc/ThrowByValueCatchByReferenceCheck.cpp @@ -23,7 +23,9 @@ ThrowByValueCatchByReferenceCheck::ThrowByValueCatchByReferenceCheck( CheckAnonymousTemporaries(Options.get("CheckThrowTemporaries", true)), WarnOnLargeObject(Options.get("WarnOnLargeObject", false)), // Cannot access `ASTContext` from here so set it to an extremal value. - MaxSize(Options.get("MaxSize", std::numeric_limits<uint64_t>::max())) {} + MaxSizeOptions( + Options.get("MaxSize", std::numeric_limits<uint64_t>::max())), + MaxSize(MaxSizeOptions) {} void ThrowByValueCatchByReferenceCheck::registerMatchers(MatchFinder *Finder) { Finder->addMatcher(cxxThrowExpr().bind("throw"), this); @@ -33,6 +35,8 @@ void ThrowByValueCatchByReferenceCheck::registerMatchers(MatchFinder *Finder) { void ThrowByValueCatchByReferenceCheck::storeOptions( ClangTidyOptions::OptionMap &Opts) { Options.store(Opts, "CheckThrowTemporaries", true); + Options.store(Opts, "WarnOnLargeObjects", WarnOnLargeObject); + Options.store(Opts, "MaxSize", MaxSizeOptions); } void ThrowByValueCatchByReferenceCheck::check( diff --git a/clang-tools-extra/clang-tidy/misc/ThrowByValueCatchByReferenceCheck.h b/clang-tools-extra/clang-tidy/misc/ThrowByValueCatchByReferenceCheck.h index fdee9a01c9c5..3018fda6a389 100644 --- a/clang-tools-extra/clang-tidy/misc/ThrowByValueCatchByReferenceCheck.h +++ b/clang-tools-extra/clang-tidy/misc/ThrowByValueCatchByReferenceCheck.h @@ -45,6 +45,7 @@ class ThrowByValueCatchByReferenceCheck : public ClangTidyCheck { bool isFunctionOrCatchVar(const DeclRefExpr *declRefExpr); const bool CheckAnonymousTemporaries; const bool WarnOnLargeObject; + const uint64_t MaxSizeOptions; // The raw value read from the options. uint64_t MaxSize; // No `const` because we have to set it in two steps. }; diff --git a/clang-tools-extra/clang-tidy/modernize/AvoidBindCheck.cpp b/clang-tools-extra/clang-tidy/modernize/AvoidBindCheck.cpp index b45d9c513e61..37f9eb6955d3 100644 --- a/clang-tools-extra/clang-tidy/modernize/AvoidBindCheck.cpp +++ b/clang-tools-extra/clang-tidy/modernize/AvoidBindCheck.cpp @@ -578,6 +578,10 @@ AvoidBindCheck::AvoidBindCheck(StringRef Name, ClangTidyContext *Context) : ClangTidyCheck(Name, Context), PermissiveParameterList(Options.get("PermissiveParameterList", false)) {} +void AvoidBindCheck::storeOptions(ClangTidyOptions::OptionMap &Opts) { + Options.store(Opts, "PermissiveParameterList", PermissiveParameterList); +} + void AvoidBindCheck::registerMatchers(MatchFinder *Finder) { Finder->addMatcher( callExpr( diff --git a/clang-tools-extra/clang-tidy/modernize/AvoidBindCheck.h b/clang-tools-extra/clang-tidy/modernize/AvoidBindCheck.h index 8a8a1d15d120..d52c33a01b32 100644 --- a/clang-tools-extra/clang-tidy/modernize/AvoidBindCheck.h +++ b/clang-tools-extra/clang-tidy/modernize/AvoidBindCheck.h @@ -27,6 +27,7 @@ class AvoidBindCheck : public ClangTidyCheck { bool isLanguageVersionSupported(const LangOptions &LangOpts) const override { return LangOpts.CPlusPlus14; } + void storeOptions(ClangTidyOptions::OptionMap &Opts) override; void registerMatchers(ast_matchers::MatchFinder *Finder) override; void check(const ast_matchers::MatchFinder::MatchResult &Result) override; diff --git a/clang-tools-extra/clang-tidy/modernize/LoopConvertCheck.cpp b/clang-tools-extra/clang-tidy/modernize/LoopConvertCheck.cpp index be3a7141a5cc..dd18d866e508 100644 --- a/clang-tools-extra/clang-tidy/modernize/LoopConvertCheck.cpp +++ b/clang-tools-extra/clang-tidy/modernize/LoopConvertCheck.cpp @@ -476,7 +476,7 @@ LoopConvertCheck::RangeDescriptor::RangeDescriptor() LoopConvertCheck::LoopConvertCheck(StringRef Name, ClangTidyContext *Context) : ClangTidyCheck(Name, Context), TUInfo(new TUTrackingInfo), - MaxCopySize(std::stoull(Options.get("MaxCopySize", "16"))), + MaxCopySize(Options.get("MaxCopySize", 16ULL)), MinConfidence(Options.get("MinConfidence", getConfidenceMapping(), Confidence::CL_Reasonable)), NamingStyle(Options.get("NamingStyle", getStyleMapping(), diff --git a/clang-tools-extra/clang-tidy/modernize/RawStringLiteralCheck.cpp b/clang-tools-extra/clang-tidy/modernize/RawStringLiteralCheck.cpp index fa0313f1ef0a..7990bc2b8f2a 100644 --- a/clang-tools-extra/clang-tidy/modernize/RawStringLiteralCheck.cpp +++ b/clang-tools-extra/clang-tidy/modernize/RawStringLiteralCheck.cpp @@ -111,10 +111,9 @@ RawStringLiteralCheck::RawStringLiteralCheck(StringRef Name, DisallowedChars.set(static_cast<unsigned char>(C)); } -void RawStringLiteralCheck::storeOptions(ClangTidyOptions::OptionMap &Options) { - ClangTidyCheck::storeOptions(Options); - this->Options.store(Options, "ReplaceShorterLiterals", - ReplaceShorterLiterals); +void RawStringLiteralCheck::storeOptions(ClangTidyOptions::OptionMap &Opts) { + Options.store(Opts, "DelimiterStem", DelimiterStem); + Options.store(Opts, "ReplaceShorterLiterals", ReplaceShorterLiterals); } void RawStringLiteralCheck::registerMatchers(MatchFinder *Finder) { diff --git a/clang-tools-extra/clang-tidy/modernize/UseAutoCheck.cpp b/clang-tools-extra/clang-tidy/modernize/UseAutoCheck.cpp index eed9321d688c..ecdef6a1bc68 100644 --- a/clang-tools-extra/clang-tidy/modernize/UseAutoCheck.cpp +++ b/clang-tools-extra/clang-tidy/modernize/UseAutoCheck.cpp @@ -321,7 +321,7 @@ UseAutoCheck::UseAutoCheck(StringRef Name, ClangTidyContext *Context) void UseAutoCheck::storeOptions(ClangTidyOptions::OptionMap &Opts) { Options.store(Opts, "MinTypeNameLength", MinTypeNameLength); - Options.store(Opts, "RemoveStars", RemoveStars ? 1 : 0); + Options.store(Opts, "RemoveStars", RemoveStars); } void UseAutoCheck::registerMatchers(MatchFinder *Finder) { diff --git a/clang-tools-extra/clang-tidy/modernize/UseBoolLiteralsCheck.cpp b/clang-tools-extra/clang-tidy/modernize/UseBoolLiteralsCheck.cpp index 5ddda30764fc..3dab7437021b 100644 --- a/clang-tools-extra/clang-tidy/modernize/UseBoolLiteralsCheck.cpp +++ b/clang-tools-extra/clang-tidy/modernize/UseBoolLiteralsCheck.cpp @@ -22,6 +22,10 @@ UseBoolLiteralsCheck::UseBoolLiteralsCheck(StringRef Name, : ClangTidyCheck(Name, Context), IgnoreMacros(Options.getLocalOrGlobal("IgnoreMacros", true)) {} +void UseBoolLiteralsCheck::storeOptions(ClangTidyOptions::OptionMap &Opts) { + Options.store(Opts, "IgnoreMacros", IgnoreMacros); +} + void UseBoolLiteralsCheck::registerMatchers(MatchFinder *Finder) { Finder->addMatcher( traverse( diff --git a/clang-tools-extra/clang-tidy/modernize/UseBoolLiteralsCheck.h b/clang-tools-extra/clang-tidy/modernize/UseBoolLiteralsCheck.h index 8bbd739e4fa1..486635bec72c 100644 --- a/clang-tools-extra/clang-tidy/modernize/UseBoolLiteralsCheck.h +++ b/clang-tools-extra/clang-tidy/modernize/UseBoolLiteralsCheck.h @@ -25,6 +25,7 @@ class UseBoolLiteralsCheck : public ClangTidyCheck { bool isLanguageVersionSupported(const LangOptions &LangOpts) const override { return LangOpts.CPlusPlus; } + void storeOptions(ClangTidyOptions::OptionMap &Opts) override; void registerMatchers(ast_matchers::MatchFinder *Finder) override; void check(const ast_matchers::MatchFinder::MatchResult &Result) override; diff --git a/clang-tools-extra/clang-tidy/modernize/UseEmplaceCheck.cpp b/clang-tools-extra/clang-tidy/modernize/UseEmplaceCheck.cpp index 823b119dace0..77d84bd340f6 100644 --- a/clang-tools-extra/clang-tidy/modernize/UseEmplaceCheck.cpp +++ b/clang-tools-extra/clang-tidy/modernize/UseEmplaceCheck.cpp @@ -160,6 +160,7 @@ void UseEmplaceCheck::check(const MatchFinder::MatchResult &Result) { } void UseEmplaceCheck::storeOptions(ClangTidyOptions::OptionMap &Opts) { + Options.store(Opts, "IgnoreImplicitConstructors", IgnoreImplicitConstructors); Options.store(Opts, "ContainersWithPushBack", utils::options::serializeStringList(ContainersWithPushBack)); Options.store(Opts, "SmartPointers", diff --git a/clang-tools-extra/clang-tidy/modernize/UseTransparentFunctorsCheck.cpp b/clang-tools-extra/clang-tidy/modernize/UseTransparentFunctorsCheck.cpp index 6794254cd0a6..cbd11f022d59 100644 --- a/clang-tools-extra/clang-tidy/modernize/UseTransparentFunctorsCheck.cpp +++ b/clang-tools-extra/clang-tidy/modernize/UseTransparentFunctorsCheck.cpp @@ -22,7 +22,7 @@ UseTransparentFunctorsCheck::UseTransparentFunctorsCheck( void UseTransparentFunctorsCheck::storeOptions( ClangTidyOptions::OptionMap &Opts) { - Options.store(Opts, "SafeMode", SafeMode ? 1 : 0); + Options.store(Opts, "SafeMode", SafeMode); } void UseTransparentFunctorsCheck::registerMatchers(MatchFinder *Finder) { diff --git a/clang-tools-extra/clang-tidy/modernize/UseUsingCheck.cpp b/clang-tools-extra/clang-tidy/modernize/UseUsingCheck.cpp index f6dc5c044a7a..f3e8506b5513 100644 --- a/clang-tools-extra/clang-tidy/modernize/UseUsingCheck.cpp +++ b/clang-tools-extra/clang-tidy/modernize/UseUsingCheck.cpp @@ -20,6 +20,10 @@ UseUsingCheck::UseUsingCheck(StringRef Name, ClangTidyContext *Context) : ClangTidyCheck(Name, Context), IgnoreMacros(Options.getLocalOrGlobal("IgnoreMacros", true)) {} +void UseUsingCheck::storeOptions(ClangTidyOptions::OptionMap &Opts) { + Options.store(Opts, "IgnoreMacros", IgnoreMacros); +} + void UseUsingCheck::registerMatchers(MatchFinder *Finder) { Finder->addMatcher(typedefDecl(unless(isInstantiated())).bind("typedef"), this); @@ -111,7 +115,6 @@ void UseUsingCheck::check(const MatchFinder::MatchResult &Result) { std::string Replacement = Using + Name + " = " + Type; Diag << FixItHint::CreateReplacement(ReplaceRange, Replacement); } - } // namespace modernize } // namespace tidy } // namespace clang diff --git a/clang-tools-extra/clang-tidy/modernize/UseUsingCheck.h b/clang-tools-extra/clang-tidy/modernize/UseUsingCheck.h index b7fbf74997ae..f116ff2445b9 100644 --- a/clang-tools-extra/clang-tidy/modernize/UseUsingCheck.h +++ b/clang-tools-extra/clang-tidy/modernize/UseUsingCheck.h @@ -32,9 +32,7 @@ class UseUsingCheck : public ClangTidyCheck { bool isLanguageVersionSupported(const LangOptions &LangOpts) const override { return LangOpts.CPlusPlus11; } - void storeOptions(ClangTidyOptions::OptionMap &Opts) override { - Options.store(Opts, "IgnoreMacros", IgnoreMacros); - } + void storeOptions(ClangTidyOptions::OptionMap &Opts) override; void registerMatchers(ast_matchers::MatchFinder *Finder) override; void check(const ast_matchers::MatchFinder::MatchResult &Result) override; }; diff --git a/clang-tools-extra/clang-tidy/readability/MagicNumbersCheck.cpp b/clang-tools-extra/clang-tidy/readability/MagicNumbersCheck.cpp index df2229ae5f03..1cecfa31da34 100644 --- a/clang-tools-extra/clang-tidy/readability/MagicNumbersCheck.cpp +++ b/clang-tools-extra/clang-tidy/readability/MagicNumbersCheck.cpp @@ -67,11 +67,14 @@ MagicNumbersCheck::MagicNumbersCheck(StringRef Name, ClangTidyContext *Context) Options.get("IgnoreAllFloatingPointValues", false)), IgnoreBitFieldsWidths(Options.get("IgnoreBitFieldsWidths", true)), IgnorePowersOf2IntegerValues( - Options.get("IgnorePowersOf2IntegerValues", false)) { + Options.get("IgnorePowersOf2IntegerValues", false)), + RawIgnoredIntegerValues( + Options.get("IgnoredIntegerValues", DefaultIgnoredIntegerValues)), + RawIgnoredFloatingPointValues(Options.get( + "IgnoredFloatingPointValues", DefaultIgnoredFloatingPointValues)) { // Process the set of ignored integer values. const std::vector<std::string> IgnoredIntegerValuesInput = - utils::options::parseStringList( - Options.get("IgnoredIntegerValues", DefaultIgnoredIntegerValues)); + utils::options::parseStringList(RawIgnoredIntegerValues); IgnoredIntegerValues.resize(IgnoredIntegerValuesInput.size()); llvm::transform(IgnoredIntegerValuesInput, IgnoredIntegerValues.begin(), [](const std::string &Value) { return std::stoll(Value); }); @@ -80,8 +83,7 @@ MagicNumbersCheck::MagicNumbersCheck(StringRef Name, ClangTidyContext *Context) if (!IgnoreAllFloatingPointValues) { // Process the set of ignored floating point values. const std::vector<std::string> IgnoredFloatingPointValuesInput = - utils::options::parseStringList(Options.get( - "IgnoredFloatingPointValues", DefaultIgnoredFloatingPointValues)); + utils::options::parseStringList(RawIgnoredFloatingPointValues); IgnoredFloatingPointValues.reserve(IgnoredFloatingPointValuesInput.size()); IgnoredDoublePointValues.reserve(IgnoredFloatingPointValuesInput.size()); for (const auto &InputValue : IgnoredFloatingPointValuesInput) { @@ -107,9 +109,14 @@ MagicNumbersCheck::MagicNumbersCheck(StringRef Name, ClangTidyContext *Context) } void MagicNumbersCheck::storeOptions(ClangTidyOptions::OptionMap &Opts) { - Options.store(Opts, "IgnoredIntegerValues", DefaultIgnoredIntegerValues); + Options.store(Opts, "IgnoreAllFloatingPointValues", + IgnoreAllFloatingPointValues); + Options.store(Opts, "IgnoreBitFieldsWidths", IgnoreBitFieldsWidths); + Options.store(Opts, "IgnorePowersOf2IntegerValues", + IgnorePowersOf2IntegerValues); + Options.store(Opts, "IgnoredIntegerValues", RawIgnoredIntegerValues); Options.store(Opts, "IgnoredFloatingPointValues", - DefaultIgnoredFloatingPointValues); + RawIgnoredFloatingPointValues); } void MagicNumbersCheck::registerMatchers(MatchFinder *Finder) { diff --git a/clang-tools-extra/clang-tidy/readability/MagicNumbersCheck.h b/clang-tools-extra/clang-tidy/readability/MagicNumbersCheck.h index 0cf7419d703c..a53fa917066e 100644 --- a/clang-tools-extra/clang-tidy/readability/MagicNumbersCheck.h +++ b/clang-tools-extra/clang-tidy/readability/MagicNumbersCheck.h @@ -86,6 +86,8 @@ class MagicNumbersCheck : public ClangTidyCheck { const bool IgnoreAllFloatingPointValues; const bool IgnoreBitFieldsWidths; const bool IgnorePowersOf2IntegerValues; + const std::string RawIgnoredIntegerValues; + const std::string RawIgnoredFloatingPointValues; constexpr static unsigned SensibleNumberOfMagicValueExceptions = 16; diff --git a/clang-tools-extra/clang-tidy/readability/RedundantDeclarationCheck.cpp b/clang-tools-extra/clang-tidy/readability/RedundantDeclarationCheck.cpp index ab2e15b07237..f673dad9ed06 100644 --- a/clang-tools-extra/clang-tidy/readability/RedundantDeclarationCheck.cpp +++ b/clang-tools-extra/clang-tidy/readability/RedundantDeclarationCheck.cpp @@ -26,6 +26,11 @@ RedundantDeclarationCheck::RedundantDeclarationCheck(StringRef Name, : ClangTidyCheck(Name, Context), IgnoreMacros(Options.getLocalOrGlobal("IgnoreMacros", true)) {} +void RedundantDeclarationCheck::storeOptions( + ClangTidyOptions::OptionMap &Opts) { + Options.store(Opts, "IgnoreMacros", IgnoreMacros); +} + void RedundantDeclarationCheck::registerMatchers(MatchFinder *Finder) { Finder->addMatcher( namedDecl(anyOf(varDecl(unless(isDefinition())), @@ -81,7 +86,6 @@ void RedundantDeclarationCheck::check(const MatchFinder::MatchResult &Result) { } diag(Prev->getLocation(), "previously declared here", DiagnosticIDs::Note); } - } // namespace readability } // namespace tidy } // namespace clang diff --git a/clang-tools-extra/clang-tidy/readability/RedundantDeclarationCheck.h b/clang-tools-extra/clang-tidy/readability/RedundantDeclarationCheck.h index fbd05396dffe..4b4b2a1afa7f 100644 --- a/clang-tools-extra/clang-tidy/readability/RedundantDeclarationCheck.h +++ b/clang-tools-extra/clang-tidy/readability/RedundantDeclarationCheck.h @@ -22,6 +22,7 @@ namespace readability { class RedundantDeclarationCheck : public ClangTidyCheck { public: RedundantDeclarationCheck(StringRef Name, ClangTidyContext *Context); + void storeOptions(ClangTidyOptions::OptionMap &Opts) override; void registerMatchers(ast_matchers::MatchFinder *Finder) override; void check(const ast_matchers::MatchFinder::MatchResult &Result) override; diff --git a/clang-tools-extra/clang-tidy/readability/StaticAccessedThroughInstanceCheck.h b/clang-tools-extra/clang-tidy/readability/StaticAccessedThroughInstanceCheck.h index 42f837952610..d12e8211651f 100644 --- a/clang-tools-extra/clang-tidy/readability/StaticAccessedThroughInstanceCheck.h +++ b/clang-tools-extra/clang-tidy/readability/StaticAccessedThroughInstanceCheck.h @@ -25,7 +25,7 @@ class StaticAccessedThroughInstanceCheck : public ClangTidyCheck { StaticAccessedThroughInstanceCheck(StringRef Name, ClangTidyContext *Context) : ClangTidyCheck(Name, Context), NameSpecifierNestingThreshold( - Options.get("NameSpecifierNestingThreshold", 3)) {} + Options.get("NameSpecifierNestingThreshold", 3U)) {} void storeOptions(ClangTidyOptions::OptionMap &Opts) override; void registerMatchers(ast_matchers::MatchFinder *Finder) override; diff --git a/clang-tools-extra/clang-tidy/utils/HeaderGuard.cpp b/clang-tools-extra/clang-tidy/utils/HeaderGuard.cpp index 1426fca808b1..68bb987c1275 100644 --- a/clang-tools-extra/clang-tidy/utils/HeaderGuard.cpp +++ b/clang-tools-extra/clang-tidy/utils/HeaderGuard.cpp @@ -266,6 +266,10 @@ class HeaderGuardPPCallbacks : public PPCallbacks { }; } // namespace +void HeaderGuardCheck::storeOptions(ClangTidyOptions::OptionMap &Opts) { + Options.store(Opts, "HeaderFileExtensions", RawStringHeaderFileExtensions); +} + void HeaderGuardCheck::registerPPCallbacks(const SourceManager &SM, Preprocessor *PP, Preprocessor *ModuleExpanderPP) { @@ -285,7 +289,6 @@ bool HeaderGuardCheck::shouldSuggestToAddHeaderGuard(StringRef FileName) { std::string HeaderGuardCheck::formatEndIf(StringRef HeaderGuard) { return "endif // " + HeaderGuard.str(); } - } // namespace utils } // namespace tidy } // namespace clang diff --git a/clang-tools-extra/clang-tidy/utils/HeaderGuard.h b/clang-tools-extra/clang-tidy/utils/HeaderGuard.h index 7ce54f42865d..d3e09a32b687 100644 --- a/clang-tools-extra/clang-tidy/utils/HeaderGuard.h +++ b/clang-tools-extra/clang-tidy/utils/HeaderGuard.h @@ -34,6 +34,7 @@ class HeaderGuardCheck : public ClangTidyCheck { HeaderFileExtensions, utils::defaultFileExtensionDelimiters()); } + void storeOptions(ClangTidyOptions::OptionMap &Opts) override; void registerPPCallbacks(const SourceManager &SM, Preprocessor *PP, Preprocessor *ModuleExpanderPP) override; _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits