8000 [lldb] add has methods to all DemangledNameInfo attributes (#144549) · charles-zablit/llvm-project@d0b010d · GitHub 8000
[go: up one dir, main page]

Skip to content

Commit d0b010d

Browse files
[lldb] add has methods to all DemangledNameInfo attributes (llvm#144549)
Add `hasX` methods to all the attributes of `DemangledNameInfo`.
1 parent 3549481 commit d0b010d

File tree

2 files changed

+95
-0
lines changed

2 files changed

+95
-0
lines changed

lldb/include/lldb/Core/DemangledNameInfo.h

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,25 @@ struct DemangledNameInfo {
7373
bool hasBasename() const {
7474
return BasenameRange.second > BasenameRange.first;
7575
}
76+
77+
/// Returns \c true if this object holds a valid scope range.
78+
bool hasScope() const { return ScopeRange.second > ScopeRange.first; }
79+
80+
/// Returns \c true if this object holds a valid arguments range.
81+
bool hasArguments() const {
82+
return ArgumentsRange.second > ArgumentsRange.first;
83+
}
84+
85+
/// Returns \c true if this object holds a valid qualifiers range.
86+
bool hasQualifiers() const {
87+
return QualifiersRange.second > QualifiersRange.first;
88+
}
89+
90+
/// Returns \c true if this object holds a valid prefix range.
91+
bool hasPrefix() const { return PrefixRange.second > PrefixRange.first; }
92+
93+
/// Returns \c true if this object holds a valid suffix range.
94+
bool hasSuffix() const { return SuffixRange.second > SuffixRange.first; }
7695
};
7796

7897
/// An OutputBuffer which keeps a record of where certain parts of a

lldb/unittests/Core/MangledTest.cpp

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -611,3 +611,79 @@ TEST_P(DemanglingPartsTestFixture, DemanglingParts) {
611611

612612
INSTANTIATE_TEST_SUITE_P(DemanglingPartsTests, DemanglingPartsTestFixture,
613613
::testing::ValuesIn(g_demangling_parts_test_cases));
614+
615+
struct DemangledNameInfoTestCase {
616+
DemangledNameInfo expected_info;
617+
bool valid_basename;
618+
bool valid_scope;
619+
bool valid_arguments;
620+
bool valid_qualifiers;
621+
bool valid_prefix;
622+
bool valid_suffix;
623+
};
624+
625+
DemangledNameInfoTestCase g_demangled_name_info_test_cases[] = {
626+
// clang-format off
627+
{
628+
{ /*.BasenameRange=*/{0, 10}, /*.ScopeRange=*/{0, 0}, /*.ArgumentsRange=*/{0, 0},
629+
/*.QualifiersRange=*/{0, 0}, /*.PrefixRange=*/{0, 0}, /*.SuffixRange=*/{0, 0}
630+
},
631+
/*valid_basename=*/true, /*valid_scope=*/false, /*valid_arguments=*/false,
632+
/*valid_qualifiers=*/false, /*valid_prefix=*/false, /*valid_suffix=*/false,
633+
},
634+
{
635+
{ /*.BasenameRange=*/{0, 0}, /*.ScopeRange=*/{0, 10}, /*.ArgumentsRange=*/{0, 0},
636+
/*.QualifiersRange=*/{0, 0}, /*.PrefixRange=*/{0, 0}, /*.SuffixRange=*/{0, 0}
637+
},
638+
/*valid_basename=*/false, /*valid_scope=*/true, /*valid_arguments=*/false,
639+
/*valid_qualifiers=*/false, /*valid_prefix=*/false, /*valid_suffix=*/false,
640+
},
641+
{
642+
{ /*.BasenameRange=*/{0, 0}, /*.ScopeRange=*/{0, 0}, /*.ArgumentsRange=*/{0, 10},
643+
/*.QualifiersRange=*/{0, 0}, /*.PrefixRange=*/{0, 0}, /*.SuffixRange=*/{0, 0}
644+
},
645+
/*valid_basename=*/false, /*valid_scope=*/false, /*valid_arguments=*/true,
646+
/*valid_qualifiers=*/false, /*valid_prefix=*/false, /*valid_suffix=*/false,
647+
},
648+
{
649+
{ /*.BasenameRange=*/{0, 0}, /*.ScopeRange=*/{0, 0}, /*.ArgumentsRange=*/{0, 0},
650+
/*.QualifiersRange=*/{0, 10}, /*.PrefixRange=*/{0, 0}, /*.SuffixRange=*/{0, 0}
651+
},
652+
/*valid_basename=*/false, /*valid_scope=*/false, /*valid_arguments=*/false,
653+
/*valid_qualifiers=*/true, /*valid_prefix=*/false, /*valid_suffix=*/false,
654+
},
655+
{
656+
{ /*.BasenameRange=*/{0, 0}, /*.ScopeRange=*/{0, 0}, /*.ArgumentsRange=*/{0, 0},
657+
/*.QualifiersRange=*/{0, 0}, /*.PrefixRange=*/{0, 10}, /*.SuffixRange=*/{0, 0}
658+
},
659+
/*valid_basename=*/false, /*valid_scope=*/false, /*valid_arguments=*/false,
660+
/*valid_qualifiers=*/false, /*valid_prefix=*/true, /*valid_suffix=*/false,
661+
},
662+
{
663+
{ /*.BasenameRange=*/{0, 0}, /*.ScopeRange=*/{0, 0}, /*.ArgumentsRange=*/{0, 0},
664+
/*.QualifiersRange=*/{0, 0}, /*.PrefixRange=*/{0, 0}, /*.SuffixRange=*/{0, 10}
665+
},
666+
/*valid_basename=*/false, /*valid_scope=*/false, /*valid_arguments=*/false,
667+
/*valid_qualifiers=*/false, /*valid_prefix=*/false, /*valid_suffix=*/true,
668+
},
669+
// clang-format on
670+
};
671+
672+
struct DemangledNameInfoTestFixture
673+
: public ::testing::TestWithParam<DemangledNameInfoTestCase> {};
674+
675+
TEST_P(DemangledNameInfoTestFixture, DemangledNameInfoRanges) {
676+
const auto &[info, valid_basename, valid_scope, valid_arguments,
677+
valid_qualifiers, valid_prefix, valid_suffix] = GetParam();
678+
679+
ASSERT_EQ(info.hasBasename(), valid_basename);
680+
ASSERT_EQ(info.hasScope(), valid_scope);
681+
ASSERT_EQ(info.hasArguments(), valid_arguments);
682+< 59FA div class="diff-text-inner"> ASSERT_EQ(info.hasQualifiers(), valid_qualifiers);
683+
ASSERT_EQ(info.hasPrefix(), valid_prefix);
684+
ASSERT_EQ(info.hasSuffix(), valid_suffix);
685+
}
686+
687+
INSTANTIATE_TEST_SUITE_P(DemangledNameInfoRangesTests,
688+
DemangledNameInfoTestFixture,
689+
::testing::ValuesIn(g_demangled_name_info_test_cases));

0 commit comments

Comments
 (0)
0