llvm/lldb/source/Symbol/CompilerType.cpp

//===-- CompilerType.cpp --------------------------------------------------===//
//
// 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
//
//===----------------------------------------------------------------------===//

#include "lldb/Symbol/CompilerType.h"

#include "lldb/Core/Debugger.h"
#include "lldb/Symbol/Type.h"
#include "lldb/Target/ExecutionContext.h"
#include "lldb/Target/Process.h"
#include "lldb/Utility/ConstString.h"
#include "lldb/Utility/DataBufferHeap.h"
#include "lldb/Utility/DataExtractor.h"
#include "lldb/Utility/Scalar.h"
#include "lldb/Utility/Stream.h"
#include "lldb/Utility/StreamString.h"

#include <iterator>
#include <mutex>
#include <optional>

usingnamespacelldb;
usingnamespacelldb_private;

// Tests

bool CompilerType::IsAggregateType() const {}

bool CompilerType::IsAnonymousType() const {}

bool CompilerType::IsScopedEnumerationType() const {}

bool CompilerType::IsArrayType(CompilerType *element_type_ptr, uint64_t *size,
                               bool *is_incomplete) const {}

bool CompilerType::IsVectorType(CompilerType *element_type,
                                uint64_t *size) const {}

bool CompilerType::IsRuntimeGeneratedType() const {}

bool CompilerType::IsCharType() const {}

bool CompilerType::IsCompleteType() const {}

bool CompilerType::IsForcefullyCompleted() const {}

bool CompilerType::IsConst() const {}

unsigned CompilerType::GetPtrAuthKey() const {}

unsigned CompilerType::GetPtrAuthDiscriminator() const {}

bool CompilerType::GetPtrAuthAddressDiversity() const {}

bool CompilerType::IsFunctionType() const {}

// Used to detect "Homogeneous Floating-point Aggregates"
uint32_t
CompilerType::IsHomogeneousAggregate(CompilerType *base_type_ptr) const {}

size_t CompilerType::GetNumberOfFunctionArguments() const {}

CompilerType
CompilerType::GetFunctionArgumentAtIndex(const size_t index) const {}

bool CompilerType::IsFunctionPointerType() const {}

bool CompilerType::IsMemberFunctionPointerType() const {}

bool CompilerType::IsBlockPointerType(
    CompilerType *function_pointer_type_ptr) const {}

bool CompilerType::IsIntegerType(bool &is_signed) const {}

bool CompilerType::IsEnumerationType(bool &is_signed) const {}

bool CompilerType::IsIntegerOrEnumerationType(bool &is_signed) const {}

bool CompilerType::IsPointerType(CompilerType *pointee_type) const {}

bool CompilerType::IsPointerOrReferenceType(CompilerType *pointee_type) const {}

bool CompilerType::IsReferenceType(CompilerType *pointee_type,
                                   bool *is_rvalue) const {}

bool CompilerType::ShouldTreatScalarValueAsAddress() const {}

bool CompilerType::IsFloatingPointType(uint32_t &count,
                                       bool &is_complex) const {}

bool CompilerType::IsDefined() const {}

bool CompilerType::IsPolymorphicClass() const {}

bool CompilerType::IsPossibleDynamicType(CompilerType *dynamic_pointee_type,
                                         bool check_cplusplus,
                                         bool check_objc) const {}

bool CompilerType::IsScalarType() const {}

bool CompilerType::IsTemplateType() const {}

bool CompilerType::IsTypedefType() const {}

bool CompilerType::IsVoidType() const {}

bool CompilerType::IsPointerToScalarType() const {}

bool CompilerType::IsArrayOfScalarType() const {}

bool CompilerType::IsBeingDefined() const {}

bool CompilerType::IsInteger() const {}

bool CompilerType::IsFloat() const {}

bool CompilerType::IsEnumerationType() const {}

bool CompilerType::IsUnscopedEnumerationType() const {}

bool CompilerType::IsIntegerOrUnscopedEnumerationType() const {}

bool CompilerType::IsSigned() const {}

bool CompilerType::IsNullPtrType() const {}

bool CompilerType::IsBoolean() const {}

bool CompilerType::IsEnumerationIntegerTypeSigned() const {}

bool CompilerType::IsScalarOrUnscopedEnumerationType() const {}

bool CompilerType::IsPromotableIntegerType() const {}

bool CompilerType::IsPointerToVoid() const {}

bool CompilerType::IsRecordType() const {}

bool CompilerType::IsVirtualBase(CompilerType target_base,
                                 CompilerType *virtual_base,
                                 bool carry_virtual) const {}

bool CompilerType::IsContextuallyConvertibleToBool() const {}

bool CompilerType::IsBasicType() const {}

std::string CompilerType::TypeDescription() {}

bool CompilerType::CompareTypes(CompilerType rhs) const {}

const char *CompilerType::GetTypeTag() {}

