namespace lldb_private {
+/// Represents a generic declaration such as a function declaration.
+///
+/// This class serves as an abstraction for a declaration inside one of the
+/// TypeSystems implemented by the language plugins. It does not have any actual
+/// logic in it but only stores an opaque pointer and a pointer to the
+/// TypeSystem that gives meaning to this opaque pointer. All methods of this
+/// class should call their respective method in the TypeSystem interface and
+/// pass the opaque pointer along.
+///
+/// \see lldb_private::TypeSystem
class CompilerDecl {
public:
// Constructors and Destructors
CompilerDecl() = default;
+ /// Creates a CompilerDecl with the given TypeSystem and opaque pointer.
+ ///
+ /// This constructor should only be called from the respective TypeSystem
+ /// implementation.
CompilerDecl(TypeSystem *type_system, void *decl)
: m_type_system(type_system), m_opaque_decl(decl) {}
namespace lldb_private {
+/// Represents a generic declaration context in a program. A declaration context
+/// is data structure that contains declarations (e.g. namespaces).
+///
+/// This class serves as an abstraction for a declaration context inside one of
+/// the TypeSystems implemented by the language plugins. It does not have any
+/// actual logic in it but only stores an opaque pointer and a pointer to the
+/// TypeSystem that gives meaning to this opaque pointer. All methods of this
+/// class should call their respective method in the TypeSystem interface and
+/// pass the opaque pointer along.
+///
+/// \see lldb_private::TypeSystem
class CompilerDeclContext {
public:
/// Constructs an invalid CompilerDeclContext.
/// Constructs a CompilerDeclContext with the given opaque decl context
/// and its respective TypeSystem instance.
///
- /// Do not use this constructor directly but instead call the respective
- /// wrapper from the TypeSystem subclass.
- /// @see lldb_private::ClangASTContext::CreateDeclContext(clang::DeclContext*)
+ /// This constructor should only be called from the respective TypeSystem
+ /// implementation.
+ ///
+ /// \see lldb_private::ClangASTContext::CreateDeclContext(clang::DeclContext*)
CompilerDeclContext(TypeSystem *type_system, void *decl_ctx)
: m_type_system(type_system), m_opaque_decl_ctx(decl_ctx) {}
class DataExtractor;
-// A class that can carry around a clang ASTContext and a opaque clang
-// QualType. A clang::QualType can be easily reconstructed from an opaque clang
-// type and often the ASTContext is needed when doing various type related
-// tasks, so this class allows both items to travel in a single very
-// lightweight class that can be used. There are many static equivalents of the
-// member functions that allow the ASTContext and the opaque clang QualType to
-// be specified for ease of use and to avoid code duplication.
+/// Represents a generic type in a programming language.
+///
+/// This class serves as an abstraction for a type inside one of the TypeSystems
+/// implemented by the language plugins. It does not have any actual logic in it
+/// but only stores an opaque pointer and a pointer to the TypeSystem that
+/// gives meaning to this opaque pointer. All methods of this class should call
+/// their respective method in the TypeSystem interface and pass the opaque
+/// pointer along.
+///
+/// \see lldb_private::TypeSystem
class CompilerType {
public:
- // Constructors and Destructors
+ /// Creates a CompilerType with the given TypeSystem and opaque compiler type.
+ ///
+ /// This constructor should only be called from the respective TypeSystem
+ /// implementation.
+ ///
+ /// \see lldb_private::ClangASTContext::GetType(clang::QualType)
CompilerType(TypeSystem *type_system, lldb::opaque_compiler_type_t type)
: m_type(type), m_type_system(type_system) {}
bool operator[](unsigned i) const;
};
-/// Interface for representing the Type Systems in different languages.
+/// Interface for representing a type system.
+///
+/// Implemented by language plugins to define the type system for a given
+/// language.
+///
+/// This interface extensively used opaque pointers to prevent that generic
+/// LLDB code has dependencies on language plugins. The type and semantics of
+/// these opaque pointers are defined by the TypeSystem implementation inside
+/// the respective language plugin. Opaque pointers from one TypeSystem
+/// instance should never be passed to a different TypeSystem instance (even
+/// when the language plugin for both TypeSystem instances is the same).
+///
+/// Most of the functions in this class should not be called directly but only
+/// called by their respective counterparts in CompilerType, CompilerDecl and
+/// CompilerDeclContext.
+///
+/// \see lldb_private::CompilerType
+/// \see lldb_private::CompilerDecl
+/// \see lldb_private::CompilerDeclContext
class TypeSystem : public PluginInterface {
public:
// Constructors and Destructors