[Lldb-commits] [lldb] 7b06cb4 - Add an opque payload field to lldb::Type (NFC).
Adrian Prantl via lldb-commits
lldb-commits at lists.llvm.org
Tue Mar 31 11:14:21 PDT 2020
Author: Adrian Prantl
Date: 2020-03-31T11:14:12-07:00
New Revision: 7b06cb4523083206ad79776c80a564cd26bd8326
URL: https://github.com/llvm/llvm-project/commit/7b06cb4523083206ad79776c80a564cd26bd8326
DIFF: https://github.com/llvm/llvm-project/commit/7b06cb4523083206ad79776c80a564cd26bd8326.diff
LOG: Add an opque payload field to lldb::Type (NFC).
Differential Revision: https://reviews.llvm.org/D75562
Added:
Modified:
lldb/include/lldb/Symbol/Type.h
lldb/source/Plugins/LanguageRuntime/ObjC/ObjCLanguageRuntime.cpp
lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h
lldb/source/Symbol/Type.cpp
Removed:
################################################################################
diff --git a/lldb/include/lldb/Symbol/Type.h b/lldb/include/lldb/Symbol/Type.h
index 11b83d7734b9..d18027c7248c 100644
--- a/lldb/include/lldb/Symbol/Type.h
+++ b/lldb/include/lldb/Symbol/Type.h
@@ -97,7 +97,7 @@ class Type : public std::enable_shared_from_this<Type>, public UserID {
llvm::Optional<uint64_t> byte_size, SymbolContextScope *context,
lldb::user_id_t encoding_uid, EncodingDataType encoding_uid_type,
const Declaration &decl, const CompilerType &compiler_qual_type,
- ResolveState compiler_type_resolve_state);
+ ResolveState compiler_type_resolve_state, uint32_t opaque_payload = 0);
// This makes an invalid type. Used for functions that return a Type when
// they get an error.
@@ -196,11 +196,10 @@ class Type : public std::enable_shared_from_this<Type>, public UserID {
uint32_t GetEncodingMask();
- bool IsCompleteObjCClass() { return m_is_complete_objc_class; }
-
- void SetIsCompleteObjCClass(bool is_complete_objc_class) {
- m_is_complete_objc_class = is_complete_objc_class;
- }
+ /// Return the language-specific payload.
+ uint32_t GetPayload() { return m_payload; }
+ /// Return the language-specific payload.
+ void SetPayload(uint32_t opaque_payload) { m_payload = opaque_payload; }
protected:
ConstString m_name;
@@ -215,7 +214,8 @@ class Type : public std::enable_shared_from_this<Type>, public UserID {
Declaration m_decl;
CompilerType m_compiler_type;
ResolveState m_compiler_type_resolve_state;
- bool m_is_complete_objc_class;
+ /// Language-specific flags.
+ uint32_t m_payload;
Type *GetEncodingType();
diff --git a/lldb/source/Plugins/LanguageRuntime/ObjC/ObjCLanguageRuntime.cpp b/lldb/source/Plugins/LanguageRuntime/ObjC/ObjCLanguageRuntime.cpp
index 459e02e55745..5fb03a67fcf9 100644
--- a/lldb/source/Plugins/LanguageRuntime/ObjC/ObjCLanguageRuntime.cpp
+++ b/lldb/source/Plugins/LanguageRuntime/ObjC/ObjCLanguageRuntime.cpp
@@ -129,7 +129,7 @@ ObjCLanguageRuntime::LookupInCompleteClassCache(ConstString &name) {
if (TypeSystemClang::IsObjCObjectOrInterfaceType(
type_sp->GetForwardCompilerType())) {
- if (type_sp->IsCompleteObjCClass()) {
+ if (TypePayloadClang(type_sp->GetPayload()).IsCompleteObjCClass()) {
m_complete_class_cache[name] = type_sp;
return type_sp;
}
diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
index 760933bf898e..96500da4c516 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
@@ -1634,12 +1634,11 @@ DWARFASTParserClang::ParseStructureLikeDIE(const SymbolContext &sc,
// parameters in any class methods need it for the clang types for
// function prototypes.
LinkDeclContextToDIE(m_ast.GetDeclContextForType(clang_type), die);
- 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::ResolveState::Forward);
-
- type_sp->SetIsCompleteObjCClass(attrs.is_complete_objc_class);
+ 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::ResolveState::Forward,
+ TypePayloadClang(attrs.is_complete_objc_class));
// Add our type to the unique type map so we don't end up creating many
// copies of the same type over and over in the ASTContext for our
diff --git a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
index a94e5a15fa68..22f401fa4e95 100644
--- a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
+++ b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
@@ -316,6 +316,10 @@ static ClangASTMap &GetASTMap() {
return *g_map_ptr;
}
+TypePayloadClang::TypePayloadClang(bool is_complete_objc_class) {
+ SetIsCompleteObjCClass(is_complete_objc_class);
+}
+
char TypeSystemClang::ID;
bool TypeSystemClang::IsOperator(llvm::StringRef name,
diff --git a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h
index 49b0bd70f2ae..a609b06d4e13 100644
--- a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h
+++ b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h
@@ -33,6 +33,7 @@
#include "lldb/Symbol/TypeSystem.h"
#include "lldb/Target/Target.h"
#include "lldb/Utility/ConstString.h"
+#include "lldb/Utility/Flags.h"
#include "lldb/Utility/Log.h"
#include "lldb/Utility/Logging.h"
#include "lldb/lldb-enumerations.h"
@@ -42,7 +43,9 @@ class PDBASTParser;
namespace clang {
class FileManager;
-}
+class HeaderSearch;
+class ModuleMap;
+} // namespace clang
namespace lldb_private {
@@ -50,6 +53,24 @@ class ClangASTMetadata;
class ClangASTSource;
class Declaration;
+/// The implementation of lldb::Type's m_payload field for TypeSystemClang.
+class TypePayloadClang {
+ /// Layout: bit 31 ... IsCompleteObjCClass.
+ uint32_t m_payload = 0;
+public:
+ TypePayloadClang() = default;
+ explicit TypePayloadClang(bool is_complete_objc_class);
+ explicit TypePayloadClang(uint32_t opaque_payload) : m_payload(opaque_payload) {}
+ operator uint32_t() { return m_payload; }
+
+ static constexpr unsigned ObjCClassBit = 1 << 31;
+ bool IsCompleteObjCClass() { return Flags(m_payload).Test(ObjCClassBit); }
+ void SetIsCompleteObjCClass(bool is_complete_objc_class) {
+ m_payload = is_complete_objc_class ? Flags(m_payload).Set(ObjCClassBit)
+ : Flags(m_payload).Clear(ObjCClassBit);
+ }
+};
+
/// A TypeSystem implementation based on Clang.
///
/// This class uses a single clang::ASTContext as the backend for storing
diff --git a/lldb/source/Symbol/Type.cpp b/lldb/source/Symbol/Type.cpp
index 09c0e1638793..804f7e02d3c9 100644
--- a/lldb/source/Symbol/Type.cpp
+++ b/lldb/source/Symbol/Type.cpp
@@ -143,15 +143,14 @@ 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)
+ ResolveState compiler_type_resolve_state, uint32_t opaque_payload)
: 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_compiler_type_resolve_state(
- compiler_type ? compiler_type_resolve_state
- : ResolveState::Unresolved),
- m_is_complete_objc_class(false) {
+ m_compiler_type_resolve_state(compiler_type ? compiler_type_resolve_state
+ : ResolveState::Unresolved),
+ m_payload(opaque_payload) {
if (byte_size) {
m_byte_size = *byte_size;
m_byte_size_has_value = true;
More information about the lldb-commits
mailing list