Skip to content

[lldb][TypeSystem][NFCI] Log creation of new TypeSystem instances to expression log #91985

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
merged 4 commits into from
May 13, 2024
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
12 changes: 11 additions & 1 deletion lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -501,6 +501,8 @@ TypeSystemClang::TypeSystemClang(llvm::StringRef name,
// The caller didn't pass an ASTContext so create a new one for this
// TypeSystemClang.
CreateASTContext();

LogCreation();
}

TypeSystemClang::TypeSystemClang(llvm::StringRef name,
Expand All @@ -510,6 +512,8 @@ TypeSystemClang::TypeSystemClang(llvm::StringRef name,

m_ast_up.reset(&existing_ctxt);
GetASTMap().Insert(&existing_ctxt, this);

LogCreation();
}

// Destructor
Expand Down Expand Up @@ -630,7 +634,7 @@ void TypeSystemClang::SetExternalSource(
ast.setExternalSource(ast_source_up);
}

ASTContext &TypeSystemClang::getASTContext() {
ASTContext &TypeSystemClang::getASTContext() const {
assert(m_ast_up);
return *m_ast_up;
}
Expand Down Expand Up @@ -9750,3 +9754,9 @@ bool TypeSystemClang::SetDeclIsForcefullyCompleted(const clang::TagDecl *td) {
metadata->SetIsForcefullyCompleted();
return true;
}

void TypeSystemClang::LogCreation() const {
if (auto *log = GetLog(LLDBLog::Expressions))
LLDB_LOG(log, "Created new TypeSystem for (ASTContext*){0:x} '{1}'",
&getASTContext(), getDisplayName());
}
8 changes: 7 additions & 1 deletion lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ class TypeSystemClang : public TypeSystem {
llvm::StringRef getDisplayName() const { return m_display_name; }

/// Returns the clang::ASTContext instance managed by this TypeSystemClang.
clang::ASTContext &getASTContext();
clang::ASTContext &getASTContext() const;

clang::MangleContext *getMangleContext();

Expand Down Expand Up @@ -1166,6 +1166,12 @@ class TypeSystemClang : public TypeSystem {
bool IsTypeImpl(lldb::opaque_compiler_type_t type,
llvm::function_ref<bool(clang::QualType)> predicate) const;

/// Emits information about this TypeSystem into the expression log.
///
/// Helper method that is used in \ref TypeSystemClang::TypeSystemClang
/// on creation of a new instance.
void LogCreation() const;

// Classes that inherit from TypeSystemClang can see and modify these
std::string m_target_triple;
std::unique_ptr<clang::ASTContext> m_ast_up;
Expand Down
Loading