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

1

2

3

4

5

6

7

8

16

17using namespace clang;

19

26 Parent.CheckingPotentialConstantExpression;

29}

30

38 Parent.CheckingPotentialConstantExpression;

41}

42

49

55 }

57

58 while (DeadBlocks) {

60

61

62

63 for (Pointer *P = DeadBlocks->B.Pointers; P; P = P->asBlockPointer().Next)

64 DeadBlocks->B.removePointer(P);

65

66 std::free(DeadBlocks);

67 DeadBlocks = Next;

68 }

69}

70

72

73

74 if (Alloc)

75 Alloc->cleanup();

76}

77

79

81 assert(B);

85

86

87

88

89

90

91 if (B->IsInitialized)

93

96 size_t Size = B->getSize();

97

98 char *Memory =

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

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

101

102

103 std::memcpy(D->rawData(), B->rawData(), Size);

104 D->B.IsInitialized = false;

105 }

106}

107

109 if (!Alloc)

110 return true;

111

112 bool NoAllocationsLeft = !Alloc->hasAllocations();

113

115 for (const auto &[Source, Site] : Alloc->allocation_sites()) {

116 assert(!Site.empty());

117

118 CCEDiag(Source->getExprLoc(), diag::note_constexpr_memory_leak)

119 << (Site.size() - 1) << Source->getSourceRange();

120 }

121 }

122

123

124 return NoAllocationsLeft || getLangOpts().CPlusPlus20;

125}

126

131 continue;

132 const auto *MD = dyn_cast_if_present(Func->getDecl());

133 if (!MD)

134 continue;

136 if (!FnII || !FnII->isStr(Name))

137 continue;

138

139 const auto *CTSD =

140 dyn_cast(MD->getParent());

141 if (!CTSD)

142 continue;

143

144 const IdentifierInfo *ClassII = CTSD->getIdentifier();

146 if (CTSD->isInStdNamespace() && ClassII && ClassII->isStr("allocator") &&

148 QualType ElemType = TAL[0].getAsType();

149 const auto *NewCall = cast(F->Caller->getExpr(F->getRetPC()));

150 return {NewCall, ElemType};

151 }

152 }

153

154 return {};

155}

Defines the C++ Decl subclasses, other than those for templates (found in DeclTemplate....

Defines the C++ template declaration subclasses.

FormatToken * Next

The next token in the unwrapped line.

One of these records is kept for each identifier that is lexed.

bool isStr(const char(&Str)[StrLen]) const

Return true if this is the identifier for the specified string.

A (possibly-)qualified type.

A template argument list.

unsigned size() const

Retrieve the number of template arguments in this template argument list.

@ Type

The template argument is a type.

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.

bool isStatic() const

Checks if the block has static storage duration.

std::byte * rawData()

Returns a pointer to the raw data, including metadata.

bool isInitialized() const

Returns whether the data of this block has been initialized via invoking the Ctor func.

bool hasPointers() const

Checks if the block has any live pointers.

Pointer into the code segment.

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

Descriptor for a dead block.

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

Frame storing local variables.

Stack frame storing temporaries and parameters.

InterpFrame BottomFrame

Bottom function frame.

Context & Ctx

Interpreter Context.

Frame * getCurrentFrame() override

Definition InterpState.cpp:78

InterpStack & Stk

Temporary stack.

bool maybeDiagnoseDanglingAllocations()

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

Definition InterpState.cpp:108

InterpFrame * Current

The current frame.

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

Definition InterpState.cpp:20

std::optional< bool > ConstantContextOverride

~InterpState()

Definition InterpState.cpp:50

void cleanup()

Definition InterpState.cpp:71

void deallocate(Block *B)

Deallocates a pointer.

Definition InterpState.cpp:80

const LangOptions & getLangOpts() const

StdAllocatorCaller getStdAllocatorCaller(StringRef Name) const

Definition InterpState.cpp:127

bool inConstantContext() const

Definition InterpState.cpp:43

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.

bool CheckingPotentialConstantExpression

Whether we're checking that an expression is a potential constant expression.

bool CheckingForUndefinedBehavior

Whether we're checking for an expression that has undefined behavior.

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 checkingPotentialConstantExpression() const

Are we checking whether the expression is a potential 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.

nullptr

This class represents a compute construct, representing a 'Kind' of ‘parallel’, 'serial',...

U cast(CodeGen::Address addr)