Skip to content

Commit aaf013a

Browse files
committed
Revert "YAML: Don't parse Y/N as booleans"
This reverts commit a9f2382. Change-Id: I9e838b53d1f2374ad0721f5ee1a80e245ca7848c
1 parent 4923afb commit aaf013a

File tree

3 files changed

+19
-24
lines changed

3 files changed

+19
-24
lines changed

clang-tools-extra/unittests/clang-tidy/ClangTidyOptionsTest.cpp

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -340,9 +340,8 @@ TEST(CheckOptionsValidation, ValidIntOptions) {
340340
CheckOptions["test.BoolIFalseValue"] = "0";
341341
CheckOptions["test.BoolTrueValue"] = "true";
342342
CheckOptions["test.BoolFalseValue"] = "false";
343-
// FIXME: SWDEV-268185.
344-
// CheckOptions["test.BoolTrueShort"] = "Y";
345-
// CheckOptions["test.BoolFalseShort"] = "N";
343+
CheckOptions["test.BoolTrueShort"] = "Y";
344+
CheckOptions["test.BoolFalseShort"] = "N";
346345
CheckOptions["test.BoolUnparseable"] = "Nothing";
347346

348347
ClangTidyContext Context(std::make_unique<DefaultOptionsProvider>(
@@ -364,9 +363,8 @@ TEST(CheckOptionsValidation, ValidIntOptions) {
364363
CHECK_VAL(TestCheck.getIntLocal<bool>("BoolIFalseValue"), false);
365364
CHECK_VAL(TestCheck.getIntLocal<bool>("BoolTrueValue"), true);
366365
CHECK_VAL(TestCheck.getIntLocal<bool>("BoolFalseValue"), false);
367-
// FIXME: SWDEV-268185.
368-
// CHECK_VAL(TestCheck.getIntLocal<bool>("BoolTrueShort"), true);
369-
// CHECK_VAL(TestCheck.getIntLocal<bool>("BoolFalseShort"), false);
366+
CHECK_VAL(TestCheck.getIntLocal<bool>("BoolTrueShort"), true);
367+
CHECK_VAL(TestCheck.getIntLocal<bool>("BoolFalseShort"), false);
370368
EXPECT_FALSE(TestCheck.getIntLocal<bool>("BoolUnparseable"));
371369

372370
EXPECT_THAT(

llvm/lib/Support/YAMLParser.cpp

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -770,18 +770,17 @@ std::string yaml::escape(StringRef Input, bool EscapePrintable) {
770770

771771
std::optional<bool> yaml::parseBool(StringRef S) {
772772
switch (S.size()) {
773-
// FIXME: SWDEV-268185.
774-
// case 1:
775-
// switch (S.front()) {
776-
// case 'y':
777-
// case 'Y':
778-
// return true;
779-
// case 'n':
780-
// case 'N':
781-
// return false;
782-
// default:
783-
// return None;
784-
// }
773+
case 1:
774+
switch (S.front()) {
775+
case 'y':
776+
case 'Y':
777+
return true;
778+
case 'n':
779+
case 'N':
780+
return false;
781+
default:
782+
return std::nullopt;
783+
}
785784
case 2:
786785
switch (S.front()) {
787786
case 'O':

llvm/unittests/Support/YAMLParserTest.cpp

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -419,9 +419,8 @@ TEST(YAMLParser, ParsesBools) {
419419
expectCanParseBool("TRUE", true);
420420
expectCanParseBool("True", true);
421421
expectCanParseBool("true", true);
422-
// FIXME: SWDEV-268185.
423-
// expectCanParseBool("Y", true);
424-
// expectCanParseBool("y", true);
422+
expectCanParseBool("Y", true);
423+
expectCanParseBool("y", true);
425424
expectCanParseBool("YES", true);
426425
expectCanParseBool("Yes", true);
427426
expectCanParseBool("yes", true);
@@ -431,9 +430,8 @@ TEST(YAMLParser, ParsesBools) {
431430
expectCanParseBool("FALSE", false);
432431
expectCanParseBool("False", false);
433432
expectCanParseBool("false", false);
434-
// FIXME: SWDEV-268185.
435-
// expectCanParseBool("N", false);
436-
// expectCanParseBool("n", false);
433+
expectCanParseBool("N", false);
434+
expectCanParseBool("n", false);
437435
expectCanParseBool("NO", false);
438436
expectCanParseBool("No", false);
439437
expectCanParseBool("no", false);

0 commit comments

Comments
 (0)