Skip to content

Commit b5cf8b2

Browse files
committed
Update code to match changes in the recently committed DILLexer.
Changed method names, class names, arguments, etc. Also small cleanups in header files (include-stmt ordering, namespaces, etc.).
1 parent fe8c0bf commit b5cf8b2

File tree

7 files changed

+88
-110
lines changed

7 files changed

+88
-110
lines changed

lldb/include/lldb/ValueObject/DILAST.h

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,7 @@
1212
#include "lldb/ValueObject/ValueObject.h"
1313
#include <string>
1414

15-
namespace lldb_private {
16-
17-
namespace dil {
15+
namespace lldb_private::dil {
1816

1917
/// The various types DIL AST nodes (used by the DIL parser).
2018
enum class NodeKind {
@@ -98,8 +96,6 @@ class Visitor {
9896
Visit(const IdentifierNode *node) = 0;
9997
};
10098

101-
} // namespace dil
102-
103-
} // namespace lldb_private
99+
} // namespace lldb_private::dil
104100

105101
#endif // LLDB_VALUEOBJECT_DILAST_H

lldb/include/lldb/ValueObject/DILEval.h

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,15 @@
66
//
77
//===----------------------------------------------------------------------===//
88

9-
#ifndef LLDB_VALUEOBJECT_DILEVAL_H_
10-
#define LLDB_VALUEOBJECT_DILEVAL_H_
9+
#ifndef LLDB_VALUEOBJECT_DILEVAL_H
10+
#define LLDB_VALUEOBJECT_DILEVAL_H
1111

1212
#include "lldb/ValueObject/DILAST.h"
1313
#include "lldb/ValueObject/DILParser.h"
1414
#include <memory>
1515
#include <vector>
1616

17-
namespace lldb_private {
18-
19-
namespace dil {
17+
namespace lldb_private::dil {
2018

2119
/// Class used to store & manipulate information about identifiers.
2220
class IdentifierInfo {
@@ -89,8 +87,6 @@ class DILInterpreter : Visitor {
8987
std::shared_ptr<ExecutionContextScope> m_exe_ctx_scope;
9088
};
9189

92-
} // namespace dil
93-
94-
} // namespace lldb_private
90+
} // namespace lldb_private::dil
9591

96-
#endif // LLDB_VALUEOBJECT_DILEVAL_H_
92+
#endif // LLDB_VALUEOBJECT_DILEVAL_H

lldb/include/lldb/ValueObject/DILParser.h

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
//
77
//===----------------------------------------------------------------------===//
88

9-
#ifndef LLDB_VALUEOBJECT_DILPARSER_H_
10-
#define LLDB_VALUEOBJECT_DILPARSER_H_
9+
#ifndef LLDB_VALUEOBJECT_DILPARSER_H
10+
#define LLDB_VALUEOBJECT_DILPARSER_H
1111

1212
#include "lldb/Target/ExecutionContextScope.h"
1313
#include "lldb/Utility/Status.h"
@@ -19,9 +19,7 @@
1919
#include <tuple>
2020
#include <vector>
2121

22-
namespace lldb_private {
23-
24-
namespace dil {
22+
namespace lldb_private::dil {
2523

2624
enum class ErrorCode : unsigned char {
2725
kOk = 0,
@@ -37,7 +35,7 @@ std::string FormatDiagnostics(llvm::StringRef input_expr,
3735
/// EBNF grammar for the parser is described in lldb/docs/dil-expr-lang.ebnf
3836
class DILParser {
3937
public:
40-
explicit DILParser(llvm::StringRef dil_input_expr,
38+
explicit DILParser(llvm::StringRef dil_input_expr, DILLexer lexer,
4139
std::shared_ptr<ExecutionContextScope> exe_ctx_scope,
4240
lldb::DynamicValueType use_dynamic, bool use_synthetic,
4341
bool fragile_ivar, bool check_ptr_vs_member);
@@ -50,7 +48,7 @@ class DILParser {
5048

5149
lldb::DynamicValueType UseDynamic() { return m_use_dynamic; }
5250

53-
using PtrOperator = std::tuple<dil::TokenKind, uint32_t>;
51+
using PtrOperator = std::tuple<Token::Kind, uint32_t>;
5452

5553
private:
5654
DILASTNodeUP ParseExpression();
@@ -67,9 +65,9 @@ class DILParser {
6765

6866
void BailOut(Status error);
6967

70-
void Expect(dil::TokenKind kind);
68+
void Expect(Token::Kind kind);
7169

72-
std::string TokenDescription(const DILToken &token);
70+
std::string TokenDescription(const Token &token);
7371

7472
void TentativeParsingRollback(uint32_t saved_idx) {
7573
m_error.Clear();
@@ -83,20 +81,19 @@ class DILParser {
8381
std::shared_ptr<ExecutionContextScope> m_ctx_scope;
8482

8583
llvm::StringRef m_input_expr;
84+
85+
DILLexer m_dil_lexer;
8686
// The token lexer is stopped at (aka "current token").
87-
DILToken m_dil_token;
87+
Token m_dil_token;
8888
// Holds an error if it occures during parsing.
8989
Status m_error;
9090

9191
lldb::DynamicValueType m_use_dynamic;
9292
bool m_use_synthetic;
9393
bool m_fragile_ivar;
9494
bool m_check_ptr_vs_member;
95-
DILLexer m_dil_lexer;
9695
}; // class DILParser
9796

98-
} // namespace dil
99-
100-
} // namespace lldb_private
97+
} // namespace lldb_private::dil
10198

102-
#endif // LLDB_VALUEOBJECT_DILPARSER_H_
99+
#endif // LLDB_VALUEOBJECT_DILPARSER_H

lldb/source/Target/StackFrame.cpp

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
#include "lldb/Utility/Log.h"
3333
#include "lldb/Utility/RegisterValue.h"
3434
#include "lldb/ValueObject/DILEval.h"
35+
#include "lldb/ValueObject/DILLexer.h"
3536
#include "lldb/ValueObject/DILParser.h"
3637
#include "lldb/ValueObject/ValueObjectConstResult.h"
3738
#include "lldb/ValueObject/ValueObjectMemory.h"
@@ -535,8 +536,16 @@ ValueObjectSP StackFrame::DILGetValueForVariableExpressionPath(
535536
const bool no_synth_child =
536537
(options & eExpressionPathOptionsNoSyntheticChildren) != 0;
537538

539+
// Lex the expression.
540+
auto lex_or_err = dil::DILLexer::Create(var_expr);
541+
if (!lex_or_err) {
542+
error = Status::FromError(lex_or_err.takeError());
543+
return ValueObjectSP();
544+
}
545+
dil::DILLexer lexer = *lex_or_err;
546+
538547
// Parse the expression.
539-
dil::DILParser parser(var_expr, shared_from_this(), use_dynamic,
548+
dil::DILParser parser(var_expr, lexer, shared_from_this(), use_dynamic,
540549
!no_synth_child, !no_fragile_ivar, check_ptr_vs_member);
541550
auto tree_or_error = parser.Run();
542551
if (!tree_or_error) {

lldb/source/ValueObject/DILAST.cpp

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,7 @@
88

99
#include "lldb/ValueObject/DILAST.h"
1010

11-
namespace lldb_private {
12-
13-
namespace dil {
11+
namespace lldb_private::dil {
1412

1513
llvm::Expected<lldb::ValueObjectSP> ErrorNode::Accept(Visitor *v) const {
1614
return v->Visit(this);
@@ -20,6 +18,4 @@ llvm::Expected<lldb::ValueObjectSP> IdentifierNode::Accept(Visitor *v) const {
2018
return v->Visit(this);
2119
}
2220

23-
} // namespace dil
24-
25-
} // namespace lldb_private
21+
} // namespace lldb_private::dil

lldb/source/ValueObject/DILEval.cpp

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,7 @@
1616
#include "llvm/Support/FormatAdapters.h"
1717
#include <memory>
1818

19-
namespace lldb_private {
20-
21-
namespace dil {
19+
namespace lldb_private::dil {
2220

2321
static lldb::ValueObjectSP
2422
LookupStaticIdentifier(lldb::TargetSP target_sp,
@@ -283,6 +281,4 @@ DILInterpreter::Visit(const IdentifierNode *node) {
283281
return val;
284282
}
285283

286-
} // namespace dil
287-
288-
} // namespace lldb_private
284+
} // namespace lldb_private::dil

0 commit comments

Comments
 (0)