diff --git a/clang-tools-extra/clang-tidy/ClangTidyCheck.cpp b/clang-tools-extra/clang-tidy/ClangTidyCheck.cpp --- a/clang-tools-extra/clang-tidy/ClangTidyCheck.cpp +++ b/clang-tools-extra/clang-tidy/ClangTidyCheck.cpp @@ -11,6 +11,7 @@ #include "llvm/ADT/StringRef.h" #include "llvm/Support/Error.h" #include "llvm/Support/WithColor.h" +#include "llvm/Support/YAMLParser.h" #include "llvm/Support/raw_ostream.h" namespace clang { @@ -101,13 +102,11 @@ static llvm::Expected getAsBool(StringRef Value, const llvm::Twine &LookupName) { - if (Value == "true") - return true; - if (Value == "false") - return false; - bool Result; - if (!Value.getAsInteger(10, Result)) - return Result; + // To maintain backwards compatability, we support parsing numbers as + // booleans, even though its not supported in YAML. + if (llvm::Optional Parsed = + llvm::yaml::parseBool(Value, /*AllowNumeric=*/true)) + return *Parsed; return llvm::make_error(LookupName.str(), Value.str(), true); } diff --git a/clang-tools-extra/docs/ReleaseNotes.rst b/clang-tools-extra/docs/ReleaseNotes.rst --- a/clang-tools-extra/docs/ReleaseNotes.rst +++ b/clang-tools-extra/docs/ReleaseNotes.rst @@ -73,6 +73,9 @@ ` and :doc:`modernize-make-unique `. +- CheckOptions that take boolean values now support all spellings supported in + the `YAML format `_. + New modules ^^^^^^^^^^^