clang: lib/AST/ByteCode/InterpState.cpp Source File (original) (raw)

1

2

3

4

5

6

7

8

14

15using namespace clang;

17

20 : Parent(Parent), M(M), P(P), Stk(Stk), Ctx(Ctx), Current(nullptr) {}

21

23 if (ConstantContextOverride)

24 return *ConstantContextOverride;

25

27}

28

34 }

35

36 while (DeadBlocks) {

37 DeadBlock *Next = DeadBlocks->Next;

38 std::free(DeadBlocks);

39 DeadBlocks = Next;

40 }

41}

42

44

45

46 for (DeadBlock *DB = DeadBlocks; DB; DB = DB->Next) {

47 for (Pointer *P = DB->B.Pointers; P; P = P->Next) {

48 P->PointeeStorage.BS.Pointee = nullptr;

49 }

50 }

51

53}

54

59}

60

65}

66

68 assert(B);

70 assert(Desc);

71

73 size_t Size = B->getSize();

74

75

76 char *Memory =

77 reinterpret_cast<char *>(std::malloc(sizeof(DeadBlock) + Size));

78 auto *D = new (Memory) DeadBlock(DeadBlocks, B);

79 std::memset(D->B.rawData(), 0, D->B.getSize());

80

81

82 if (B->IsInitialized && Desc->MoveFn) {

83 Desc->MoveFn(B, B->data(), D->data(), Desc);

86 }

87 D->B.IsInitialized = B->IsInitialized;

88

89

90 B->IsInitialized = false;

91 } else if (B->IsInitialized) {

93 }

94}

95

98

101 assert(It.second.size() > 0);

102

103 const Expr *Source = It.first;

105 << (It.second.size() - 1) << Source->getSourceRange();

106 }

107 }

108 return NoAllocationsLeft;

109}

This represents one expression.

SourceLocation getExprLoc() const LLVM_READONLY

getExprLoc - Return the preferred location for the arrow when diagnosing a problem with a generic exp...

A (possibly-)qualified type.

SourceRange getSourceRange() const LLVM_READONLY

SourceLocation tokens are not useful in isolation - they are low level value objects created/interpre...

The base class of the type hierarchy.

A memory block, either on the stack or in the heap.

unsigned getSize() const

Returns the size of the block.

void invokeDtor()

Invokes the Destructor.

std::byte * data()

Returns a pointer to the stored data.

const Descriptor * getDescriptor() const

Returns the block's descriptor.

std::byte * rawData()

Returns a pointer to the raw data, including metadata.

bool hasPointers() const

Checks if the block has any live pointers.

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

Descriptor for a dead block.

llvm::iterator_range< const_virtual_iter > allocation_sites() const

unsigned getNumAllocations() const

Base class for stack frames, shared between VM and walker.

Frame storing local variables.

InterpFrame * Caller

The frame of the previous function.

Stack frame storing temporaries and parameters.

bool reportOverflow(const Expr *E, const llvm::APSInt &Value)

Reports overflow and return true if evaluation should continue.

bool noteUndefinedBehavior() override

Frame * getCurrentFrame() override

bool maybeDiagnoseDanglingAllocations()

Diagnose any dynamic allocations that haven't been freed yet.

InterpFrame * Current

The current frame.

InterpState(State &Parent, Program &P, InterpStack &Stk, Context &Ctx, SourceMapper *M=nullptr)

void deallocate(Block *B)

Deallocates a pointer.

bool checkingPotentialConstantExpression() const override

bool inConstantContext() const

Program & P

Reference to the module containing all bytecode.

A pointer to a memory block, live or dead.

The program contains and links the bytecode for all functions.

Interface for classes which map locations to sources.

Interface for the VM to interact with the AST walker's context.

virtual Frame * getCurrentFrame()=0

OptionalDiagnostic CCEDiag(SourceLocation Loc, diag::kind DiagId=diag::note_invalid_subexpr_in_const_expr, unsigned ExtraNotes=0)

Diagnose that the evaluation does not produce a C++11 core constant expression.

bool InConstantContext

Whether or not we're in a context where the front end requires a constant value.

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

Describes a memory block created by an allocation site.

unsigned getMetadataSize() const

Returns the size of the metadata.