Skip to content

Commit cd9dfc6

Browse files
committed
Code cleanup
1 parent 6a06470 commit cd9dfc6

File tree

7 files changed

+12
-13
lines changed

7 files changed

+12
-13
lines changed

lldb/docs/dil-expr-lang.ebnf

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@ postfix_expression = primary_expression
1515
| postfix_expression "." id_expression
1616
| postfix_expression "->" id_expression ;
1717
18-
primary_expression = id_expression
18+
primary_expression = numeric_literal
19+
| id_expression
1920
| "(" expression ")" ;
2021
2122
id_expression = unqualified_id

lldb/include/lldb/ValueObject/DILLexer.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ class Token {
2828
arrow,
2929
coloncolon,
3030
eof,
31-
floating_constant,
31+
float_constant,
3232
identifier,
3333
integer_constant,
3434
l_paren,

lldb/source/ValueObject/DILEval.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -512,11 +512,9 @@ GetTypeSystemFromCU(std::shared_ptr<StackFrame> ctx) {
512512
static CompilerType GetBasicType(lldb::TypeSystemSP type_system,
513513
lldb::BasicType basic_type) {
514514
if (type_system)
515-
if (auto compiler_type = type_system.get()->GetBasicTypeFromAST(basic_type))
516-
return compiler_type;
515+
return type_system.get()->GetBasicTypeFromAST(basic_type);
517516

518-
CompilerType empty_type;
519-
return empty_type;
517+
return CompilerType();
520518
}
521519

522520
llvm::Expected<CompilerType>

lldb/source/ValueObject/DILLexer.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@ llvm::StringRef Token::GetTokenName(Kind kind) {
2828
return "coloncolon";
2929
case Kind::eof:
3030
return "eof";
31-
case Kind::floating_constant:
32-
return "floating_constant";
31+
case Kind::float_constant:
32+
return "float_constant";
3333
case Kind::identifier:
3434
return "identifier";
3535
case Kind::integer_constant:
@@ -133,7 +133,7 @@ llvm::Expected<Token> DILLexer::Lex(llvm::StringRef expr,
133133
bool isFloat = false;
134134
std::optional<llvm::StringRef> maybe_number = IsNumber(remainder, isFloat);
135135
if (maybe_number) {
136-
auto kind = isFloat ? Token::floating_constant : Token::integer_constant;
136+
auto kind = isFloat ? Token::float_constant : Token::integer_constant;
137137
return Token(kind, maybe_number->str(), position);
138138
}
139139
std::optional<llvm::StringRef> maybe_word = IsWord(expr, remainder);

lldb/source/ValueObject/DILParser.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ ASTNodeUP DILParser::ParsePostfixExpression() {
184184
// "(" expression ")"
185185
//
186186
ASTNodeUP DILParser::ParsePrimaryExpression() {
187-
if (CurToken().IsOneOf({Token::integer_constant, Token::floating_constant}))
187+
if (CurToken().IsOneOf({Token::integer_constant, Token::float_constant}))
188188
return ParseNumericLiteral();
189189
if (CurToken().IsOneOf(
190190
{Token::coloncolon, Token::identifier, Token::l_paren})) {

lldb/test/API/commands/frame/var-dil/basics/ArraySubscript/TestFrameVarDILArraySubscript.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ def test_subscript(self):
6666
self.expect(
6767
"frame var 'int_arr[1.0]'",
6868
error=True,
69-
substrs=["failed to parse integer constant: <'1.0' (floating_constant)>"],
69+
substrs=["failed to parse integer constant: <'1.0' (float_constant)>"],
7070
)
7171

7272
# Test accessing bits in scalar types.

lldb/unittests/ValueObject/DILLexerTests.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ TEST(DILLexerTests, NumbersTest) {
176176
SCOPED_TRACE(str);
177177
EXPECT_THAT_EXPECTED(ExtractTokenData(str),
178178
llvm::HasValue(testing::ElementsAre(
179-
testing::Pair(Token::floating_constant, str))));
179+
testing::Pair(Token::float_constant, str))));
180180
}
181181
// Verify that none of the invalid numbers come out as numeric tokens.
182182
for (auto &str : invalid_numbers) {
@@ -200,7 +200,7 @@ TEST(DILLexerTests, NumbersTest) {
200200
DILLexer lexer(*maybe_lexer);
201201
Token token = lexer.GetCurrentToken();
202202
EXPECT_TRUE(
203-
token.IsOneOf({Token::integer_constant, Token::floating_constant}));
203+
token.IsOneOf({Token::integer_constant, Token::float_constant}));
204204
lexer.Advance();
205205
token = lexer.GetCurrentToken();
206206
EXPECT_TRUE(token.IsOneOf({Token::plus, Token::minus}));

0 commit comments

Comments
 (0)