Just adds the storeOptions for Checks that weren't already storing their options.
Reviewed By: aaron.ballman
Differential Revision: https://reviews.llvm.org/D82223
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) {
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(
}
}
}
-
} // namespace cppcoreguidelines
} // namespace tidy
} // namespace clang
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;
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.
return handleImplicitCast(*Result.Context, *Cast);
llvm_unreachable("must be binary operator or cast expression");
}
-
} // namespace cppcoreguidelines
} // namespace tidy
} // namespace clang
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;
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.
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;
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);
void ThrowByValueCatchByReferenceCheck::storeOptions(
ClangTidyOptions::OptionMap &Opts) {
Options.store(Opts, "CheckThrowTemporaries", true);
+ Options.store(Opts, "WarnOnLargeObjects", WarnOnLargeObject);
+ Options.store(Opts, "MaxSize", MaxSizeOptions);
}
void ThrowByValueCatchByReferenceCheck::check(
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.
};
: 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(
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;
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(),
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) {
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) {
: 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(
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;
}
void UseEmplaceCheck::storeOptions(ClangTidyOptions::OptionMap &Opts) {
+ Options.store(Opts, "IgnoreImplicitConstructors", IgnoreImplicitConstructors);
Options.store(Opts, "ContainersWithPushBack",
utils::options::serializeStringList(ContainersWithPushBack));
Options.store(Opts, "SmartPointers",
void UseTransparentFunctorsCheck::storeOptions(
ClangTidyOptions::OptionMap &Opts) {
- Options.store(Opts, "SafeMode", SafeMode ? 1 : 0);
+ Options.store(Opts, "SafeMode", SafeMode);
}
void UseTransparentFunctorsCheck::registerMatchers(MatchFinder *Finder) {
: 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);
std::string Replacement = Using + Name + " = " + Type;
Diag << FixItHint::CreateReplacement(ReplaceRange, Replacement);
}
-
} // namespace modernize
} // namespace tidy
} // namespace clang
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;
};
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); });
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) {
}
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) {
const bool IgnoreAllFloatingPointValues;
const bool IgnoreBitFieldsWidths;
const bool IgnorePowersOf2IntegerValues;
+ const std::string RawIgnoredIntegerValues;
+ const std::string RawIgnoredFloatingPointValues;
constexpr static unsigned SensibleNumberOfMagicValueExceptions = 16;
: 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())),
}
diag(Prev->getLocation(), "previously declared here", DiagnosticIDs::Note);
}
-
} // namespace readability
} // namespace tidy
} // namespace clang
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;
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;
};
} // namespace
+void HeaderGuardCheck::storeOptions(ClangTidyOptions::OptionMap &Opts) {
+ Options.store(Opts, "HeaderFileExtensions", RawStringHeaderFileExtensions);
+}
+
void HeaderGuardCheck::registerPPCallbacks(const SourceManager &SM,
Preprocessor *PP,
Preprocessor *ModuleExpanderPP) {
std::string HeaderGuardCheck::formatEndIf(StringRef HeaderGuard) {
return "endif // " + HeaderGuard.str();
}
-
} // namespace utils
} // namespace tidy
} // namespace clang
HeaderFileExtensions,
utils::defaultFileExtensionDelimiters());
}
+ void storeOptions(ClangTidyOptions::OptionMap &Opts) override;
void registerPPCallbacks(const SourceManager &SM, Preprocessor *PP,
Preprocessor *ModuleExpanderPP) override;