uint32_t CompilerType::GetNumberOfNonEmptyBaseClasses() {}

// Type Completion

bool CompilerType::GetCompleteType() const {}

// AST related queries
size_t CompilerType::GetPointerByteSize() const {}

ConstString CompilerType::GetTypeName(bool BaseOnly) const {}

ConstString CompilerType::GetDisplayTypeName() const {}

uint32_t CompilerType::GetTypeInfo(
    CompilerType *pointee_or_element_compiler_type) const {}

lldb::LanguageType CompilerType::GetMinimumLanguage() {}

lldb::TypeClass CompilerType::GetTypeClass() const {}

void CompilerType::SetCompilerType(lldb::TypeSystemWP type_system,
                                   lldb::opaque_compiler_type_t type) {}

void CompilerType::SetCompilerType(CompilerType::TypeSystemSPWrapper type_system,
                                   lldb::opaque_compiler_type_t type) {}

unsigned CompilerType::GetTypeQualifiers() const {}

// Creating related types

CompilerType
CompilerType::GetArrayElementType(ExecutionContextScope *exe_scope) const {}

CompilerType CompilerType::GetArrayType(uint64_t size) const {}

CompilerType CompilerType::GetCanonicalType() const {}

CompilerType CompilerType::GetFullyUnqualifiedType() const {}

CompilerType CompilerType::GetEnumerationIntegerType() const {}

int CompilerType::GetFunctionArgumentCount() const {}

CompilerType CompilerType::GetFunctionArgumentTypeAtIndex(size_t idx) const {}

CompilerType CompilerType::GetFunctionReturnType() const {}

size_t CompilerType::GetNumMemberFunctions() const {}

TypeMemberFunctionImpl CompilerType::GetMemberFunctionAtIndex(size_t idx) {}

CompilerType CompilerType::GetNonReferenceType() const {}

CompilerType CompilerType::GetPointeeType() const {}

CompilerType CompilerType::GetPointerType() const {}

CompilerType CompilerType::AddPtrAuthModifier(uint32_t payload) const {}

CompilerType CompilerType::GetLValueReferenceType() const {}

CompilerType CompilerType::GetRValueReferenceType() const {}

CompilerType CompilerType::GetAtomicType() const {}

CompilerType CompilerType::AddConstModifier() const {}

CompilerType CompilerType::AddVolatileModifier() const {}

CompilerType CompilerType::AddRestrictModifier() const {}

CompilerType CompilerType::CreateTypedef(const char *name,
                                         const CompilerDeclContext &decl_ctx,
                                         uint32_t payload) const {}

CompilerType CompilerType::GetTypedefedType() const {}

// Create related types using the current type's AST

CompilerType
CompilerType::GetBasicTypeFromAST(lldb::BasicType basic_type) const {}
// Exploring the type

std::optional<uint64_t>
CompilerType::GetBitSize(ExecutionContextScope *exe_scope) const {}

std::optional<uint64_t>
CompilerType::GetByteSize(ExecutionContextScope *exe_scope) const {}

std::optional<size_t>
CompilerType::GetTypeBitAlign(ExecutionContextScope *exe_scope) const {}

lldb::Encoding CompilerType::GetEncoding(uint64_t &count) const {}

lldb::Format CompilerType::GetFormat() const {}

llvm::Expected<uint32_t>
CompilerType::GetNumChildren(bool omit_empty_base_classes,
                             const ExecutionContext *exe_ctx) const {}

lldb::BasicType CompilerType::GetBasicTypeEnumeration() const {}

void CompilerType::ForEachEnumerator(
    std::function<bool(const CompilerType &integer_type,
                       ConstString name,
                       const llvm::APSInt &value)> const &callback) const {}

uint32_t CompilerType::GetNumFields() const {}

CompilerType CompilerType::GetFieldAtIndex(size_t idx, std::string &name,
                                           uint64_t *bit_offset_ptr,
                                           uint32_t *bitfield_bit_size_ptr,
                                           bool *is_bitfield_ptr) const {}

uint32_t CompilerType::GetNumDirectBaseClasses() const {}

uint32_t CompilerType::GetNumVirtualBaseClasses() const {}

CompilerType
CompilerType::GetDirectBaseClassAtIndex(size_t idx,
                                        uint32_t *bit_offset_ptr) const {}

CompilerType
CompilerType::GetVirtualBaseClassAtIndex(size_t idx,
                                         uint32_t *bit_offset_ptr) const {}

CompilerDecl CompilerType::GetStaticFieldWithName(llvm::StringRef name) const {}

uint32_t CompilerType::GetIndexOfFieldWithName(
    const char *name, CompilerType *field_compiler_type_ptr,
    uint64_t *bit_offset_ptr, uint32_t *bitfield_bit_size_ptr,
    bool *is_bitfield_ptr) const {}

