//===--- Pointer.h - Types for the constexpr VM -----------------*- C++ -*-===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// // // Defines the classes responsible for pointer tracking. // //===----------------------------------------------------------------------===// #ifndef LLVM_CLANG_AST_INTERP_POINTER_H #define LLVM_CLANG_AST_INTERP_POINTER_H #include "Descriptor.h" #include "FunctionPointer.h" #include "InterpBlock.h" #include "clang/AST/ComparisonCategories.h" #include "clang/AST/Decl.h" #include "clang/AST/DeclCXX.h" #include "clang/AST/Expr.h" #include "llvm/Support/raw_ostream.h" namespace clang { namespace interp { class Block; class DeadBlock; class Pointer; class Context; template <unsigned A, bool B> class Integral; enum PrimType : unsigned; class Pointer; inline llvm::raw_ostream &operator<<(llvm::raw_ostream &OS, const Pointer &P); struct BlockPointer { … }; struct IntPointer { … }; enum class Storage { … }; /// A pointer to a memory block, live or dead. /// /// This object can be allocated into interpreter stack frames. If pointing to /// a live block, it is a link in the chain of pointers pointing to the block. /// /// In the simplest form, a Pointer has a Block* (the pointee) and both Base /// and Offset are 0, which means it will point to raw data. /// /// The Base field is used to access metadata about the data. For primitive /// arrays, the Base is followed by an InitMap. In a variety of cases, the /// Base is preceded by an InlineDescriptor, which is used to track the /// initialization state, among other things. /// /// The Offset field is used to access the actual data. In other words, the /// data the pointer decribes can be found at /// Pointee->rawData() + Pointer.Offset. /// /// /// Pointee Offset /// │ │ /// │ │ /// ▼ ▼ /// ┌───────┬────────────┬─────────┬────────────────────────────┐ /// │ Block │ InlineDesc │ InitMap │ Actual Data │ /// └───────┴────────────┴─────────┴────────────────────────────┘ /// ▲ /// │ /// │ /// Base class Pointer { … }; inline llvm::raw_ostream &operator<<(llvm::raw_ostream &OS, const Pointer &P) { … } } // namespace interp } // namespace clang #endif