clang 24.0.0git
InterpBuiltinObjectSize.cpp File Reference
#include "InterpHelpers.h"
#include "Pointer.h"
#include "Record.h"
#include "clang/AST/RecordLayout.h"

Go to the source code of this file.

Namespaces

namespace  clang
 Top level wrappers for InstallAPI frontend operations.
namespace  clang::interp

Enumerations

enum  : uint8_t { Regular = 1 << 0 , IgnoreBaseCasts = 1 << 1 , SurroundingArray = 1 << 2 }

Functions

static bool validType (QualType T)
static QualType computeFieldType (const ASTContext &ASTCtx, const OpaquePointer &OP, unsigned TypeModifier=0)
static std::optional< unsignedcomputeFullDescSize (const ASTContext &ASTCtx, const Descriptor *Desc)
static unsigned computePointerOffset (const ASTContext &ASTCtx, const Pointer &Ptr)
 Compute the byte offset of Ptr in the full declaration.
static bool pointsToLastObject (const Pointer &Ptr)
 Does Ptr point to the last subobject?
static bool isUserWritingOffTheEnd (const ASTContext &Ctx, const Pointer &Ptr, bool InvalidBase)
 Does Ptr point to the last object AND to a flexible array member?
static bool isUserWritingOffTheEnd (const ASTContext &ASTCtx, const OpaquePointer &OP)
static std::optional< uint64_t > computeOpaquePtrOffset (const ASTContext &ASTCtx, const Pointer &Ptr, bool UseClosestSurroundingVariable, bool &OffsetIsNegative)
 Determine the offset of the given pointer.
static bool pointsToCompleteObject (const ASTContext &ASTCtx, const Pointer &Ptr)
 Check if the given pointer points to the complete object, i.e.
static std::optional< unsignedcomputeOpaqueSize (const ASTContext &ASTCtx, const Pointer &Ptr, bool UseClosestSurroundingVariable, bool WritingOffTheEnd, bool DetermineForCompleteObject)
UnsignedOrNone clang::interp::evaluateBuiltinObjectSize (const ASTContext &ASTCtx, unsigned Kind, Pointer &Ptr, const Expr *E, bool IsDynamic)
 Evaluate __builtin_object_size or __builtin_dynamic_object_size for the given pointer and Kind.

Enumeration Type Documentation

◆ anonymous enum

anonymous enum : uint8_t
Enumerator
Regular 
IgnoreBaseCasts 
SurroundingArray 

Definition at line 20 of file InterpBuiltinObjectSize.cpp.

Function Documentation

◆ computeFieldType()

◆ computeFullDescSize()

◆ computeOpaquePtrOffset()

◆ computeOpaqueSize()

std::optional< unsigned > computeOpaqueSize ( const ASTContext & ASTCtx,
const Pointer & Ptr,
bool UseClosestSurroundingVariable,
bool WritingOffTheEnd,
bool DetermineForCompleteObject )
static

◆ computePointerOffset()

unsigned computePointerOffset ( const ASTContext & ASTCtx,
const Pointer & Ptr )
static

Compute the byte offset of Ptr in the full declaration.

Definition at line 92 of file InterpBuiltinObjectSize.cpp.

Referenced by clang::interp::evaluateBuiltinObjectSize().

◆ isUserWritingOffTheEnd() [1/2]

◆ isUserWritingOffTheEnd() [2/2]

bool isUserWritingOffTheEnd ( const ASTContext & Ctx,
const Pointer & Ptr,
bool InvalidBase )
static

Does Ptr point to the last object AND to a flexible array member?

Definition at line 126 of file InterpBuiltinObjectSize.cpp.

References clang::ASTContext::getLangOpts(), clang::interp::Descriptor::isArray(), and pointsToLastObject().

Referenced by determineEndOffset(), and clang::interp::evaluateBuiltinObjectSize().

◆ pointsToCompleteObject()

bool pointsToCompleteObject ( const ASTContext & ASTCtx,
const Pointer & Ptr )
static

Check if the given pointer points to the complete object, i.e.

either to the very beginning or after the end (into the flexible array member) of the object.

Definition at line 316 of file InterpBuiltinObjectSize.cpp.

References computeFieldType(), clang::interp::OpaquePointer::getSurroundingArray(), clang::isa(), clang::interp::OpaquePointer::isArrayElement(), and clang::interp::OpaquePointer::PathLength.

Referenced by clang::interp::evaluateBuiltinObjectSize().

◆ pointsToLastObject()

◆ validType()

bool validType ( QualType T)
static

Definition at line 28 of file InterpBuiltinObjectSize.cpp.

References ASTContext::hasLayout(), and clang::T.