[clang-tidy] readability-implicit-bool-cast forgets to store its options.
authorHaojian Wu <hokein@google.com>
Tue, 16 Aug 2016 11:15:05 +0000 (11:15 +0000)
committerHaojian Wu <hokein@google.com>
Tue, 16 Aug 2016 11:15:05 +0000 (11:15 +0000)
Reviewers: alexfh

Subscribers: cfe-commits

Differential Revision: https://reviews.llvm.org/D23544

llvm-svn: 278791

clang-tools-extra/clang-tidy/readability/ImplicitBoolCastCheck.cpp
clang-tools-extra/clang-tidy/readability/ImplicitBoolCastCheck.h

index 6f80ccf..38e4098 100644 (file)
@@ -299,6 +299,22 @@ bool isAllowedConditionalCast(const ImplicitCastExpr *CastExpression,
 
 } // anonymous namespace
 
+ImplicitBoolCastCheck::ImplicitBoolCastCheck(StringRef Name,
+                                             ClangTidyContext *Context)
+    : ClangTidyCheck(Name, Context),
+      AllowConditionalIntegerCasts(
+          Options.get("AllowConditionalIntegerCasts", false)),
+      AllowConditionalPointerCasts(
+          Options.get("AllowConditionalPointerCasts", false)) {}
+
+void ImplicitBoolCastCheck::storeOptions(
+    ClangTidyOptions::OptionMap &Opts) {
+  Options.store(Opts, "AllowConditionalIntegerCasts",
+                AllowConditionalIntegerCasts);
+  Options.store(Opts, "AllowConditionalPointerCasts",
+                AllowConditionalPointerCasts);
+}
+
 void ImplicitBoolCastCheck::registerMatchers(MatchFinder *Finder) {
   // This check doesn't make much sense if we run it on language without
   // built-in bool support.
index e9fa480..cd8addf 100644 (file)
@@ -22,12 +22,9 @@ namespace readability {
 /// http://clang.llvm.org/extra/clang-tidy/checks/readability-implicit-bool-cast.html
 class ImplicitBoolCastCheck : public ClangTidyCheck {
 public:
-  ImplicitBoolCastCheck(StringRef Name, ClangTidyContext *Context)
-      : ClangTidyCheck(Name, Context),
-        AllowConditionalIntegerCasts(
-            Options.get("AllowConditionalIntegerCasts", 0) != 0),
-        AllowConditionalPointerCasts(
-            Options.get("AllowConditionalPointerCasts", 0) != 0) {}
+  ImplicitBoolCastCheck(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;