llvm::Expected<CompilerType> CompilerType::GetChildCompilerTypeAtIndex(
    ExecutionContext *exe_ctx, size_t idx, bool transparent_pointers,
    bool omit_empty_base_classes, bool ignore_array_bounds,
    std::string &child_name, uint32_t &child_byte_size,
    int32_t &child_byte_offset, uint32_t &child_bitfield_bit_size,
    uint32_t &child_bitfield_bit_offset, bool &child_is_base_class,
    bool &child_is_deref_of_parent, ValueObject *valobj,
    uint64_t &language_flags) const {}

// Look for a child member (doesn't include base classes, but it does include
// their members) in the type hierarchy. Returns an index path into
// "clang_type" on how to reach the appropriate member.
//
//    class A
//    {
//    public:
//        int m_a;
//        int m_b;
//    };
//
//    class B
//    {
//    };
//
//    class C :
//        public B,
//        public A
//    {
//    };
//
// If we have a clang type that describes "class C", and we wanted to looked
// "m_b" in it:
//
// With omit_empty_base_classes == false we would get an integer array back
// with: { 1,  1 } The first index 1 is the child index for "class A" within
// class C The second index 1 is the child index for "m_b" within class A
//
// With omit_empty_base_classes == true we would get an integer array back
// with: { 0,  1 } The first index 0 is the child index for "class A" within
// class C (since class B doesn't have any members it doesn't count) The second
// index 1 is the child index for "m_b" within class A

size_t CompilerType::GetIndexOfChildMemberWithName(
    llvm::StringRef name, bool omit_empty_base_classes,
    std::vector<uint32_t> &child_indexes) const {}

CompilerType
CompilerType::GetDirectNestedTypeWithName(llvm::StringRef name) const {}

size_t CompilerType::GetNumTemplateArguments(bool expand_pack) const {}

TemplateArgumentKind
CompilerType::GetTemplateArgumentKind(size_t idx, bool expand_pack) const {}

CompilerType CompilerType::GetTypeTemplateArgument(size_t idx,
                                                   bool expand_pack) const {}

std::optional<CompilerType::IntegralTemplateArgument>
CompilerType::GetIntegralTemplateArgument(size_t idx, bool expand_pack) const {}

CompilerType CompilerType::GetTypeForFormatters() const {}

LazyBool CompilerType::ShouldPrintAsOneLiner(ValueObject *valobj) const {}

bool CompilerType::IsMeaninglessWithoutDynamicResolution() const {}

// Get the index of the child of "clang_type" whose name matches. This function
// doesn't descend into the children, but only looks one level deep and name
// matches can include base class names.

uint32_t
CompilerType::GetIndexOfChildWithName(llvm::StringRef name,
                                      bool omit_empty_base_classes) const {}

// Dumping types

bool CompilerType::DumpTypeValue(Stream *s, lldb::Format format,
                                 const DataExtractor &data,
                                 lldb::offset_t byte_offset, size_t byte_size,
                                 uint32_t bitfield_bit_size,
                                 uint32_t bitfield_bit_offset,
                                 ExecutionContextScope *exe_scope) {}

void CompilerType::DumpTypeDescription(lldb::DescriptionLevel level) const {}

void CompilerType::DumpTypeDescription(Stream *s,
                                       lldb::DescriptionLevel level) const {}

#ifndef NDEBUG
LLVM_DUMP_METHOD void CompilerType::dump() const {
  if (IsValid())
    if (auto type_system_sp = GetTypeSystem())
      return type_system_sp->dump(m_type);
  llvm::errs() << "<invalid>\n";
}
#endif

bool CompilerType::GetValueAsScalar(const lldb_private::DataExtractor &data,
                                    lldb::offset_t data_byte_offset,
                                    size_t data_byte_size, Scalar &value,
                                    ExecutionContextScope *exe_scope) const {}

CompilerType::CompilerType(CompilerType::TypeSystemSPWrapper type_system,
                           lldb::opaque_compiler_type_t type)
    :{}

CompilerType::CompilerType(lldb::TypeSystemWP type_system,
                           lldb::opaque_compiler_type_t type)
    :{}

#ifndef NDEBUG
bool CompilerType::Verify() const {
  if (!IsValid())
    return true;
  if (auto type_system_sp = GetTypeSystem())
    return type_system_sp->Verify(m_type);
  return true;
}
#endif

CompilerType::TypeSystemSPWrapper CompilerType::GetTypeSystem() const {}

bool CompilerType::TypeSystemSPWrapper::operator==(
    const CompilerType::TypeSystemSPWrapper &other) const {}

TypeSystem *CompilerType::TypeSystemSPWrapper::operator->() const {}

bool lldb_private::operator==(const lldb_private::CompilerType &lhs,
                              const lldb_private::CompilerType &rhs) {}

bool lldb_private::operator!=(const lldb_private::CompilerType &lhs,
                              const lldb_private::CompilerType &rhs) {}