LLDB mainline
DILEval.h
Go to the documentation of this file.
1//===-- DILEval.h -----------------------------------------------*- C++ -*-===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
9#ifndef LLDB_VALUEOBJECT_DILEVAL_H
10#define LLDB_VALUEOBJECT_DILEVAL_H
11
14#include "llvm/ADT/StringRef.h"
15#include "llvm/Support/Error.h"
16#include <memory>
17#include <vector>
18
19namespace lldb_private::dil {
20
21/// Given the name of an identifier (variable name, member name, type name,
22/// etc.), find the ValueObject for that name (if it exists), excluding global
23/// variables, and create and return an IdentifierInfo object containing all
24/// the relevant information about that object (for DIL parsing and
25/// evaluating).
26lldb::ValueObjectSP LookupIdentifier(llvm::StringRef name_ref,
27 std::shared_ptr<StackFrame> frame_sp,
28 lldb::DynamicValueType use_dynamic);
29
30/// Given the name of an identifier, check to see if it matches the name of a
31/// global variable. If so, find the ValueObject for that global variable, and
32/// create and return an IdentifierInfo object containing all the relevant
33/// informatin about it.
34lldb::ValueObjectSP LookupGlobalIdentifier(llvm::StringRef name_ref,
35 std::shared_ptr<StackFrame> frame_sp,
36 lldb::TargetSP target_sp,
37 lldb::DynamicValueType use_dynamic);
38
40public:
41 Interpreter(lldb::TargetSP target, llvm::StringRef expr,
42 std::shared_ptr<StackFrame> frame_sp,
43 lldb::DynamicValueType use_dynamic, bool use_synthetic,
44 bool fragile_ivar, bool check_ptr_vs_member);
45
46 /// Evaluate an ASTNode.
47 /// \returns A non-null lldb::ValueObjectSP or an Error.
48 llvm::Expected<lldb::ValueObjectSP> Evaluate(const ASTNode &node);
49
50private:
51 /// Evaluate an ASTNode. If the result is a reference, it is also
52 /// dereferenced using ValueObject::Dereference.
53 /// \returns A non-null lldb::ValueObjectSP or an Error.
54 llvm::Expected<lldb::ValueObjectSP>
56 llvm::Expected<lldb::ValueObjectSP>
57 Visit(const IdentifierNode &node) override;
58 llvm::Expected<lldb::ValueObjectSP> Visit(const MemberOfNode &node) override;
59 llvm::Expected<lldb::ValueObjectSP> Visit(const UnaryOpNode &node) override;
60 llvm::Expected<lldb::ValueObjectSP>
61 Visit(const ArraySubscriptNode &node) override;
62 llvm::Expected<lldb::ValueObjectSP>
63 Visit(const BitFieldExtractionNode &node) override;
64 llvm::Expected<lldb::ValueObjectSP>
65 Visit(const IntegerLiteralNode &node) override;
66 llvm::Expected<lldb::ValueObjectSP>
67 Visit(const FloatLiteralNode &node) override;
68 llvm::Expected<lldb::ValueObjectSP>
69 Visit(const BooleanLiteralNode &node) override;
70 llvm::Expected<lldb::ValueObjectSP> Visit(const CastNode &node) override;
71
72 /// Perform usual unary conversions on a value. At the moment this
73 /// includes array-to-pointer and integral promotion for eligible types.
74 llvm::Expected<lldb::ValueObjectSP>
75 UnaryConversion(lldb::ValueObjectSP valobj, uint32_t location);
76 llvm::Expected<CompilerType>
78 std::shared_ptr<ExecutionContextScope> ctx,
79 const IntegerLiteralNode &literal);
80
81 /// A helper function for VerifyCastType (below). This performs
82 /// arithmetic-specific checks. It should only be called if the target_type
83 /// is a scalar type.
84 llvm::Expected<CastKind> VerifyArithmeticCast(CompilerType source_type,
85 CompilerType target_type,
86 int location);
87
88 /// As a preparation for type casting, compare the requested 'target' type
89 /// of the cast with the type of the operand to be cast. If the cast is
90 /// allowed, return the appropriate CastKind for the cast; otherwise return
91 /// an error.
92 llvm::Expected<CastKind> VerifyCastType(lldb::ValueObjectSP operand,
93 CompilerType source_type,
94 CompilerType target_type,
95 int location);
96
97 // Used by the interpreter to create objects, perform casts, etc.
99 llvm::StringRef m_expr;
101 std::shared_ptr<StackFrame> m_exe_ctx_scope;
106};
107
108} // namespace lldb_private::dil
109
110#endif // LLDB_VALUEOBJECT_DILEVAL_H
Generic representation of a type in a programming language.
The rest of the classes in this file, except for the Visitor class at the very end,...
Definition DILAST.h:63
std::shared_ptr< StackFrame > m_exe_ctx_scope
Definition DILEval.h:101
llvm::Expected< lldb::ValueObjectSP > Evaluate(const ASTNode &node)
Evaluate an ASTNode.
Definition DILEval.cpp:265
llvm::Expected< lldb::ValueObjectSP > EvaluateAndDereference(const ASTNode &node)
Evaluate an ASTNode.
Definition DILEval.cpp:278
Interpreter(lldb::TargetSP target, llvm::StringRef expr, std::shared_ptr< StackFrame > frame_sp, lldb::DynamicValueType use_dynamic, bool use_synthetic, bool fragile_ivar, bool check_ptr_vs_member)
Definition DILEval.cpp:256
llvm::Expected< lldb::ValueObjectSP > UnaryConversion(lldb::ValueObjectSP valobj, uint32_t location)
Perform usual unary conversions on a value.
Definition DILEval.cpp:80
llvm::Expected< lldb::ValueObjectSP > Visit(const IdentifierNode &node) override
Definition DILEval.cpp:294
lldb::ValueObjectSP m_scope
Definition DILEval.h:100
llvm::Expected< CompilerType > PickIntegerType(lldb::TypeSystemSP type_system, std::shared_ptr< ExecutionContextScope > ctx, const IntegerLiteralNode &literal)
Definition DILEval.cpp:719
lldb::DynamicValueType m_use_dynamic
Definition DILEval.h:102
llvm::Expected< CastKind > VerifyCastType(lldb::ValueObjectSP operand, CompilerType source_type, CompilerType target_type, int location)
As a preparation for type casting, compare the requested 'target' type of the cast with the type of t...
Definition DILEval.cpp:873
llvm::Expected< CastKind > VerifyArithmeticCast(CompilerType source_type, CompilerType target_type, int location)
A helper function for VerifyCastType (below).
Definition DILEval.cpp:810
This class contains one Visit method for each specialized type of DIL AST node.
Definition DILAST.h:285
lldb::ValueObjectSP LookupGlobalIdentifier(llvm::StringRef name_ref, std::shared_ptr< StackFrame > frame_sp, lldb::TargetSP target_sp, lldb::DynamicValueType use_dynamic)
Given the name of an identifier, check to see if it matches the name of a global variable.
Definition DILEval.cpp:167
lldb::ValueObjectSP LookupIdentifier(llvm::StringRef name_ref, std::shared_ptr< StackFrame > frame_sp, lldb::DynamicValueType use_dynamic)
Given the name of an identifier (variable name, member name, type name, etc.), find the ValueObject f...
Definition DILEval.cpp:208
std::shared_ptr< lldb_private::TypeSystem > TypeSystemSP
std::shared_ptr< lldb_private::ValueObject > ValueObjectSP
std::shared_ptr< lldb_private::Target > TargetSP