eEncodingIsSyntheticUID
};
- // We must force the underlying type of the enum to be unsigned here. Not
- // all compilers behave the same with regards to the default underlying type
- // of an enum, but because this enum is used in an enum bitfield and integer
- // comparisons are done with the value we need to guarantee that it's always
- // unsigned so that, for example, eResolveStateFull doesn't compare less than
- // eResolveStateUnresolved when used in a 2-bit bitfield.
- typedef enum ResolveStateTag : unsigned {
- eResolveStateUnresolved = 0,
- eResolveStateForward = 1,
- eResolveStateLayout = 2,
- eResolveStateFull = 3
- } ResolveState;
+ enum class ResolveState : unsigned char {
+ Unresolved = 0,
+ Forward = 1,
+ Layout = 2,
+ Full = 3
+ };
Type(lldb::user_id_t uid, SymbolFile *symbol_file, ConstString name,
llvm::Optional<uint64_t> byte_size, SymbolContextScope *context,
uint32_t GetEncodingMask();
- bool IsCompleteObjCClass() { return m_flags.is_complete_objc_class; }
+ bool IsCompleteObjCClass() { return m_is_complete_objc_class; }
void SetIsCompleteObjCClass(bool is_complete_objc_class) {
- m_flags.is_complete_objc_class = is_complete_objc_class;
+ m_is_complete_objc_class = is_complete_objc_class;
}
protected:
ConstString m_name;
SymbolFile *m_symbol_file;
- SymbolContextScope
- *m_context; // The symbol context in which this type is defined
+ /// The symbol context in which this type is defined.
+ SymbolContextScope *m_context;
Type *m_encoding_type;
lldb::user_id_t m_encoding_uid;
EncodingDataType m_encoding_uid_type;
uint64_t m_byte_size_has_value : 1;
Declaration m_decl;
CompilerType m_compiler_type;
-
- struct Flags {
-#ifdef __GNUC__
- // using unsigned type here to work around a very noisy gcc warning
- unsigned compiler_type_resolve_state : 2;
-#else
- ResolveState compiler_type_resolve_state : 2;
-#endif
- bool is_complete_objc_class : 1;
- } m_flags;
+ ResolveState m_compiler_type_resolve_state;
+ bool m_is_complete_objc_class;
Type *GetEncodingType();
TypeSP type_sp(new Type(
die.GetID(), dwarf, pcm_type_sp->GetName(), pcm_type_sp->GetByteSize(),
nullptr, LLDB_INVALID_UID, Type::eEncodingInvalid,
- &pcm_type_sp->GetDeclaration(), type, Type::eResolveStateForward));
+ &pcm_type_sp->GetDeclaration(), type, Type::ResolveState::Forward));
dwarf->GetTypeList().Insert(type_sp);
dwarf->GetDIEToType()[die.GetDIE()] = type_sp.get();
const dw_tag_t tag = die.Tag();
- Type::ResolveState resolve_state = Type::eResolveStateUnresolved;
+ Type::ResolveState resolve_state = Type::ResolveState::Unresolved;
Type::EncodingDataType encoding_data_type = Type::eEncodingIsUID;
CompilerType clang_type;
case DW_TAG_unspecified_type:
if (attrs.name == "nullptr_t" || attrs.name == "decltype(nullptr)") {
- resolve_state = Type::eResolveStateFull;
+ resolve_state = Type::ResolveState::Full;
clang_type = m_ast.GetBasicType(eBasicTypeNullPtr);
break;
}
LLVM_FALLTHROUGH;
case DW_TAG_base_type:
- resolve_state = Type::eResolveStateFull;
+ resolve_state = Type::ResolveState::Full;
clang_type = m_ast.GetBuiltinTypeForDWARFEncodingAndBitSize(
attrs.name.GetCString(), attrs.encoding,
attrs.byte_size.getValueOr(0) * 8);
lldb_function_type_sp->GetForwardCompilerType());
encoding_data_type = Type::eEncodingIsUID;
attrs.type.Clear();
- resolve_state = Type::eResolveStateFull;
+ resolve_state = Type::ResolveState::Full;
}
}
clang_type = m_ast.GetBasicType(eBasicTypeObjCID);
encoding_data_type = Type::eEncodingIsUID;
attrs.type.Clear();
- resolve_state = Type::eResolveStateFull;
+ resolve_state = Type::ResolveState::Full;
} else if (attrs.name == g_objc_type_name_Class) {
if (log)
clang_type = m_ast.GetBasicType(eBasicTypeObjCClass);
encoding_data_type = Type::eEncodingIsUID;
attrs.type.Clear();
- resolve_state = Type::eResolveStateFull;
+ resolve_state = Type::ResolveState::Full;
} else if (attrs.name == g_objc_type_name_selector) {
if (log)
dwarf->GetObjectFile()->GetModule()->LogMessage(
clang_type = m_ast.GetBasicType(eBasicTypeObjCSel);
encoding_data_type = Type::eEncodingIsUID;
attrs.type.Clear();
- resolve_state = Type::eResolveStateFull;
+ resolve_state = Type::ResolveState::Full;
}
} else if (encoding_data_type == Type::eEncodingIsPointerUID &&
attrs.type.IsValid()) {
clang_type = m_ast.GetBasicType(eBasicTypeObjCID);
encoding_data_type = Type::eEncodingIsUID;
attrs.type.Clear();
- resolve_state = Type::eResolveStateFull;
+ resolve_state = Type::ResolveState::Full;
}
}
}
type_sp = std::make_shared<Type>(
die.GetID(), dwarf, attrs.name, attrs.byte_size, nullptr,
dwarf->GetUID(attrs.type.Reference()), Type::eEncodingIsUID,
- &attrs.decl, clang_type, Type::eResolveStateForward);
+ &attrs.decl, clang_type, Type::ResolveState::Forward);
if (ClangASTContext::StartTagDeclarationDefinition(clang_type)) {
if (die.HasChildren()) {
}
type_sp = std::make_shared<Type>(
die.GetID(), dwarf, attrs.name, llvm::None, nullptr, LLDB_INVALID_UID,
- Type::eEncodingIsUID, &attrs.decl, clang_type, Type::eResolveStateFull);
+ Type::eEncodingIsUID, &attrs.decl, clang_type, Type::ResolveState::Full);
assert(type_sp.get());
} break;
type_sp = std::make_shared<Type>(
die.GetID(), dwarf, empty_name, array_element_bit_stride / 8, nullptr,
dwarf->GetUID(type_die), Type::eEncodingIsUID, &attrs.decl,
- clang_type, Type::eResolveStateFull);
+ clang_type, Type::ResolveState::Full);
type_sp->SetEncodingType(element_type);
m_ast.SetMetadataAsUserID(clang_type.GetOpaqueQualType(), die.GetID());
}
type_sp = std::make_shared<Type>(
die.GetID(), dwarf, attrs.name, *clang_type_size, nullptr,
LLDB_INVALID_UID, Type::eEncodingIsUID, nullptr, clang_type,
- Type::eResolveStateForward);
+ Type::ResolveState::Forward);
}
break;
type_sp = std::make_shared<Type>(die.GetID(), dwarf, attrs.name,
attrs.byte_size, nullptr, LLDB_INVALID_UID,
Type::eEncodingIsUID, &attrs.decl,
- clang_type, Type::eResolveStateForward);
+ clang_type, Type::ResolveState::Forward);
type_sp->SetIsCompleteObjCClass(attrs.is_complete_objc_class);
return std::make_shared<Type>(toOpaqueUid(type_id), this, ConstString(name),
modified_type->GetByteSize(), nullptr,
LLDB_INVALID_UID, Type::eEncodingIsUID, decl,
- ct, Type::eResolveStateFull);
+ ct, Type::ResolveState::Full);
}
lldb::TypeSP
return std::make_shared<Type>(toOpaqueUid(type_id), this, ConstString(),
pr.getSize(), nullptr, LLDB_INVALID_UID,
Type::eEncodingIsUID, decl, ct,
- Type::eResolveStateFull);
+ Type::ResolveState::Full);
}
lldb::TypeSP SymbolFileNativePDB::CreateSimpleType(TypeIndex ti,
Declaration decl;
return std::make_shared<Type>(
uid, this, ConstString("std::nullptr_t"), 0, nullptr, LLDB_INVALID_UID,
- Type::eEncodingIsUID, decl, ct, Type::eResolveStateFull);
+ Type::eEncodingIsUID, decl, ct, Type::ResolveState::Full);
}
if (ti.getSimpleMode() != SimpleTypeMode::Direct) {
Declaration decl;
return std::make_shared<Type>(
uid, this, ConstString(), pointer_size, nullptr, LLDB_INVALID_UID,
- Type::eEncodingIsUID, decl, ct, Type::eResolveStateFull);
+ Type::eEncodingIsUID, decl, ct, Type::ResolveState::Full);
}
if (ti.getSimpleKind() == SimpleTypeKind::NotTranslated)
Declaration decl;
return std::make_shared<Type>(uid, this, ConstString(type_name), size,
nullptr, LLDB_INVALID_UID, Type::eEncodingIsUID,
- decl, ct, Type::eResolveStateFull);
+ decl, ct, Type::ResolveState::Full);
}
static std::string GetUnqualifiedTypeName(const TagRecord &record) {
return std::make_shared<Type>(toOpaqueUid(type_id), this, ConstString(uname),
size, nullptr, LLDB_INVALID_UID,
Type::eEncodingIsUID, decl, ct,
- Type::eResolveStateForward);
+ Type::ResolveState::Forward);
}
lldb::TypeSP SymbolFileNativePDB::CreateTagType(PdbTypeSymId type_id,
toOpaqueUid(type_id), this, ConstString(uname),
underlying_type->GetByteSize(), nullptr, LLDB_INVALID_UID,
lldb_private::Type::eEncodingIsUID, decl, ct,
- lldb_private::Type::eResolveStateForward);
+ lldb_private::Type::ResolveState::Forward);
}
TypeSP SymbolFileNativePDB::CreateArrayType(PdbTypeSymId type_id,
TypeSP array_sp = std::make_shared<lldb_private::Type>(
toOpaqueUid(type_id), this, ConstString(), ar.Size, nullptr,
LLDB_INVALID_UID, lldb_private::Type::eEncodingIsUID, decl, ct,
- lldb_private::Type::eResolveStateFull);
+ lldb_private::Type::ResolveState::Full);
array_sp->SetEncodingType(element_type.get());
return array_sp;
}
return std::make_shared<lldb_private::Type>(
toOpaqueUid(type_id), this, ConstString(), 0, nullptr, LLDB_INVALID_UID,
lldb_private::Type::eEncodingIsUID, decl, ct,
- lldb_private::Type::eResolveStateFull);
+ lldb_private::Type::ResolveState::Full);
}
TypeSP SymbolFileNativePDB::CreateProcedureType(PdbTypeSymId type_id,
return std::make_shared<lldb_private::Type>(
toOpaqueUid(type_id), this, ConstString(), 0, nullptr, LLDB_INVALID_UID,
lldb_private::Type::eEncodingIsUID, decl, ct,
- lldb_private::Type::eResolveStateFull);
+ lldb_private::Type::ResolveState::Full);
}
TypeSP SymbolFileNativePDB::CreateType(PdbTypeSymId type_id, CompilerType ct) {
toOpaqueUid(id), this, ConstString(udt.Name), target_type->GetByteSize(),
nullptr, target_type->GetID(), lldb_private::Type::eEncodingIsTypedefUID,
decl, target_type->GetForwardCompilerType(),
- lldb_private::Type::eResolveStateForward);
+ lldb_private::Type::ResolveState::Forward);
}
TypeSP SymbolFileNativePDB::GetOrCreateTypedef(PdbGlobalSymId id) {
// This may occur with const or volatile types. There are separate type
// symbols in PDB for types with const or volatile modifiers, but we need
// to create only one declaration for them all.
- Type::ResolveStateTag type_resolve_state_tag;
+ Type::ResolveState type_resolve_state;
CompilerType clang_type = m_ast.GetTypeForIdentifier<clang::CXXRecordDecl>(
ConstString(name), decl_context);
if (!clang_type.IsValid()) {
ClangASTContext::SetHasExternalStorage(clang_type.GetOpaqueQualType(),
false);
- type_resolve_state_tag = Type::eResolveStateFull;
+ type_resolve_state = Type::ResolveState::Full;
} else {
// Add the type to the forward declarations. It will help us to avoid
// an endless recursion in CompleteTypeFromUdt function.
ClangASTContext::SetHasExternalStorage(clang_type.GetOpaqueQualType(),
true);
- type_resolve_state_tag = Type::eResolveStateForward;
+ type_resolve_state = Type::ResolveState::Forward;
}
} else
- type_resolve_state_tag = Type::eResolveStateForward;
+ type_resolve_state = Type::ResolveState::Forward;
if (udt->isConstType())
clang_type = clang_type.AddConstModifier();
type.getSymIndexId(), m_ast.GetSymbolFile(), ConstString(name),
udt->getLength(), nullptr, LLDB_INVALID_UID,
lldb_private::Type::eEncodingIsUID, decl, clang_type,
- type_resolve_state_tag);
+ type_resolve_state);
} break;
case PDB_SymType::Enum: {
auto enum_type = llvm::dyn_cast<PDBSymbolTypeEnum>(&type);
return std::make_shared<lldb_private::Type>(
type.getSymIndexId(), m_ast.GetSymbolFile(), ConstString(name), bytes,
nullptr, LLDB_INVALID_UID, lldb_private::Type::eEncodingIsUID, decl,
- ast_enum, lldb_private::Type::eResolveStateFull);
+ ast_enum, lldb_private::Type::ResolveState::Full);
} break;
case PDB_SymType::Typedef: {
auto type_def = llvm::dyn_cast<PDBSymbolTypeTypedef>(&type);
type_def->getSymIndexId(), m_ast.GetSymbolFile(), ConstString(name),
size, nullptr, target_type->GetID(),
lldb_private::Type::eEncodingIsTypedefUID, decl, ast_typedef,
- lldb_private::Type::eResolveStateFull);
+ lldb_private::Type::ResolveState::Full);
} break;
case PDB_SymType::Function:
case PDB_SymType::FunctionSig: {
type.getSymIndexId(), m_ast.GetSymbolFile(), ConstString(name),
llvm::None, nullptr, LLDB_INVALID_UID,
lldb_private::Type::eEncodingIsUID, decl, func_sig_ast_type,
- lldb_private::Type::eResolveStateFull);
+ lldb_private::Type::ResolveState::Full);
} break;
case PDB_SymType::ArrayType: {
auto array_type = llvm::dyn_cast<PDBSymbolTypeArray>(&type);
TypeSP type_sp = std::make_shared<lldb_private::Type>(
array_type->getSymIndexId(), m_ast.GetSymbolFile(), ConstString(),
bytes, nullptr, LLDB_INVALID_UID, lldb_private::Type::eEncodingIsUID,
- decl, array_ast_type, lldb_private::Type::eResolveStateFull);
+ decl, array_ast_type, lldb_private::Type::ResolveState::Full);
type_sp->SetEncodingType(element_type);
return type_sp;
} break;
return std::make_shared<lldb_private::Type>(
builtin_type->getSymIndexId(), m_ast.GetSymbolFile(), type_name, bytes,
nullptr, LLDB_INVALID_UID, lldb_private::Type::eEncodingIsUID, decl,
- builtin_ast_type, lldb_private::Type::eResolveStateFull);
+ builtin_ast_type, lldb_private::Type::ResolveState::Full);
} break;
case PDB_SymType::PointerType: {
auto *pointer_type = llvm::dyn_cast<PDBSymbolTypePointer>(&type);
pointer_type->getSymIndexId(), m_ast.GetSymbolFile(), ConstString(),
pointer_type->getLength(), nullptr, LLDB_INVALID_UID,
lldb_private::Type::eEncodingIsUID, decl, pointer_ast_type,
- lldb_private::Type::eResolveStateForward);
+ lldb_private::Type::ResolveState::Forward);
}
CompilerType pointer_ast_type;
pointer_type->getSymIndexId(), m_ast.GetSymbolFile(), ConstString(),
pointer_type->getLength(), nullptr, LLDB_INVALID_UID,
lldb_private::Type::eEncodingIsUID, decl, pointer_ast_type,
- lldb_private::Type::eResolveStateFull);
+ lldb_private::Type::ResolveState::Full);
} break;
default:
break;
return m_type_sp.get();
}
-Type::Type(lldb::user_id_t uid, SymbolFile *symbol_file,
- ConstString name, llvm::Optional<uint64_t> byte_size,
- SymbolContextScope *context, user_id_t encoding_uid,
- EncodingDataType encoding_uid_type, const Declaration &decl,
- const CompilerType &compiler_type,
+Type::Type(lldb::user_id_t uid, SymbolFile *symbol_file, ConstString name,
+ llvm::Optional<uint64_t> byte_size, SymbolContextScope *context,
+ user_id_t encoding_uid, EncodingDataType encoding_uid_type,
+ const Declaration &decl, const CompilerType &compiler_type,
ResolveState compiler_type_resolve_state)
: std::enable_shared_from_this<Type>(), UserID(uid), m_name(name),
m_symbol_file(symbol_file), m_context(context), m_encoding_type(nullptr),
m_encoding_uid(encoding_uid), m_encoding_uid_type(encoding_uid_type),
- m_decl(decl), m_compiler_type(compiler_type) {
+ m_decl(decl), m_compiler_type(compiler_type),
+ m_compiler_type_resolve_state(
+ compiler_type ? compiler_type_resolve_state
+ : ResolveState::Unresolved),
+ m_is_complete_objc_class(false) {
if (byte_size) {
m_byte_size = *byte_size;
m_byte_size_has_value = true;
m_byte_size = 0;
m_byte_size_has_value = false;
}
- m_flags.compiler_type_resolve_state =
- (compiler_type ? compiler_type_resolve_state : eResolveStateUnresolved);
- m_flags.is_complete_objc_class = false;
}
Type::Type()
: std::enable_shared_from_this<Type>(), UserID(0), m_name("<INVALID TYPE>"),
m_symbol_file(nullptr), m_context(nullptr), m_encoding_type(nullptr),
m_encoding_uid(LLDB_INVALID_UID), m_encoding_uid_type(eEncodingInvalid),
- m_byte_size(0), m_byte_size_has_value(false), m_decl(),
- m_compiler_type() {
- m_flags.compiler_type_resolve_state = eResolveStateUnresolved;
- m_flags.is_complete_objc_class = false;
+ m_compiler_type_resolve_state(ResolveState::Unresolved) {
+ m_byte_size = 0;
+ m_byte_size_has_value = false;
}
void Type::GetDescription(Stream *s, lldb::DescriptionLevel level,
const DataExtractor &data, uint32_t data_byte_offset,
bool show_types, bool show_summary, bool verbose,
lldb::Format format) {
- if (ResolveClangType(eResolveStateForward)) {
+ if (ResolveClangType(ResolveState::Forward)) {
if (show_types) {
s->PutChar('(');
if (verbose)
encoding_type->GetForwardCompilerType();
if (encoding_compiler_type.IsValid()) {
m_compiler_type = encoding_compiler_type;
- m_flags.compiler_type_resolve_state =
- encoding_type->m_flags.compiler_type_resolve_state;
+ m_compiler_type_resolve_state =
+ encoding_type->m_compiler_type_resolve_state;
}
} break;
// set to eResolveStateUnresolved so we need to update it to say that we
// now have a forward declaration since that is what we created above.
if (m_compiler_type.IsValid())
- m_flags.compiler_type_resolve_state = eResolveStateForward;
+ m_compiler_type_resolve_state = ResolveState::Forward;
}
// Check if we have a forward reference to a class/struct/union/enum?
- if (compiler_type_resolve_state == eResolveStateLayout ||
- compiler_type_resolve_state == eResolveStateFull) {
+ if (compiler_type_resolve_state == ResolveState::Layout ||
+ compiler_type_resolve_state == ResolveState::Full) {
// Check if we have a forward reference to a class/struct/union/enum?
if (m_compiler_type.IsValid() &&
- m_flags.compiler_type_resolve_state < compiler_type_resolve_state) {
- m_flags.compiler_type_resolve_state = eResolveStateFull;
+ m_compiler_type_resolve_state < compiler_type_resolve_state) {
+ m_compiler_type_resolve_state = ResolveState::Full;
if (!m_compiler_type.IsDefined()) {
// We have a forward declaration, we need to resolve it to a complete
// definition.
ResolveState encoding_compiler_type_resolve_state =
compiler_type_resolve_state;
- if (compiler_type_resolve_state == eResolveStateLayout) {
+ if (compiler_type_resolve_state == ResolveState::Layout) {
switch (m_encoding_uid_type) {
case eEncodingIsPointerUID:
case eEncodingIsLValueReferenceUID:
case eEncodingIsRValueReferenceUID:
- encoding_compiler_type_resolve_state = eResolveStateForward;
+ encoding_compiler_type_resolve_state = ResolveState::Forward;
break;
default:
break;
}
CompilerType Type::GetFullCompilerType() {
- ResolveClangType(eResolveStateFull);
+ ResolveClangType(ResolveState::Full);
return m_compiler_type;
}
CompilerType Type::GetLayoutCompilerType() {
- ResolveClangType(eResolveStateLayout);
+ ResolveClangType(ResolveState::Layout);
return m_compiler_type;
}
CompilerType Type::GetForwardCompilerType() {
- ResolveClangType(eResolveStateForward);
+ ResolveClangType(ResolveState::Forward);
return m_compiler_type;
}