clang: lib/AST/ByteCode/EvaluationResult.h Source File (original) (raw)

1

2

3

4

5

6

7

8

9#ifndef LLVM_CLANG_AST_INTERP_EVALUATION_RESULT_H

10#define LLVM_CLANG_AST_INTERP_EVALUATION_RESULT_H

11

17#include

18#include

19

21namespace interp {

22class EvalEmitter;

23class Context;

24

25

26

27

28

29

30

31

33public:

36 LValue,

37 RValue,

39 Valid,

40 };

41

42 using DeclTy = llvm::PointerUnion<const Decl *, const Expr *>;

43

44private:

45 const Context *Ctx = nullptr;

46 std::variant<std::monostate, Pointer, FunctionPointer, APValue> Value;

48 DeclTy Source = nullptr;

49

51

52

54 }

55

56 void setSource(DeclTy D) { Source = D; }

57

58 void setValue(const APValue &V) {

59

63 }

64 void setPointer(const Pointer P) {

68 }

69 void setFunctionPointer(const FunctionPointer &P) {

73 }

74 void setInvalid() {

75

76

78 }

79 void setValid() {

82 }

83

84public:

86

91

92

93

95

96

97

98

99 std::optional toRValue() const;

100

101

103

104

107

109 if (const auto *D =

110 dyn_cast_if_present(Source.dyn_cast<const Decl *>()))

111 return D->getType();

112 else if (const auto *E = Source.dyn_cast<const Expr *>())

113 return E->getType();

115 }

116

117

118 void dump() const;

119

122};

123

124}

125}

126

127#endif

APValue - This class implements a discriminated union of [uninitialized] [APSInt] [APFloat],...

Decl - This represents one declaration (or definition), e.g.

This represents one expression.

A (possibly-)qualified type.

Holds all information required to evaluate constexpr code in a module.

An emitter which evaluates opcodes as they are emitted.

Defines the result of an evaluation.

std::optional< APValue > toRValue() const

If the result is an LValue, convert that to an RValue and return it.

APValue toAPValue() const

Returns an APValue for the evaluation result.

QualType getSourceType() const

bool checkReturnValue(InterpState &S, const Context &Ctx, const Pointer &Ptr, const SourceInfo &Info)

Check that none of the blocks the given pointer (transitively) points to are dynamically allocated.

llvm::PointerUnion< const Decl *, const Expr * > DeclTy

bool checkFullyInitialized(InterpState &S, const Pointer &Ptr) const

Check that all subobjects of the given pointer have been initialized.

EvaluationResult(const Context *Ctx)

void dump() const

Dump to stderr.

A pointer to a memory block, live or dead.

Describes the statement/declaration an opcode was generated from.

llvm::PointerUnion< const Decl *, const Expr * > DeclTy

The JSON file list parser is used to communicate input to InstallAPI.