Skip to content

[lldb][NFC] Rename ClangASTContext to TypeSystemClang #656

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions lldb/include/lldb/Symbol/ClangASTImporter.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,11 @@ class ClangASTImporter {
: m_file_manager(clang::FileSystemOptions(),
FileSystem::Instance().GetVirtualFileSystem()) {}

CompilerType CopyType(ClangASTContext &dst, const CompilerType &src_type);
CompilerType CopyType(TypeSystemClang &dst, const CompilerType &src_type);

clang::Decl *CopyDecl(clang::ASTContext *dst_ctx, clang::Decl *decl);

CompilerType DeportType(ClangASTContext &dst, const CompilerType &src_type);
CompilerType DeportType(TypeSystemClang &dst, const CompilerType &src_type);

clang::Decl *DeportDecl(clang::ASTContext *dst_ctx, clang::Decl *decl);

Expand Down
8 changes: 4 additions & 4 deletions lldb/include/lldb/Symbol/ClangExternalASTSourceCallbacks.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,16 @@
#ifndef liblldb_ClangExternalASTSourceCallbacks_h_
#define liblldb_ClangExternalASTSourceCallbacks_h_

#include "lldb/Symbol/ClangASTContext.h"
#include "lldb/Symbol/TypeSystemClang.h"
#include "clang/AST/ExternalASTSource.h"

namespace lldb_private {

class ClangASTContext;
class TypeSystemClang;

class ClangExternalASTSourceCallbacks : public clang::ExternalASTSource {
public:
ClangExternalASTSourceCallbacks(ClangASTContext &ast) : m_ast(ast) {}
ClangExternalASTSourceCallbacks(TypeSystemClang &ast) : m_ast(ast) {}

void FindExternalLexicalDecls(
const clang::DeclContext *DC,
Expand All @@ -38,7 +38,7 @@ class ClangExternalASTSourceCallbacks : public clang::ExternalASTSource {
&VirtualBaseOffsets) override;

private:
ClangASTContext &m_ast;
TypeSystemClang &m_ast;
};

} // namespace lldb_private
Expand Down
2 changes: 1 addition & 1 deletion lldb/include/lldb/Symbol/CompilerDeclContext.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class CompilerDeclContext {
/// This constructor should only be called from the respective TypeSystem
/// implementation.
///
/// \see lldb_private::ClangASTContext::CreateDeclContext(clang::DeclContext*)
/// \see lldb_private::TypeSystemClang::CreateDeclContext(clang::DeclContext*)
CompilerDeclContext(TypeSystem *type_system, void *decl_ctx)
: m_type_system(type_system), m_opaque_decl_ctx(decl_ctx) {}

Expand Down
2 changes: 1 addition & 1 deletion lldb/include/lldb/Symbol/CompilerType.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class CompilerType {
/// This constructor should only be called from the respective TypeSystem
/// implementation.
///
/// \see lldb_private::ClangASTContext::GetType(clang::QualType)
/// \see lldb_private::TypeSystemClang::GetType(clang::QualType)
CompilerType(TypeSystem *type_system, lldb::opaque_compiler_type_t type)
: m_type(type), m_type_system(type_system) {}

Expand Down
2 changes: 1 addition & 1 deletion lldb/include/lldb/Symbol/TypeSystem.h
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,7 @@ class TypeSystem : public PluginInterface {
lldb::offset_t data_offset,
size_t data_byte_size) = 0;

// TODO: Determine if these methods should move to ClangASTContext.
// TODO: Determine if these methods should move to TypeSystemClang.

virtual bool IsPointerOrReferenceType(lldb::opaque_compiler_type_t type,
CompilerType *pointee_type) = 0;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
//===-- ClangASTContext.h ---------------------------------------*- C++ -*-===//
//===-- TypeSystemClang.h ---------------------------------------*- C++ -*-===//
//
// 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
//
//===----------------------------------------------------------------------===//

#ifndef liblldb_ClangASTContext_h_
#define liblldb_ClangASTContext_h_
#ifndef liblldb_TypeSystemClang_h_
#define liblldb_TypeSystemClang_h_

#include <stdint.h>

Expand Down Expand Up @@ -42,7 +42,7 @@ namespace lldb_private {

class Declaration;

class ClangASTContext : public TypeSystem {
class TypeSystemClang : public TypeSystem {
// LLVM RTTI support
static char ID;

Expand All @@ -55,21 +55,21 @@ class ClangASTContext : public TypeSystem {
bool isA(const void *ClassID) const override { return ClassID == &ID; }
static bool classof(const TypeSystem *ts) { return ts->isA(&ID); }

/// Constructs a ClangASTContext with an ASTContext using the given triple.
/// Constructs a TypeSystemClang with an ASTContext using the given triple.
///
/// \param triple The llvm::Triple used for the ASTContext. The triple defines
/// certain characteristics of the ASTContext and its types
/// (e.g., whether certain primitive types exist or what their
/// signedness is).
explicit ClangASTContext(llvm::Triple triple = llvm::Triple());
explicit TypeSystemClang(llvm::Triple triple = llvm::Triple());

/// Constructs a ClangASTContext that uses an existing ASTContext internally.
/// Constructs a TypeSystemClang that uses an existing ASTContext internally.
/// Useful when having an existing ASTContext created by Clang.
///
/// \param existing_ctxt An existing ASTContext.
explicit ClangASTContext(clang::ASTContext &existing_ctxt);
explicit TypeSystemClang(clang::ASTContext &existing_ctxt);

~ClangASTContext() override;
~TypeSystemClang() override;

void Finalize() override;

Expand All @@ -90,18 +90,18 @@ class ClangASTContext : public TypeSystem {

static void Terminate();

static ClangASTContext *GetASTContext(clang::ASTContext *ast_ctx);
static TypeSystemClang *GetASTContext(clang::ASTContext *ast_ctx);

static ClangASTContext *GetScratch(Target &target,
static TypeSystemClang *GetScratch(Target &target,
bool create_on_demand = true) {
auto type_system_or_err = target.GetScratchTypeSystemForLanguage(
lldb::eLanguageTypeC, create_on_demand);
if (auto err = type_system_or_err.takeError()) {
LLDB_LOG_ERROR(lldb_private::GetLogIfAnyCategoriesSet(LIBLLDB_LOG_TARGET),
std::move(err), "Couldn't get scratch ClangASTContext");
std::move(err), "Couldn't get scratch TypeSystemClang");
return nullptr;
}
return llvm::dyn_cast<ClangASTContext>(&type_system_or_err.get());
return llvm::dyn_cast<TypeSystemClang>(&type_system_or_err.get());
}

clang::ASTContext &getASTContext();
Expand All @@ -121,7 +121,7 @@ class ClangASTContext : public TypeSystem {
llvm::IntrusiveRefCntPtr<clang::ExternalASTSource> &ast_source_up);

bool GetCompleteDecl(clang::Decl *decl) {
return ClangASTContext::GetCompleteDecl(&getASTContext(), decl);
return TypeSystemClang::GetCompleteDecl(&getASTContext(), decl);
}

static void DumpDeclHiearchy(clang::Decl *decl);
Expand Down Expand Up @@ -169,16 +169,16 @@ class ClangASTContext : public TypeSystem {
bool ignore_qualifiers = false);

/// Creates a CompilerType form the given QualType with the current
/// ClangASTContext instance as the CompilerType's typesystem.
/// TypeSystemClang instance as the CompilerType's typesystem.
/// \param qt The QualType for a type that belongs to the ASTContext of this
/// ClangASTContext.
/// TypeSystemClang.
/// \return The CompilerType representing the given QualType. If the
/// QualType's type pointer is a nullptr then the function returns an
/// invalid CompilerType.
CompilerType GetType(clang::QualType qt) {
if (qt.getTypePtrOrNull() == nullptr)
return CompilerType();
// Check that the type actually belongs to this ClangASTContext.
// Check that the type actually belongs to this TypeSystemClang.
assert(qt->getAsTagDecl() == nullptr ||
&qt->getAsTagDecl()->getASTContext() == &getASTContext());
return CompilerType(this, qt.getAsOpaquePtr());
Expand Down Expand Up @@ -319,7 +319,7 @@ class ClangASTContext : public TypeSystem {
int *assigned_accessibilities,
size_t num_assigned_accessibilities);

// Returns a mask containing bits from the ClangASTContext::eTypeXXX
// Returns a mask containing bits from the TypeSystemClang::eTypeXXX
// enumerations

// Namespace Declarations
Expand Down Expand Up @@ -385,7 +385,7 @@ class ClangASTContext : public TypeSystem {
DWARFASTParser *GetDWARFParser() override;
PDBASTParser *GetPDBParser() override;

// ClangASTContext callbacks for external source lookups.
// TypeSystemClang callbacks for external source lookups.
void CompleteTagDecl(clang::TagDecl *);

void CompleteObjCInterfaceDecl(clang::ObjCInterfaceDecl *);
Expand Down Expand Up @@ -417,9 +417,9 @@ class ClangASTContext : public TypeSystem {
// CompilerDeclContext override functions

/// Creates a CompilerDeclContext from the given DeclContext
/// with the current ClangASTContext instance as its typesystem.
/// with the current TypeSystemClang instance as its typesystem.
/// The DeclContext has to come from the ASTContext of this
/// ClangASTContext.
/// TypeSystemClang.
CompilerDeclContext CreateDeclContext(clang::DeclContext *ctx);

std::vector<CompilerDecl>
Expand Down Expand Up @@ -459,7 +459,7 @@ class ClangASTContext : public TypeSystem {
const clang::Decl *object);

static clang::ASTContext *
DeclContextGetClangASTContext(const CompilerDeclContext &dc);
DeclContextGetTypeSystemClang(const CompilerDeclContext &dc);

// Tests

Expand Down Expand Up @@ -893,7 +893,7 @@ class ClangASTContext : public TypeSystem {
clang::ClassTemplateDecl *ParseClassTemplateDecl(
clang::DeclContext *decl_ctx, lldb::AccessType access_type,
const char *parent_name, int tag_decl_kind,
const ClangASTContext::TemplateParameterInfos &template_param_infos);
const TypeSystemClang::TemplateParameterInfos &template_param_infos);

clang::BlockDecl *CreateBlockDeclaration(clang::DeclContext *ctx);

Expand Down Expand Up @@ -931,7 +931,7 @@ class ClangASTContext : public TypeSystem {
const clang::ClassTemplateSpecializationDecl *
GetAsTemplateSpecialization(lldb::opaque_compiler_type_t type);

// Classes that inherit from ClangASTContext can see and modify these
// Classes that inherit from TypeSystemClang can see and modify these
std::string m_target_triple;
std::unique_ptr<clang::ASTContext> m_ast_up;
std::unique_ptr<clang::LangOptions> m_language_options_up;
Expand Down Expand Up @@ -963,19 +963,19 @@ class ClangASTContext : public TypeSystem {
/// ASTContext wasn't created by parsing source code.
clang::Sema *m_sema = nullptr;

// For ClangASTContext only
ClangASTContext(const ClangASTContext &);
const ClangASTContext &operator=(const ClangASTContext &);
// For TypeSystemClang only
TypeSystemClang(const TypeSystemClang &);
const TypeSystemClang &operator=(const TypeSystemClang &);
/// Creates the internal ASTContext.
void CreateASTContext();
void SetTargetTriple(llvm::StringRef target_triple);
};

class ClangASTContextForExpressions : public ClangASTContext {
class TypeSystemClangForExpressions : public TypeSystemClang {
public:
ClangASTContextForExpressions(Target &target, llvm::Triple triple);
TypeSystemClangForExpressions(Target &target, llvm::Triple triple);

~ClangASTContextForExpressions() override = default;
~TypeSystemClangForExpressions() override = default;

void Finalize() override;

Expand Down Expand Up @@ -1005,4 +1005,4 @@ class ClangASTContextForExpressions : public ClangASTContext {

} // namespace lldb_private

#endif // liblldb_ClangASTContext_h_
#endif // liblldb_TypeSystemClang_h_
4 changes: 2 additions & 2 deletions lldb/include/lldb/lldb-forward.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ class BroadcastEventSpec;
class Broadcaster;
class BroadcasterManager;
class CallFrameInfo;
class ClangASTContext;
class TypeSystemClang;
class ClangASTImporter;
class ClangASTMetadata;
class ClangASTSource;
Expand Down Expand Up @@ -304,7 +304,7 @@ typedef std::shared_ptr<lldb_private::BreakpointResolver> BreakpointResolverSP;
typedef std::shared_ptr<lldb_private::Broadcaster> BroadcasterSP;
typedef std::shared_ptr<lldb_private::BroadcasterManager> BroadcasterManagerSP;
typedef std::weak_ptr<lldb_private::BroadcasterManager> BroadcasterManagerWP;
typedef std::unique_ptr<lldb_private::ClangASTContext> ClangASTContextUP;
typedef std::unique_ptr<lldb_private::TypeSystemClang> TypeSystemClangUP;
typedef std::shared_ptr<lldb_private::ClangASTImporter> ClangASTImporterSP;
typedef std::unique_ptr<lldb_private::ClangModulesDeclVendor>
ClangModulesDeclVendorUP;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def test(self):
self.expect("fr var all", DATA_TYPES_DISPLAYED_CORRECTLY,
patterns=[' = ALL$'])
# Test that an enum that doesn't match the heuristic we use in
# ClangASTContext::DumpEnumValue, gets printed as a raw integer.
# TypeSystemClang::DumpEnumValue, gets printed as a raw integer.
self.expect("fr var omega", DATA_TYPES_DISPLAYED_CORRECTLY,
patterns=[' = 7$'])
# Test the behavior in case have a variable of a type considered
Expand Down
6 changes: 3 additions & 3 deletions lldb/source/API/SystemInitializerFull.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
#include "lldb/Host/Host.h"
#include "lldb/Initialization/SystemInitializerCommon.h"
#include "lldb/Interpreter/CommandInterpreter.h"
#include "lldb/Symbol/ClangASTContext.h"
#include "lldb/Symbol/TypeSystemClang.h"
#include "lldb/Utility/Timer.h"

#include "Plugins/ABI/MacOSX-arm/ABIMacOSX_arm.h"
Expand Down Expand Up @@ -214,7 +214,7 @@ llvm::Error SystemInitializerFull::Initialize() {
llvm::InitializeAllTargetMCs();
llvm::InitializeAllDisassemblers();

ClangASTContext::Initialize();
TypeSystemClang::Initialize();

#define LLVM_TARGET(t) LLDB_PROCESS_ ## t(Initialize)
#include "llvm/Config/Targets.def"
Expand Down Expand Up @@ -312,7 +312,7 @@ void SystemInitializerFull::Terminate() {
// Terminate and unload and loaded system or user LLDB plug-ins
PluginManager::Terminate();

ClangASTContext::Terminate();
TypeSystemClang::Terminate();

ArchitectureArm::Terminate();
ArchitectureMips::Terminate();
Expand Down
4 changes: 2 additions & 2 deletions lldb/source/Core/ValueObject.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
#include "lldb/DataFormatters/ValueObjectPrinter.h"
#include "lldb/Expression/ExpressionVariable.h"
#include "lldb/Host/Config.h"
#include "lldb/Symbol/ClangASTContext.h"
#include "lldb/Symbol/TypeSystemClang.h"
#include "lldb/Symbol/CompileUnit.h"
#include "lldb/Symbol/CompilerType.h"
#include "lldb/Symbol/Declaration.h"
Expand Down Expand Up @@ -2019,7 +2019,7 @@ bool ValueObject::GetBaseClassPath(Stream &s) {
GetParent() && GetParent()->GetBaseClassPath(s);
CompilerType compiler_type = GetCompilerType();
llvm::Optional<std::string> cxx_class_name =
ClangASTContext::GetCXXClassName(compiler_type);
TypeSystemClang::GetCXXClassName(compiler_type);
if (cxx_class_name) {
if (parent_had_base_class)
s.PutCString("::");
Expand Down
8 changes: 4 additions & 4 deletions lldb/source/Plugins/ABI/SysV-ppc64/ABISysV_ppc64.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
#include "lldb/Core/ValueObjectConstResult.h"
#include "lldb/Core/ValueObjectMemory.h"
#include "lldb/Core/ValueObjectRegister.h"
#include "lldb/Symbol/ClangASTContext.h"
#include "lldb/Symbol/TypeSystemClang.h"
#include "lldb/Symbol/UnwindPlan.h"
#include "lldb/Target/Process.h"
#include "lldb/Target/RegisterContext.h"
Expand Down Expand Up @@ -806,10 +806,10 @@ class ReturnValueExtractor {
// case 3: get from GPRs

// first, check if this is a packed struct or not
ClangASTContext *ast =
llvm::dyn_cast<ClangASTContext>(m_type.GetTypeSystem());
TypeSystemClang *ast =
llvm::dyn_cast<TypeSystemClang>(m_type.GetTypeSystem());
if (ast) {
clang::RecordDecl *record_decl = ClangASTContext::GetAsRecordDecl(m_type);
clang::RecordDecl *record_decl = TypeSystemClang::GetAsRecordDecl(m_type);

if (record_decl) {
auto attrs = record_decl->attrs();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
#include "lldb/Core/Section.h"
#include "lldb/Expression/DiagnosticManager.h"
#include "lldb/Host/FileSystem.h"
#include "lldb/Symbol/ClangASTContext.h"
#include "lldb/Symbol/TypeSystemClang.h"
#include "lldb/Symbol/Function.h"
#include "lldb/Symbol/ObjectFile.h"
#include "lldb/Target/ABI.h"
Expand Down Expand Up @@ -1072,8 +1072,8 @@ DynamicLoaderDarwin::GetThreadLocalData(const lldb::ModuleSP module_sp,
}
StackFrameSP frame_sp = thread_sp->GetStackFrameAtIndex(0);
if (frame_sp) {
ClangASTContext *clang_ast_context =
ClangASTContext::GetScratch(target);
TypeSystemClang *clang_ast_context =
TypeSystemClang::GetScratch(target);

if (!clang_ast_context)
return LLDB_INVALID_ADDRESS;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
#include "lldb/Core/Module.h"
#include "lldb/Core/PluginManager.h"
#include "lldb/Core/Section.h"
#include "lldb/Symbol/ClangASTContext.h"
#include "lldb/Symbol/TypeSystemClang.h"
#include "lldb/Symbol/ObjectFile.h"
#include "lldb/Symbol/SymbolVendor.h"
#include "lldb/Target/ABI.h"
Expand Down Expand Up @@ -222,8 +222,8 @@ bool DynamicLoaderMacOS::NotifyBreakpointHit(void *baton,
// Build up the value array to store the three arguments given above, then
// get the values from the ABI:

ClangASTContext *clang_ast_context =
ClangASTContext::GetScratch(process->GetTarget());
TypeSystemClang *clang_ast_context =
TypeSystemClang::GetScratch(process->GetTarget());
if (!clang_ast_context)
return false;

Expand Down
Loading