Skip to content

[lldb] Store *signed* ranges in lldb_private::Block #120224

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 9, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lldb/include/lldb/Symbol/Block.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ namespace lldb_private {
/// blocks.
class Block : public UserID, public SymbolContextScope {
public:
typedef RangeVector<uint32_t, uint32_t, 1> RangeList;
typedef RangeVector<int32_t, uint32_t, 1> RangeList;
typedef RangeList::Entry Range;

// Creates a block representing the whole function. Only meant to be used from
Expand Down
23 changes: 23 additions & 0 deletions lldb/unittests/Utility/RangeMapTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,29 @@

using namespace lldb_private;

TEST(RangeVector, SignedBaseType) {
using RangeVector = RangeVector<int32_t, uint32_t>;
using Entry = RangeVector::Entry;

RangeVector V;
V.Append(10, 5);
V.Append(-3, 6);
V.Append(-10, 3);
V.Sort();
EXPECT_THAT(V,
testing::ElementsAre(Entry(-10, 3), Entry(-3, 6), Entry(10, 5)));
Entry e = *V.begin();
EXPECT_EQ(e.GetRangeBase(), -10);
EXPECT_EQ(e.GetByteSize(), 3u);
EXPECT_EQ(e.GetRangeEnd(), -7);
EXPECT_TRUE(e.Contains(-10));
EXPECT_TRUE(e.Contains(-8));
EXPECT_FALSE(e.Contains(-7));
EXPECT_TRUE(e.Union(Entry(-8, 2)));
EXPECT_EQ(e, Entry(-10, 4));
EXPECT_EQ(e.Intersect(Entry(-7, 3)), Entry(-7, 1));
}

TEST(RangeVector, CombineConsecutiveRanges) {
using RangeVector = RangeVector<uint32_t, uint32_t>;
using Entry = RangeVector::Entry;
Expand Down
Loading