[PATCH] [clang-tidy] Add support for boolean check options.

Manuel Klimek klimek at google.com
Mon Oct 6 10:21:29 PDT 2014


================
Comment at: clang-tidy/ClangTidy.h:68-80
@@ -67,1 +67,15 @@
 
+  /// \brief Read a named option from the \c Context and parse it as bool.
+  ///
+  /// Reads the option with the check-local name \p LocalName from the
+  /// \c CheckOptions. If the corresponding key is not present, returns
+  /// \p Default.
+  bool get(StringRef LocalName, bool Default) const {
+    std::string Value = get(LocalName, "");
+    if (Value == "true")
+      return true;
+    if (Value == "false")
+      return false;
+    return Default;
+  }
+
----------------
alexfh wrote:
> klimek wrote:
> > Why do we want unknown values to give Default? If we do, we should put it into the comments; can we rather make them given an error while parsing, and then do:
> > return get(LocalName, Default ? "true" : "false") == "true";
> We can't error out early enough as check options are parsed after the configuration is read. So I don't currently see a better way than to fall back to default.
Fall back to false?

http://reviews.llvm.org/D5602






More information about the cfe-commits mailing list