clang 24.0.0git
Disasm.cpp
Go to the documentation of this file.
1//===--- Disasm.cpp - Disassembler for bytecode functions -------*- 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// Dump method for Function which disassembles the bytecode.
10//
11//===----------------------------------------------------------------------===//
12
13#include "Boolean.h"
14#include "Char.h"
15#include "Context.h"
16#include "EvaluationResult.h"
17#include "FixedPoint.h"
18#include "Floating.h"
19#include "Function.h"
20#include "Integral.h"
21#include "IntegralAP.h"
22#include "InterpFrame.h"
23#include "MemberPointer.h"
24#include "Opcode.h"
25#include "PrimType.h"
26#include "Program.h"
28#include "clang/AST/DeclCXX.h"
29#include "clang/AST/ExprCXX.h"
30#include "llvm/Support/Compiler.h"
31#include "llvm/Support/FormatVariadic.h"
32
33using namespace clang;
34using namespace clang::interp;
35
36template <typename T> inline static std::string printArg(CodePtr &OpPC) {
37 if constexpr (std::is_pointer_v<T>) {
38 uintptr_t Ptr = OpPC.read<uintptr_t>();
39 std::string Result;
40 llvm::raw_string_ostream SS(Result);
41 SS << reinterpret_cast<void *>(Ptr);
42 return Result;
43 } else {
44 std::string Result;
45 llvm::raw_string_ostream SS(Result);
46 auto Arg = OpPC.read<T>();
47 // Make sure we print the integral value of chars.
48 if constexpr (std::is_integral_v<T>) {
49 if constexpr (sizeof(T) == 1) {
50 if constexpr (std::is_signed_v<T>)
51 SS << static_cast<int32_t>(Arg);
52 else
53 SS << static_cast<uint32_t>(Arg);
54 } else {
55 SS << Arg;
56 }
57 } else {
58 SS << Arg;
59 }
60
61 return Result;
62 }
63}
64
65template <> inline std::string printArg<Floating>(CodePtr &OpPC) {
66 auto Sem = Floating::deserializeSemantics(*OpPC);
67
68 unsigned BitWidth = llvm::APFloatBase::semanticsSizeInBits(
69 llvm::APFloatBase::EnumToSemantics(Sem));
70 auto Memory =
71 std::make_unique<uint64_t[]>(llvm::APInt::getNumWords(BitWidth));
72 Floating Result(Memory.get(), Sem);
74
75 OpPC += align(Result.bytesToSerialize());
76
77 std::string S;
78 llvm::raw_string_ostream SS(S);
79 SS << std::move(Result);
80 return S;
81}
82
83template <> inline std::string printArg<IntegralAP<false>>(CodePtr &OpPC) {
84 using T = IntegralAP<false>;
85 uint32_t BitWidth = T::deserializeSize(*OpPC);
86 auto Memory =
87 std::make_unique<uint64_t[]>(llvm::APInt::getNumWords(BitWidth));
88
89 T Result(Memory.get(), BitWidth);
90 T::deserialize(*OpPC, &Result);
91
92 OpPC += align(Result.bytesToSerialize());
93
94 std::string Str;
95 llvm::raw_string_ostream SS(Str);
96 SS << std::move(Result);
97 return Str;
98}
99
100template <> inline std::string printArg<IntegralAP<true>>(CodePtr &OpPC) {
101 using T = IntegralAP<true>;
102 uint32_t BitWidth = T::deserializeSize(*OpPC);
103 auto Memory =
104 std::make_unique<uint64_t[]>(llvm::APInt::getNumWords(BitWidth));
105
106 T Result(Memory.get(), BitWidth);
107 T::deserialize(*OpPC, &Result);
108
109 OpPC += align(Result.bytesToSerialize());
110
111 std::string Str;
112 llvm::raw_string_ostream SS(Str);
113 SS << std::move(Result);
114 return Str;
115}
116
117template <> inline std::string printArg<FixedPoint>(CodePtr &OpPC) {
118 auto F = FixedPoint::deserialize(*OpPC);
119 OpPC += align(F.bytesToSerialize());
120
121 std::string Result;
122 llvm::raw_string_ostream SS(Result);
123 SS << std::move(F);
124 return Result;
125}
126
127static bool isJumpOpcode(Opcode Op) {
128 return Op == OP_Jmp || Op == OP_Jf || Op == OP_Jt;
129}
130
131static size_t getNumDisplayWidth(size_t N) {
132 unsigned L = 1u, M = 10u;
133 while (M <= N && ++L != std::numeric_limits<size_t>::digits10 + 1)
134 M *= 10u;
135
136 return L;
137}
138
139LLVM_DUMP_METHOD void Function::dump(CodePtr PC) const {
140 dump(llvm::errs(), PC);
141}
142
143LLVM_DUMP_METHOD void Function::dump(llvm::raw_ostream &OS,
144 CodePtr OpPC) const {
145 if (OpPC) {
146 assert(OpPC >= getCodeBegin());
147 assert(OpPC <= getCodeEnd());
148 }
149 {
150 ColorScope SC(OS, true, {llvm::raw_ostream::BRIGHT_GREEN, true});
151 if (const FunctionDecl *FD = getDecl()) {
152 FD->getNameForDiagnostic(OS, FD->getASTContext().getPrintingPolicy(),
153 /*Qualified=*/true);
154 } else {
155 OS << getName();
156 }
157 OS << " " << (const void *)this << "\n";
158 }
159 OS << "frame size: " << getFrameSize() << "\n";
160 OS << "arg size: " << getArgSize() << "\n";
161 OS << "rvo: " << hasRVO() << "\n";
162 OS << "this arg: " << hasThisPointer() << "\n";
163
164 struct OpText {
165 size_t Addr;
166 std::string Op;
167 bool IsJump;
168 bool CurrentOp = false;
169 llvm::SmallVector<std::string> Args;
170 };
171
172 auto PrintName = [](const char *Name) -> std::string {
173 return std::string(Name);
174 };
175
176 llvm::SmallVector<OpText> Code;
177 size_t LongestAddr = 0;
178 size_t LongestOp = 0;
179
180 for (CodePtr Start = getCodeBegin(), PC = Start; PC != getCodeEnd();) {
181 size_t Addr = PC - Start;
182 OpText Text;
183 auto Op = PC.read<Opcode>();
184 Text.Addr = Addr;
185 Text.IsJump = isJumpOpcode(Op);
186 Text.CurrentOp = (PC == OpPC);
187 switch (Op) {
188#define GET_DISASM
189#include "Opcodes.inc"
190#undef GET_DISASM
191 }
192 Code.push_back(Text);
193 LongestOp = std::max(Text.Op.size(), LongestOp);
194 LongestAddr = std::max(getNumDisplayWidth(Addr), LongestAddr);
195 }
196
197 // Record jumps and their targets.
198 struct JmpData {
199 size_t From;
200 size_t To;
201 };
202 llvm::SmallVector<JmpData> Jumps;
203 for (auto &Text : Code) {
204 if (Text.IsJump)
205 Jumps.push_back({Text.Addr, Text.Addr + std::stoi(Text.Args[0]) +
206 align(sizeof(Opcode)) +
207 align(sizeof(int32_t))});
208 }
209
210 llvm::SmallVector<std::string> Text;
211 Text.reserve(Code.size());
212 size_t LongestLine = 0;
213 // Print code to a string, one at a time.
214 for (const auto &C : Code) {
215 std::string Line;
216 llvm::raw_string_ostream LS(Line);
217 if (OpPC) {
218 if (C.CurrentOp)
219 LS << " * ";
220 else
221 LS << " ";
222 }
223 LS << C.Addr;
224 LS.indent(LongestAddr - getNumDisplayWidth(C.Addr) + 4);
225 LS << C.Op;
226 LS.indent(LongestOp - C.Op.size() + 4);
227 for (auto &Arg : C.Args) {
228 LS << Arg << ' ';
229 }
230 Text.push_back(Line);
231 LongestLine = std::max(Line.size(), LongestLine);
232 }
233
234 assert(Code.size() == Text.size());
235
236 auto spaces = [](unsigned N) -> std::string {
237 std::string S;
238 for (unsigned I = 0; I != N; ++I)
239 S += ' ';
240 return S;
241 };
242
243 // Now, draw the jump lines.
244 for (auto &J : Jumps) {
245 if (J.To > J.From) {
246 bool FoundStart = false;
247 for (size_t LineIndex = 0; LineIndex != Text.size(); ++LineIndex) {
248 Text[LineIndex] += spaces(LongestLine - Text[LineIndex].size());
249
250 if (Code[LineIndex].Addr == J.From) {
251 Text[LineIndex] += " --+";
252 FoundStart = true;
253 } else if (Code[LineIndex].Addr == J.To) {
254 Text[LineIndex] += " <-+";
255 break;
256 } else if (FoundStart) {
257 Text[LineIndex] += " |";
258 }
259 }
260 LongestLine += 5;
261 } else {
262 bool FoundStart = false;
263 for (ssize_t LineIndex = Text.size() - 1; LineIndex >= 0; --LineIndex) {
264 Text[LineIndex] += spaces(LongestLine - Text[LineIndex].size());
265 if (Code[LineIndex].Addr == J.From) {
266 Text[LineIndex] += " --+";
267 FoundStart = true;
268 } else if (Code[LineIndex].Addr == J.To) {
269 Text[LineIndex] += " <-+";
270 break;
271 } else if (FoundStart) {
272 Text[LineIndex] += " |";
273 }
274 }
275 LongestLine += 5;
276 }
277 }
278
279 for (auto &Line : Text)
280 OS << Line << '\n';
281}
282
283LLVM_DUMP_METHOD void Program::dump() const { dump(llvm::errs()); }
284
285static const char *primTypeToString(PrimType T) {
286 switch (T) {
287 case PT_Sint8:
288 return "Sint8";
289 case PT_Uint8:
290 return "Uint8";
291 case PT_Sint16:
292 return "Sint16";
293 case PT_Uint16:
294 return "Uint16";
295 case PT_Sint32:
296 return "Sint32";
297 case PT_Uint32:
298 return "Uint32";
299 case PT_Sint64:
300 return "Sint64";
301 case PT_Uint64:
302 return "Uint64";
303 case PT_IntAP:
304 return "IntAP";
305 case PT_IntAPS:
306 return "IntAPS";
307 case PT_Bool:
308 return "Bool";
309 case PT_Float:
310 return "Float";
311 case PT_Ptr:
312 return "Ptr";
313 case PT_MemberPtr:
314 return "MemberPtr";
315 case PT_FixedPoint:
316 return "FixedPoint";
317 case PT_Reflect:
318 return "Reflect";
319 }
320 llvm_unreachable("Unhandled PrimType");
321}
322
323static std::string formatBytes(size_t B) {
324 std::string Result;
325 llvm::raw_string_ostream SS(Result);
326
327 if (B < (1u << 10u))
328 SS << B << " B";
329 else if (B < (1u << 20u))
330 SS << llvm::formatv("{0:F2}", B / 1024.) << " KB";
331 else
332 SS << llvm::formatv("{0:F2}", B / 1024. / 1024.) << " MB";
333
334 return Result;
335}
336
337LLVM_DUMP_METHOD void Program::dump(llvm::raw_ostream &OS) const {
338 {
339 ColorScope SC(OS, true, {llvm::raw_ostream::BRIGHT_RED, true});
340 OS << "\n:: Program\n";
341 }
342
343 {
344 ColorScope SC(OS, true, {llvm::raw_ostream::WHITE, true});
345 size_t Bytes = 0;
346 Bytes += Allocator.getTotalMemory();
347 // All the maps.
348 Bytes += GlobalIndices.getMemorySize();
349 Bytes += Records.getMemorySize();
350
351 // All Records.
352 // They are allocated using the program allocator, so only get the size from
353 // the BaseMap.
354 for (const Record *R : Records.values())
355 Bytes += R->BaseMap.getMemorySize();
356
357 // Globals are allocated via the allocator, so already counted.
358
359 OS << "Total memory : " << formatBytes(Bytes) << '\n';
360 OS << "Global Variables: " << Globals.size() << '\n';
361 }
362 unsigned GI = 0;
363 for (const Global *G : Globals) {
364 const Descriptor *Desc = G->block()->getDescriptor();
365 Pointer GP = getPtrGlobal(GI);
366
367 OS << GI << ": " << (const void *)G->block() << " ";
368 {
369 ColorScope SC(OS, true,
370 GP.isInitialized()
371 ? TerminalColor{llvm::raw_ostream::GREEN, false}
372 : TerminalColor{llvm::raw_ostream::RED, false});
373 OS << (GP.isInitialized() ? "initialized " : "uninitialized ");
374 }
375 Desc->dump(OS);
376
377 if (GP.isInitialized() && Desc->IsTemporary) {
378 if (const auto *MTE =
379 dyn_cast_if_present<MaterializeTemporaryExpr>(Desc->asExpr());
380 MTE && MTE->getLifetimeExtendedTemporaryDecl()) {
381 if (const APValue *V =
382 MTE->getLifetimeExtendedTemporaryDecl()->getValue()) {
383 OS << " (global temporary value: ";
384 {
385 ColorScope SC(OS, true, {llvm::raw_ostream::BRIGHT_MAGENTA, true});
386 std::string VStr;
387 llvm::raw_string_ostream SS(VStr);
388 V->dump(SS, Ctx.getASTContext());
389
390 for (unsigned I = 0; I != VStr.size(); ++I) {
391 if (VStr[I] == '\n')
392 VStr[I] = ' ';
393 }
394 VStr.pop_back(); // Remove the newline (or now space) at the end.
395 OS << VStr;
396 }
397 OS << ')';
398 }
399 }
400 }
401
402 OS << "\n";
403 if (GP.isInitialized() && Desc->isPrimitive()) {
404 OS << " ";
405 {
406 ColorScope SC(OS, true, {llvm::raw_ostream::BRIGHT_CYAN, false});
407 OS << primTypeToString(Desc->getPrimType()) << " ";
408 }
409 TYPE_SWITCH(Desc->getPrimType(), { GP.deref<T>().print(OS); });
410 OS << "\n";
411 }
412 ++GI;
413 }
414
415 {
416 ColorScope SC(OS, true, {llvm::raw_ostream::WHITE, true});
417 OS << "Functions: " << Funcs.size() << "\n";
418 }
419 for (const auto &Func : Funcs) {
420 Func.second->dump();
421 }
422 for (const auto &Anon : AnonFuncs) {
423 Anon->dump();
424 }
425}
426
427LLVM_DUMP_METHOD void Descriptor::dump() const {
428 dump(llvm::errs());
429 llvm::errs() << '\n';
430}
431
432LLVM_DUMP_METHOD void Descriptor::dump(llvm::raw_ostream &OS) const {
433 // Source
434 {
435 ColorScope SC(OS, true, {llvm::raw_ostream::BLUE, true});
436 if (const auto *ND = dyn_cast_if_present<NamedDecl>(asDecl()))
437 ND->printQualifiedName(OS);
438 else if (asExpr())
439 OS << "Expr " << (const void *)asExpr();
440 }
441
442 // Print a few interesting bits about the descriptor.
443 if (isPrimitiveArray())
444 OS << " primitive-array " << getNumElems() << ' '
446 else if (isCompositeArray())
447 OS << " composite-array " << getNumElems();
448 else if (isUnion())
449 OS << " union(" << ElemRecord->getName() << ")";
450 else if (isRecord())
451 OS << " record(" << ElemRecord->getName() << ")";
452 else if (isPrimitive())
453 OS << " primitive " << primTypeToString(getPrimType());
454
455 if (isZeroSizeArray())
456 OS << " zero-size-array";
457 else if (isUnknownSizeArray())
458 OS << " unknown-size-array";
459
461 OS << " constexpr-unknown";
462}
463
464/// Dump descriptor, including all valid offsets.
465LLVM_DUMP_METHOD void Descriptor::dumpFull(unsigned Offset,
466 unsigned Indent) const {
467 unsigned Spaces = Indent * 2;
468 llvm::raw_ostream &OS = llvm::errs();
469 OS.indent(Spaces);
470 dump(OS);
471 OS << '\n';
472 OS.indent(Spaces) << "Size: " << getSize() << " bytes\n";
473 OS.indent(Spaces) << "AllocSize: " << getAllocSize() << " bytes\n";
474 if (isCompositeArray()) {
475 OS.indent(Spaces) << "Elements: " << getNumElems() << '\n';
476 unsigned FO = Offset;
477 for (unsigned I = 0; I != getNumElems(); ++I) {
478 FO += sizeof(InlineDescriptor);
479 OS.indent(Spaces) << "Element " << I << " offset: " << FO << '\n';
480 ElemDesc->dumpFull(FO, Indent + 1);
481
482 FO += ElemDesc->getAllocSize();
483 }
484 } else if (isPrimitiveArray()) {
485 OS.indent(Spaces) << "Elements: " << getNumElems() << '\n';
486 OS.indent(Spaces) << "Element type: " << primTypeToString(getPrimType())
487 << '\n';
488 unsigned FO = Offset + sizeof(InitMapPtr);
489 for (unsigned I = 0; I != getNumElems(); ++I) {
490 OS.indent(Spaces) << "Element " << I << " offset: " << FO << '\n';
491 FO += getElemSize();
492 }
493 } else if (isRecord()) {
494 ElemRecord->dump(OS, Indent + 1, Offset);
495 unsigned I = 0;
496 for (const Record::Field &F : ElemRecord->fields()) {
497 OS.indent(Spaces) << "- Field " << I << ": ";
498 {
499 ColorScope SC(OS, true, {llvm::raw_ostream::BRIGHT_RED, true});
500 OS << F.Decl->getName();
501 }
502 OS << ". Offset " << (Offset + F.Offset) << "\n";
503 F.Desc->dumpFull(Offset + F.Offset, Indent + 1);
504 ++I;
505 }
506 } else if (isPrimitive()) {
507 } else {
508 }
509
510 OS << '\n';
511}
512
513LLVM_DUMP_METHOD void InlineDescriptor::dump(llvm::raw_ostream &OS) const {
514 {
515 ColorScope SC(OS, true, {llvm::raw_ostream::BLUE, true});
516 OS << "InlineDescriptor " << (const void *)this << "\n";
517 }
518 OS << "Offset: " << Offset << "\n";
519 OS << "IsConst: " << IsConst << "\n";
520 OS << "IsInitialized: " << IsInitialized << "\n";
521 OS << "IsBase: " << IsBase << "\n";
522 OS << "IsActive: " << IsActive << "\n";
523 OS << "InUnion: " << InUnion << "\n";
524 OS << "IsFieldMutable: " << IsFieldMutable << "\n";
525 OS << "IsArrayElement: " << IsArrayElement << "\n";
526 OS << "IsConstInMutable: " << IsConstInMutable << '\n';
527 OS << "Desc: ";
528 if (Desc)
529 Desc->dump(OS);
530 else
531 OS << "nullptr";
532 OS << "\n";
533}
534
535LLVM_DUMP_METHOD void InterpFrame::dump(llvm::raw_ostream &OS,
536 unsigned Indent) const {
537 unsigned Spaces = Indent * 2;
538 {
539 ColorScope SC(OS, true, {llvm::raw_ostream::BLUE, true});
540 OS.indent(Spaces);
541 if (getCallee())
542 describe(OS);
543 else
544 OS << "Frame (Depth: " << getDepth() << ")";
545 OS << "\n";
546 }
547 OS.indent(Spaces) << "Function: " << getFunction();
548 if (const Function *F = getFunction()) {
549 OS << " (" << F->getName() << ")";
550 }
551 OS << "\n";
552 if (hasThisPointer())
553 OS.indent(Spaces) << "This: " << getThis() << "\n";
554 else
555 OS.indent(Spaces) << "This: -\n";
556 if (Func && Func->hasRVO())
557 OS.indent(Spaces) << "RVO: " << getRVOPtr() << "\n";
558 else
559 OS.indent(Spaces) << "RVO: -\n";
560 OS.indent(Spaces) << "Depth: " << Depth << "\n";
561 OS.indent(Spaces) << "ArgSize: " << ArgSize << "\n";
562 OS.indent(Spaces) << "Args: " << (void *)Args << "\n";
563#ifndef NDEBUG
564 OS.indent(Spaces) << "FrameOffset: " << FrameOffset << "\n";
565#endif
566 OS.indent(Spaces) << "FrameSize: " << (Func ? Func->getFrameSize() : 0)
567 << "\n";
568
569 for (const InterpFrame *F = this->Caller; F; F = F->Caller) {
570 F->dump(OS, Indent + 1);
571 }
572}
573
574LLVM_DUMP_METHOD void Record::dump(llvm::raw_ostream &OS, unsigned Indentation,
575 unsigned Offset) const {
576 unsigned Indent = Indentation * 2;
577 OS.indent(Indent);
578 {
579 ColorScope SC(OS, true, {llvm::raw_ostream::BLUE, true});
580 OS << getName() << "\n";
581 }
582
583 unsigned I = 0;
584 for (const Record::Base &B : bases()) {
585 OS.indent(Indent) << "- Base " << I << ". Offset " << (Offset + B.Offset)
586 << "\n";
587 B.R->dump(OS, Indentation + 1, Offset + B.Offset);
588 ++I;
589 }
590
591 I = 0;
592 for (const Record::Field &F : fields()) {
593 OS.indent(Indent) << "- Field " << I << ": ";
594 {
595 ColorScope SC(OS, true, {llvm::raw_ostream::BRIGHT_RED, true});
596 OS << F.Decl->getName();
597 }
598 OS << ". Offset " << (Offset + F.Offset) << "\n";
599 ++I;
600 }
601
602 I = 0;
603 for (const Record::Base &B : virtual_bases()) {
604 OS.indent(Indent) << "- Virtual Base " << I << ". Offset "
605 << (Offset + B.Offset) << "\n";
606 B.R->dump(OS, Indentation + 1, Offset + B.Offset);
607 ++I;
608 }
609}
610
611LLVM_DUMP_METHOD void Block::dump(llvm::raw_ostream &OS) const {
612 {
613 ColorScope SC(OS, true, {llvm::raw_ostream::BRIGHT_BLUE, true});
614 OS << "Block " << (const void *)this;
615 }
616 OS << " (";
617 Desc->dump(OS);
618 OS << ")\n";
619 unsigned NPointers = 0;
620 for (const Pointer *P = Pointers; P; P = P->asBlockPointer().Next) {
621 ++NPointers;
622 }
623 OS << " EvalID: " << EvalID << '\n';
624 OS << " DeclID: ";
625 if (DeclID)
626 OS << *DeclID << '\n';
627 else
628 OS << "-\n";
629 OS << " Pointers: " << NPointers << "\n";
630 OS << " Dead: " << isDead() << "\n";
631 OS << " Static: " << IsStatic << "\n";
632 OS << " Extern: " << isExtern() << "\n";
633 OS << " Initialized: " << IsInitialized << "\n";
634 OS << " Weak: " << isWeak() << "\n";
635 OS << " Dynamic: " << isDynamic() << "\n";
636 OS << " Metadata: " << MDSize << '\n';
637}
638
639LLVM_DUMP_METHOD void EvaluationResult::dump() const {
640 auto &OS = llvm::errs();
641
642 if (empty()) {
643 OS << "Empty\n";
644 } else if (isInvalid()) {
645 OS << "Invalid\n";
646 } else {
647 OS << "Value: ";
648 Value.dump(OS, Ctx.getASTContext());
649 }
650}
#define V(N, I)
static void dump(llvm::raw_ostream &OS, StringRef FunctionName, ArrayRef< CounterExpression > Expressions, ArrayRef< CounterMappingRegion > Regions)
Defines the C++ Decl subclasses, other than those for templates (found in DeclTemplate....
static std::string formatBytes(size_t B)
Definition Disasm.cpp:323
static const char * primTypeToString(PrimType T)
Definition Disasm.cpp:285
static std::string printArg(CodePtr &OpPC)
Definition Disasm.cpp:36
static size_t getNumDisplayWidth(size_t N)
Definition Disasm.cpp:131
static bool isJumpOpcode(Opcode Op)
Definition Disasm.cpp:127
std::string printArg< Floating >(CodePtr &OpPC)
Definition Disasm.cpp:65
std::string printArg< FixedPoint >(CodePtr &OpPC)
Definition Disasm.cpp:117
Defines the clang::Expr interface and subclasses for C++ expressions.
FormatToken * Next
The next token in the unwrapped line.
Result
Implement __builtin_bit_cast and related operations.
#define TYPE_SWITCH(Expr, B)
Definition PrimType.h:240
static bool isInvalid(LocType Loc, bool *Invalid)
APValue - This class implements a discriminated union of [uninitialized] [APSInt] [APFloat],...
Definition APValue.h:124
Represents a function declaration or definition.
Definition Decl.h:2059
bool isExtern() const
Checks if the block is extern.
Definition InterpBlock.h:77
friend class Pointer
bool isDead() const
Definition InterpBlock.h:84
bool isDynamic() const
Definition InterpBlock.h:83
bool isWeak() const
Definition InterpBlock.h:82
Pointer into the code segment.
Definition Source.h:31
std::enable_if_t<!std::is_pointer< T >::value, T > read()
Reads data and advances the pointer.
Definition Source.h:60
void dump() const
Dump to stderr.
Definition Disasm.cpp:639
static FixedPoint deserialize(const std::byte *Buff)
Definition FixedPoint.h:108
If a Floating is constructed from Memory, it DOES NOT OWN THAT MEMORY.
Definition Floating.h:35
static llvm::APFloatBase::Semantics deserializeSemantics(const std::byte *Buff)
Definition Floating.h:212
static void deserialize(const std::byte *Buff, Floating *Result)
Definition Floating.h:216
Bytecode function.
Definition Function.h:98
void dump() const
Dumps the disassembled bytecode to llvm::errs().
Definition Function.h:334
If an IntegralAP is constructed from Memory, it DOES NOT OWN THAT MEMORY.
Definition IntegralAP.h:36
InterpFrame(InterpState &S)
Bottom Frame.
InterpFrame * Caller
The frame of the previous function.
const Pointer & getThis() const
Returns the 'this' pointer.
const Function * getFunction() const
Returns the current function.
Definition InterpFrame.h:80
unsigned getDepth() const
const Pointer & getRVOPtr() const
Returns the RVO pointer, if the Function has one.
void describe(llvm::raw_ostream &OS) const override
Describes the frame with arguments for diagnostic purposes.
A pointer to a memory block, live or dead.
Definition Pointer.h:546
bool isInitialized() const
Checks if an object was initialized.
Definition Pointer.h:1221
Pointer getPtrGlobal(unsigned Idx) const
Returns a pointer to a global.
Definition Program.cpp:21
void dump() const
Dumps the disassembled bytecode to llvm::errs().
Definition Disasm.cpp:283
Structure/Class descriptor.
Definition Record.h:27
std::string getName() const
Returns the name of the underlying declaration.
Definition Record.cpp:26
llvm::iterator_range< const_base_iter > bases() const
Definition Record.h:107
llvm::iterator_range< const_base_iter > virtual_bases() const
Definition Record.h:123
llvm::iterator_range< const_field_iter > fields() const
Definition Record.h:92
static const FunctionDecl * getCallee(const CXXConstructExpr &D)
@ OS
Indicates that the tracking object is a descendant of a referenced-counted OSObject,...
StringRef getName(const HeaderType T)
Definition HeaderFile.h:38
constexpr size_t align(size_t Size)
Aligns a size to the pointer alignment.
Definition PrimType.h:218
PrimType
Enumeration of the primitive types of the VM.
Definition PrimType.h:35
Top level wrappers for InstallAPI frontend operations.
raw_ostream & Indent(raw_ostream &Out, const unsigned int Space, bool IsDot)
Definition JsonSupport.h:21
@ Result
The result type of a method or function.
Definition TypeBase.h:906
const FunctionProtoType * T
__UINTPTR_TYPE__ uintptr_t
An unsigned integer type with the property that any valid pointer to void can be converted to this ty...
int32_t uint32_t
A quantity in bytes.
Describes a memory block created by an allocation site.
Definition Descriptor.h:122
unsigned getAllocSize() const
Returns the allocated size, including metadata.
Definition Descriptor.h:237
unsigned getNumElems() const
Returns the number of elements stored in the block.
Definition Descriptor.h:246
unsigned getSize() const
Returns the size of the object without metadata.
Definition Descriptor.h:226
void dumpFull(unsigned Offset=0, unsigned Indent=0) const
Dump descriptor, including all valid offsets.
Definition Disasm.cpp:465
bool isPrimitive() const
Checks if the descriptor is of a primitive.
Definition Descriptor.h:260
bool isCompositeArray() const
Checks if the descriptor is of an array of composites.
Definition Descriptor.h:253
const Decl * asDecl() const
Definition Descriptor.h:201
const Descriptor *const ElemDesc
Descriptor of the array element.
Definition Descriptor.h:148
bool isUnknownSizeArray() const
Checks if the descriptor is of an array of unknown size.
Definition Descriptor.h:257
unsigned getElemSize() const
returns the size of an element when the structure is viewed as an array.
Definition Descriptor.h:239
bool isPrimitiveArray() const
Checks if the descriptor is of an array of primitives.
Definition Descriptor.h:251
bool isZeroSizeArray() const
Checks if the descriptor is of an array of zero size.
Definition Descriptor.h:255
PrimType getPrimType() const
Definition Descriptor.h:231
bool isRecord() const
Checks if the descriptor is of a record.
Definition Descriptor.h:265
const bool IsTemporary
Flag indicating if the block is a temporary.
Definition Descriptor.h:158
const Record *const ElemRecord
Pointer to the record, if block contains records.
Definition Descriptor.h:146
bool isUnion() const
Checks if the descriptor is of a union.
const Expr * asExpr() const
Definition Descriptor.h:202
A pointer-sized struct we use to allocate into data storage.
Definition InitMap.h:79
Inline descriptor embedded in structures and arrays.
Definition Descriptor.h:67
unsigned IsActive
Flag indicating if the field is the active member of a union.
Definition Descriptor.h:89
unsigned IsConstInMutable
Flag indicating if this field is a const field nested in a mutable parent field.
Definition Descriptor.h:99
unsigned IsBase
Flag indicating if the field is an embedded base class.
Definition Descriptor.h:83
unsigned InUnion
Flag indicating if this field is in a union (even if nested).
Definition Descriptor.h:92
unsigned Offset
Offset inside the structure/array.
Definition Descriptor.h:69
unsigned IsInitialized
For primitive fields, it indicates if the field was initialized.
Definition Descriptor.h:80
unsigned IsConst
Flag indicating if the storage is constant or not.
Definition Descriptor.h:74
unsigned IsArrayElement
Flag indicating if the field is an element of a composite array.
Definition Descriptor.h:102
unsigned IsFieldMutable
Flag indicating if the field is mutable (if in a record).
Definition Descriptor.h:95