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