Skip to content

Commit 95d3950

Browse files
committed
Rename getters, refactor number lexing and remove '_'
1 parent 54af853 commit 95d3950

File tree

4 files changed

+14
-26
lines changed

4 files changed

+14
-26
lines changed

lldb/include/lldb/ValueObject/DILAST.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -118,8 +118,8 @@ class UnaryOpNode : public ASTNode {
118118

119119
llvm::Expected<lldb::ValueObjectSP> Accept(Visitor *v) const override;
120120

121-
UnaryOpKind kind() const { return m_kind; }
122-
ASTNode *operand() const { return m_operand.get(); }
121+
UnaryOpKind GetKind() const { return m_kind; }
122+
ASTNode *GetOperand() const { return m_operand.get(); }
123123

124124
static bool classof(const ASTNode *node) {
125125
return node->GetKind() == NodeKind::eUnaryOpNode;
@@ -138,8 +138,8 @@ class ArraySubscriptNode : public ASTNode {
138138

139139
llvm::Expected<lldb::ValueObjectSP> Accept(Visitor *v) const override;
140140

141-
ASTNode *lhs() const { return m_lhs.get(); }
142-
ASTNode *rhs() const { return m_rhs.get(); }
141+
ASTNode *GetLHS() const { return m_lhs.get(); }
142+
ASTNode *GetRHS() const { return m_rhs.get(); }
143143

144144
static bool classof(const ASTNode *node) {
145145
return node->GetKind() == NodeKind::eArraySubscriptNode;

lldb/source/ValueObject/DILEval.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -276,13 +276,13 @@ Interpreter::Visit(const IdentifierNode *node) {
276276
llvm::Expected<lldb::ValueObjectSP>
277277
Interpreter::Visit(const UnaryOpNode *node) {
278278
Status error;
279-
auto rhs_or_err = Evaluate(node->operand());
279+
auto rhs_or_err = Evaluate(node->GetOperand());
280280
if (!rhs_or_err)
281281
return rhs_or_err;
282282

283283
lldb::ValueObjectSP rhs = *rhs_or_err;
284284

285-
switch (node->kind()) {
285+
switch (node->GetKind()) {
286286
case UnaryOpKind::Deref: {
287287
lldb::ValueObjectSP dynamic_rhs = rhs->GetDynamicValue(m_default_dynamic);
288288
if (dynamic_rhs)
@@ -313,12 +313,12 @@ Interpreter::Visit(const UnaryOpNode *node) {
313313

314314
llvm::Expected<lldb::ValueObjectSP>
315315
Interpreter::Visit(const ArraySubscriptNode *node) {
316-
auto lhs_or_err = Evaluate(node->lhs());
316+
auto lhs_or_err = Evaluate(node->GetLHS());
317317
if (!lhs_or_err) {
318318
return lhs_or_err;
319319
}
320320
lldb::ValueObjectSP base = *lhs_or_err;
321-
auto rhs_or_err = Evaluate(node->rhs());
321+
auto rhs_or_err = Evaluate(node->GetRHS());
322322
if (!rhs_or_err) {
323323
return rhs_or_err;
324324
}

lldb/source/ValueObject/DILLexer.cpp

Lines changed: 5 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -64,25 +64,14 @@ static std::optional<llvm::StringRef> IsWord(llvm::StringRef expr,
6464
return candidate;
6565
}
6666

67-
static void ConsumeNumberBody(char &prev_ch, llvm::StringRef::iterator &cur_pos,
68-
llvm::StringRef expr) {
69-
while (cur_pos != expr.end() &&
70-
(IsDigit(*cur_pos) || IsLetter(*cur_pos) || *cur_pos == '_')) {
71-
prev_ch = *cur_pos;
72-
cur_pos++;
73-
}
74-
}
67+
static bool IsNumberBodyChar(char ch) { return IsDigit(ch) || IsLetter(ch); }
7568

7669
static std::optional<llvm::StringRef> IsNumber(llvm::StringRef expr,
7770
llvm::StringRef &remainder) {
78-
llvm::StringRef::iterator cur_pos = remainder.begin();
79-
llvm::StringRef::iterator start = cur_pos;
80-
char prev_ch = 0;
81-
if (IsDigit(*start)) {
82-
ConsumeNumberBody(prev_ch, cur_pos, expr);
83-
llvm::StringRef number = expr.substr(start - expr.begin(), cur_pos - start);
84-
if (remainder.consume_front(number))
85-
return number;
71+
if (IsDigit(remainder[0])) {
72+
llvm::StringRef number = remainder.take_while(IsNumberBodyChar);
73+
remainder = remainder.drop_front(number.size());
74+
return number;
8675
}
8776
return std::nullopt;
8877
}

lldb/unittests/ValueObject/DILLexerTests.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -157,8 +157,7 @@ TEST(DILLexerTests, IdentifiersTest) {
157157

158158
TEST(DILLexerTests, NumbersTest) {
159159
// These strings should lex into number tokens.
160-
std::vector<std::string> valid_numbers = {"123", "0x123", "0123", "0b101",
161-
"1_000"};
160+
std::vector<std::string> valid_numbers = {"123", "0x123", "0123", "0b101"};
162161

163162
// The lexer can lex these strings, but they should not be numbers.
164163
std::vector<std::string> invalid_numbers = {"", "x123", "b123"};

0 commit comments

Comments
 (0)