aboutsummaryrefslogtreecommitdiff
path: root/lldb/source/Plugins/ExpressionParser
diff options
context:
space:
mode:
authorDimitry Andric <dim@FreeBSD.org>2022-07-03 14:10:23 +0000
committerDimitry Andric <dim@FreeBSD.org>2022-07-03 14:10:23 +0000
commit145449b1e420787bb99721a429341fa6be3adfb6 (patch)
tree1d56ae694a6de602e348dd80165cf881a36600ed /lldb/source/Plugins/ExpressionParser
parentecbca9f5fb7d7613d2b94982c4825eb0d33d6842 (diff)
Diffstat (limited to 'lldb/source/Plugins/ExpressionParser')
-rw-r--r--lldb/source/Plugins/ExpressionParser/Clang/ASTResultSynthesizer.cpp15
-rw-r--r--lldb/source/Plugins/ExpressionParser/Clang/ClangASTImporter.cpp31
-rw-r--r--lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.cpp33
-rw-r--r--lldb/source/Plugins/ExpressionParser/Clang/ClangDeclVendor.h2
-rw-r--r--lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp57
-rw-r--r--lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp9
-rw-r--r--lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionSourceCode.cpp5
-rw-r--r--lldb/source/Plugins/ExpressionParser/Clang/ClangFunctionCaller.cpp3
-rw-r--r--lldb/source/Plugins/ExpressionParser/Clang/ClangHost.cpp7
-rw-r--r--lldb/source/Plugins/ExpressionParser/Clang/ClangModulesDeclVendor.cpp20
-rw-r--r--lldb/source/Plugins/ExpressionParser/Clang/ClangUserExpression.cpp15
-rw-r--r--lldb/source/Plugins/ExpressionParser/Clang/CxxModuleHandler.cpp3
-rw-r--r--lldb/source/Plugins/ExpressionParser/Clang/IRDynamicChecks.cpp14
-rw-r--r--lldb/source/Plugins/ExpressionParser/Clang/IRDynamicChecks.h2
-rw-r--r--lldb/source/Plugins/ExpressionParser/Clang/IRForTarget.cpp117
-rw-r--r--lldb/source/Plugins/ExpressionParser/Clang/NameSearchContext.cpp3
16 files changed, 149 insertions, 187 deletions
diff --git a/lldb/source/Plugins/ExpressionParser/Clang/ASTResultSynthesizer.cpp b/lldb/source/Plugins/ExpressionParser/Clang/ASTResultSynthesizer.cpp
index 7844f27139cf..7a1ac7870547 100644
--- a/lldb/source/Plugins/ExpressionParser/Clang/ASTResultSynthesizer.cpp
+++ b/lldb/source/Plugins/ExpressionParser/Clang/ASTResultSynthesizer.cpp
@@ -14,6 +14,7 @@
#include "Plugins/TypeSystem/Clang/TypeSystemClang.h"
#include "lldb/Target/Target.h"
#include "lldb/Utility/LLDBAssert.h"
+#include "lldb/Utility/LLDBLog.h"
#include "lldb/Utility/Log.h"
#include "clang/AST/ASTContext.h"
#include "clang/AST/Decl.h"
@@ -53,7 +54,7 @@ void ASTResultSynthesizer::Initialize(ASTContext &Context) {
}
void ASTResultSynthesizer::TransformTopLevelDecl(Decl *D) {
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_EXPRESSIONS));
+ Log *log = GetLog(LLDBLog::Expressions);
if (NamedDecl *named_decl = dyn_cast<NamedDecl>(D)) {
if (log && log->GetVerbose()) {
@@ -112,7 +113,7 @@ bool ASTResultSynthesizer::HandleTopLevelDecl(DeclGroupRef D) {
}
bool ASTResultSynthesizer::SynthesizeFunctionResult(FunctionDecl *FunDecl) {
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_EXPRESSIONS));
+ Log *log = GetLog(LLDBLog::Expressions);
if (!m_sema)
return false;
@@ -154,7 +155,7 @@ bool ASTResultSynthesizer::SynthesizeFunctionResult(FunctionDecl *FunDecl) {
bool ASTResultSynthesizer::SynthesizeObjCMethodResult(
ObjCMethodDecl *MethodDecl) {
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_EXPRESSIONS));
+ Log *log = GetLog(LLDBLog::Expressions);
if (!m_sema)
return false;
@@ -198,7 +199,7 @@ bool ASTResultSynthesizer::SynthesizeObjCMethodResult(
bool ASTResultSynthesizer::SynthesizeBodyResult(CompoundStmt *Body,
DeclContext *DC) {
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_EXPRESSIONS));
+ Log *log = GetLog(LLDBLog::Expressions);
ASTContext &Ctx(*m_ast_context);
@@ -407,7 +408,7 @@ void ASTResultSynthesizer::MaybeRecordPersistentType(TypeDecl *D) {
if (name.size() == 0 || name[0] != '$')
return;
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_EXPRESSIONS));
+ Log *log = GetLog(LLDBLog::Expressions);
ConstString name_cs(name.str().c_str());
@@ -427,7 +428,7 @@ void ASTResultSynthesizer::RecordPersistentDecl(NamedDecl *D) {
if (name.size() == 0)
return;
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_EXPRESSIONS));
+ Log *log = GetLog(LLDBLog::Expressions);
ConstString name_cs(name.str().c_str());
@@ -455,7 +456,7 @@ void ASTResultSynthesizer::CommitPersistentDecls() {
&scratch_ctx->getASTContext(), decl);
if (!D_scratch) {
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_EXPRESSIONS));
+ Log *log = GetLog(LLDBLog::Expressions);
if (log) {
std::string s;
diff --git a/lldb/source/Plugins/ExpressionParser/Clang/ClangASTImporter.cpp b/lldb/source/Plugins/ExpressionParser/Clang/ClangASTImporter.cpp
index 6ed3cc9384f0..9ef3c3671abf 100644
--- a/lldb/source/Plugins/ExpressionParser/Clang/ClangASTImporter.cpp
+++ b/lldb/source/Plugins/ExpressionParser/Clang/ClangASTImporter.cpp
@@ -8,6 +8,7 @@
#include "lldb/Core/Module.h"
#include "lldb/Utility/LLDBAssert.h"
+#include "lldb/Utility/LLDBLog.h"
#include "lldb/Utility/Log.h"
#include "clang/AST/Decl.h"
#include "clang/AST/DeclCXX.h"
@@ -49,8 +50,7 @@ CompilerType ClangASTImporter::CopyType(TypeSystemClang &dst_ast,
llvm::Expected<QualType> ret_or_error = delegate_sp->Import(src_qual_type);
if (!ret_or_error) {
- Log *log =
- lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_EXPRESSIONS);
+ Log *log = GetLog(LLDBLog::Expressions);
LLDB_LOG_ERROR(log, ret_or_error.takeError(),
"Couldn't import type: {0}");
return CompilerType();
@@ -77,7 +77,7 @@ clang::Decl *ClangASTImporter::CopyDecl(clang::ASTContext *dst_ast,
llvm::Expected<clang::Decl *> result = delegate_sp->Import(decl);
if (!result) {
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_EXPRESSIONS));
+ Log *log = GetLog(LLDBLog::Expressions);
LLDB_LOG_ERROR(log, result.takeError(), "Couldn't import decl: {0}");
if (log) {
lldb::user_id_t user_id = LLDB_INVALID_UID;
@@ -170,7 +170,7 @@ private:
void Override(clang::Decl *decl) {
if (clang::Decl *escaped_child = GetEscapedChild(decl)) {
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_EXPRESSIONS));
+ Log *log = GetLog(LLDBLog::Expressions);
LLDB_LOG(log,
" [ClangASTImporter] DeclContextOverride couldn't "
@@ -240,7 +240,7 @@ public:
m_delegate->SetImportListener(this);
}
- virtual ~CompleteTagDeclsScope() {
+ ~CompleteTagDeclsScope() override {
ClangASTImporter::ASTContextMetadataSP to_context_md =
importer.GetContextMetadata(m_dst_ctx);
@@ -303,7 +303,7 @@ public:
CompilerType ClangASTImporter::DeportType(TypeSystemClang &dst,
const CompilerType &src_type) {
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_EXPRESSIONS));
+ Log *log = GetLog(LLDBLog::Expressions);
TypeSystemClang *src_ctxt =
llvm::cast<TypeSystemClang>(src_type.GetTypeSystem());
@@ -326,7 +326,7 @@ CompilerType ClangASTImporter::DeportType(TypeSystemClang &dst,
clang::Decl *ClangASTImporter::DeportDecl(clang::ASTContext *dst_ctx,
clang::Decl *decl) {
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_EXPRESSIONS));
+ Log *log = GetLog(LLDBLog::Expressions);
clang::ASTContext *src_ctx = &decl->getASTContext();
LLDB_LOG(log,
@@ -615,7 +615,7 @@ bool ClangASTImporter::CompleteAndFetchChildren(clang::QualType type) {
if (!RequireCompleteType(type))
return false;
- Log *log = lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_EXPRESSIONS);
+ Log *log = GetLog(LLDBLog::Expressions);
if (const TagType *tag_type = type->getAs<TagType>()) {
TagDecl *tag_decl = tag_type->getDecl();
@@ -779,7 +779,7 @@ void ClangASTImporter::BuildNamespaceMap(const clang::NamespaceDecl *decl) {
}
void ClangASTImporter::ForgetDestination(clang::ASTContext *dst_ast) {
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_EXPRESSIONS));
+ Log *log = GetLog(LLDBLog::Expressions);
LLDB_LOG(log,
" [ClangASTImporter] Forgetting destination (ASTContext*){0}",
@@ -792,7 +792,7 @@ void ClangASTImporter::ForgetSource(clang::ASTContext *dst_ast,
clang::ASTContext *src_ast) {
ASTContextMetadataSP md = MaybeGetContextMetadata(dst_ast);
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_EXPRESSIONS));
+ Log *log = GetLog(LLDBLog::Expressions);
LLDB_LOG(log,
" [ClangASTImporter] Forgetting source->dest "
@@ -806,7 +806,7 @@ void ClangASTImporter::ForgetSource(clang::ASTContext *dst_ast,
md->removeOriginsWithContext(src_ast);
}
-ClangASTImporter::MapCompleter::~MapCompleter() {}
+ClangASTImporter::MapCompleter::~MapCompleter() = default;
llvm::Expected<Decl *>
ClangASTImporter::ASTImporterDelegate::ImportImpl(Decl *From) {
@@ -865,7 +865,7 @@ ClangASTImporter::ASTImporterDelegate::ImportImpl(Decl *From) {
const ClangASTMetadata *md = m_main.GetDeclMetadata(From);
auto *td = dyn_cast<TagDecl>(From);
if (td && md && md->IsForcefullyCompleted()) {
- Log *log = GetLogIfAllCategoriesSet(LIBLLDB_LOG_EXPRESSIONS);
+ Log *log = GetLog(LLDBLog::Expressions);
LLDB_LOG(log,
"[ClangASTImporter] Searching for a complete definition of {0} in "
"other modules",
@@ -903,7 +903,7 @@ void ClangASTImporter::ASTImporterDelegate::ImportDefinitionTo(
MapImported(from, to);
ASTImporter::Imported(from, to);
- Log *log = lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_EXPRESSIONS);
+ Log *log = GetLog(LLDBLog::Expressions);
if (llvm::Error err = ImportDefinition(from)) {
LLDB_LOG_ERROR(log, std::move(err),
@@ -915,8 +915,7 @@ void ClangASTImporter::ASTImporterDelegate::ImportDefinitionTo(
if (clang::TagDecl *from_tag = dyn_cast<clang::TagDecl>(from)) {
to_tag->setCompleteDefinition(from_tag->isCompleteDefinition());
- if (Log *log_ast =
- lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_AST)) {
+ if (Log *log_ast = GetLog(LLDBLog::AST)) {
std::string name_string;
if (NamedDecl *from_named_decl = dyn_cast<clang::NamedDecl>(from)) {
llvm::raw_string_ostream name_stream(name_string);
@@ -1023,7 +1022,7 @@ RemapModule(OptionalClangModuleID from_id,
void ClangASTImporter::ASTImporterDelegate::Imported(clang::Decl *from,
clang::Decl *to) {
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_EXPRESSIONS));
+ Log *log = GetLog(LLDBLog::Expressions);
// Some decls shouldn't be tracked here because they were not created by
// copying 'from' to 'to'. Just exit early for those.
diff --git a/lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.cpp b/lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.cpp
index 510352e8c173..1bf29efb0bee 100644
--- a/lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.cpp
+++ b/lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.cpp
@@ -18,6 +18,7 @@
#include "lldb/Symbol/SymbolFile.h"
#include "lldb/Symbol/TaggedASTType.h"
#include "lldb/Target/Target.h"
+#include "lldb/Utility/LLDBLog.h"
#include "lldb/Utility/Log.h"
#include "clang/AST/ASTContext.h"
#include "clang/AST/RecordLayout.h"
@@ -183,7 +184,7 @@ bool ClangASTSource::FindExternalVisibleDeclsByName(
}
TagDecl *ClangASTSource::FindCompleteType(const TagDecl *decl) {
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_EXPRESSIONS));
+ Log *log = GetLog(LLDBLog::Expressions);
if (const NamespaceDecl *namespace_context =
dyn_cast<NamespaceDecl>(decl->getDeclContext())) {
@@ -278,7 +279,7 @@ TagDecl *ClangASTSource::FindCompleteType(const TagDecl *decl) {
}
void ClangASTSource::CompleteType(TagDecl *tag_decl) {
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_EXPRESSIONS));
+ Log *log = GetLog(LLDBLog::Expressions);
if (log) {
LLDB_LOG(log,
@@ -307,7 +308,7 @@ void ClangASTSource::CompleteType(TagDecl *tag_decl) {
}
void ClangASTSource::CompleteType(clang::ObjCInterfaceDecl *interface_decl) {
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_EXPRESSIONS));
+ Log *log = GetLog(LLDBLog::Expressions);
LLDB_LOG(log,
" [CompleteObjCInterfaceDecl] on (ASTContext*){0} '{1}' "
@@ -387,7 +388,7 @@ void ClangASTSource::FindExternalLexicalDecls(
llvm::function_ref<bool(Decl::Kind)> predicate,
llvm::SmallVectorImpl<Decl *> &decls) {
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_EXPRESSIONS));
+ Log *log = GetLog(LLDBLog::Expressions);
const Decl *context_decl = dyn_cast<Decl>(decl_context);
@@ -520,7 +521,7 @@ void ClangASTSource::FindExternalVisibleDecls(NameSearchContext &context) {
const ConstString name(context.m_decl_name.getAsString().c_str());
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_EXPRESSIONS));
+ Log *log = GetLog(LLDBLog::Expressions);
if (log) {
if (!context.m_decl_context)
@@ -597,7 +598,7 @@ void ClangASTSource::FindExternalVisibleDecls(
CompilerDeclContext &namespace_decl) {
assert(m_ast_context);
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_EXPRESSIONS));
+ Log *log = GetLog(LLDBLog::Expressions);
SymbolContextList sc_list;
@@ -668,7 +669,7 @@ void ClangASTSource::FillNamespaceMap(
if (IgnoreName(name, true))
return;
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_EXPRESSIONS));
+ Log *log = GetLog(LLDBLog::Expressions);
if (module_sp && namespace_decl) {
CompilerDeclContext found_namespace_decl;
@@ -833,7 +834,7 @@ bool ClangASTSource::FindObjCMethodDeclsWithOrigin(
if (!copied_method_decl)
continue;
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_EXPRESSIONS));
+ Log *log = GetLog(LLDBLog::Expressions);
LLDB_LOG(log, " CAS::FOMD found ({0}) {1}", log_info,
ClangUtil::DumpDecl(copied_method_decl));
@@ -846,7 +847,7 @@ bool ClangASTSource::FindObjCMethodDeclsWithOrigin(
void ClangASTSource::FindDeclInModules(NameSearchContext &context,
ConstString name) {
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_EXPRESSIONS));
+ Log *log = GetLog(LLDBLog::Expressions);
std::shared_ptr<ClangModulesDeclVendor> modules_decl_vendor =
GetClangModulesDeclVendor();
@@ -886,7 +887,7 @@ void ClangASTSource::FindDeclInModules(NameSearchContext &context,
void ClangASTSource::FindDeclInObjCRuntime(NameSearchContext &context,
ConstString name) {
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_EXPRESSIONS));
+ Log *log = GetLog(LLDBLog::Expressions);
lldb::ProcessSP process(m_target->GetProcessSP());
@@ -928,7 +929,7 @@ void ClangASTSource::FindDeclInObjCRuntime(NameSearchContext &context,
}
void ClangASTSource::FindObjCMethodDecls(NameSearchContext &context) {
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_EXPRESSIONS));
+ Log *log = GetLog(LLDBLog::Expressions);
const DeclarationName &decl_name(context.m_decl_name);
const DeclContext *decl_ctx(context.m_decl_context);
@@ -1208,7 +1209,7 @@ void ClangASTSource::FindObjCMethodDecls(NameSearchContext &context) {
static bool FindObjCPropertyAndIvarDeclsWithOrigin(
NameSearchContext &context, ClangASTSource &source,
DeclFromUser<const ObjCInterfaceDecl> &origin_iface_decl) {
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_EXPRESSIONS));
+ Log *log = GetLog(LLDBLog::Expressions);
if (origin_iface_decl.IsInvalid())
return false;
@@ -1255,7 +1256,7 @@ static bool FindObjCPropertyAndIvarDeclsWithOrigin(
}
void ClangASTSource::FindObjCPropertyAndIvarDecls(NameSearchContext &context) {
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_EXPRESSIONS));
+ Log *log = GetLog(LLDBLog::Expressions);
DeclFromParser<const ObjCInterfaceDecl> parser_iface_decl(
cast<ObjCInterfaceDecl>(context.m_decl_context));
@@ -1391,7 +1392,7 @@ void ClangASTSource::LookupInNamespace(NameSearchContext &context) {
const NamespaceDecl *namespace_context =
dyn_cast<NamespaceDecl>(context.m_decl_context);
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_EXPRESSIONS));
+ Log *log = GetLog(LLDBLog::Expressions);
ClangASTImporter::NamespaceMapSP namespace_map =
m_ast_importer_sp->GetNamespaceMap(namespace_context);
@@ -1498,7 +1499,7 @@ bool ClangASTSource::layoutRecordType(const RecordDecl *record, uint64_t &size,
BaseOffsetMap &base_offsets,
BaseOffsetMap &virtual_base_offsets) {
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_EXPRESSIONS));
+ Log *log = GetLog(LLDBLog::Expressions);
LLDB_LOG(log,
"LayoutRecordType on (ASTContext*){0} '{1}' for (RecordDecl*)"
@@ -1620,7 +1621,7 @@ void ClangASTSource::CompleteNamespaceMap(
ClangASTImporter::NamespaceMapSP &namespace_map, ConstString name,
ClangASTImporter::NamespaceMapSP &parent_map) const {
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_EXPRESSIONS));
+ Log *log = GetLog(LLDBLog::Expressions);
if (log) {
if (parent_map && parent_map->size())
diff --git a/lldb/source/Plugins/ExpressionParser/Clang/ClangDeclVendor.h b/lldb/source/Plugins/ExpressionParser/Clang/ClangDeclVendor.h
index 6313117c08d6..a9b2d4110ab2 100644
--- a/lldb/source/Plugins/ExpressionParser/Clang/ClangDeclVendor.h
+++ b/lldb/source/Plugins/ExpressionParser/Clang/ClangDeclVendor.h
@@ -22,7 +22,7 @@ class ClangDeclVendor : public DeclVendor {
public:
ClangDeclVendor(DeclVendorKind kind) : DeclVendor(kind) {}
- virtual ~ClangDeclVendor() = default;
+ ~ClangDeclVendor() override = default;
using DeclVendor::FindDecls;
diff --git a/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp b/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp
index 4af5d41a5921..cc45871bcd71 100644
--- a/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp
+++ b/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp
@@ -40,6 +40,7 @@
#include "lldb/Target/Target.h"
#include "lldb/Target/Thread.h"
#include "lldb/Utility/Endian.h"
+#include "lldb/Utility/LLDBLog.h"
#include "lldb/Utility/Log.h"
#include "lldb/Utility/RegisterValue.h"
#include "lldb/Utility/Status.h"
@@ -252,7 +253,7 @@ bool ClangExpressionDeclMap::AddPersistentVariable(const NamedDecl *decl,
return true;
}
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_EXPRESSIONS));
+ Log *log = GetLog(LLDBLog::Expressions);
ExecutionContext &exe_ctx = m_parser_vars->m_exe_ctx;
Target *target = exe_ctx.GetTargetPtr();
if (target == nullptr)
@@ -328,7 +329,7 @@ bool ClangExpressionDeclMap::AddValueToStruct(const NamedDecl *decl,
bool is_persistent_variable = false;
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_EXPRESSIONS));
+ Log *log = GetLog(LLDBLog::Expressions);
m_struct_vars->m_struct_laid_out = false;
@@ -646,7 +647,7 @@ void ClangExpressionDeclMap::FindExternalVisibleDecls(
const ConstString name(context.m_decl_name.getAsString().c_str());
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_EXPRESSIONS));
+ Log *log = GetLog(LLDBLog::Expressions);
if (log) {
if (!context.m_decl_context)
@@ -728,7 +729,7 @@ clang::NamedDecl *ClangExpressionDeclMap::GetPersistentDecl(ConstString name) {
void ClangExpressionDeclMap::SearchPersistenDecls(NameSearchContext &context,
const ConstString name) {
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_EXPRESSIONS));
+ Log *log = GetLog(LLDBLog::Expressions);
NamedDecl *persistent_decl = GetPersistentDecl(name);
@@ -756,7 +757,7 @@ void ClangExpressionDeclMap::SearchPersistenDecls(NameSearchContext &context,
}
void ClangExpressionDeclMap::LookUpLldbClass(NameSearchContext &context) {
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_EXPRESSIONS));
+ Log *log = GetLog(LLDBLog::Expressions);
StackFrame *frame = m_parser_vars->m_exe_ctx.GetFramePtr();
SymbolContext sym_ctx;
@@ -805,7 +806,7 @@ void ClangExpressionDeclMap::LookUpLldbClass(NameSearchContext &context) {
TypeFromUser class_user_type(class_qual_type.getAsOpaquePtr(),
function_decl_ctx.GetTypeSystem());
- LLDB_LOG(log, " CEDM::FEVD Adding type for $__lldb_class: {1}",
+ LLDB_LOG(log, " CEDM::FEVD Adding type for $__lldb_class: {0}",
class_qual_type.getAsString());
AddContextClassType(context, class_user_type);
@@ -847,7 +848,7 @@ void ClangExpressionDeclMap::LookUpLldbClass(NameSearchContext &context) {
TypeFromUser pointee_type =
this_type->GetForwardCompilerType().GetPointeeType();
- LLDB_LOG(log, " FEVD Adding type for $__lldb_class: {1}",
+ LLDB_LOG(log, " FEVD Adding type for $__lldb_class: {0}",
ClangUtil::GetQualType(pointee_type).getAsString());
AddContextClassType(context, pointee_type);
@@ -857,7 +858,7 @@ void ClangExpressionDeclMap::LookUpLldbClass(NameSearchContext &context) {
}
void ClangExpressionDeclMap::LookUpLldbObjCClass(NameSearchContext &context) {
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_EXPRESSIONS));
+ Log *log = GetLog(LLDBLog::Expressions);
StackFrame *frame = m_parser_vars->m_exe_ctx.GetFramePtr();
@@ -1014,7 +1015,7 @@ void ClangExpressionDeclMap::LookupLocalVarNamespace(
void ClangExpressionDeclMap::LookupInModulesDeclVendor(
NameSearchContext &context, ConstString name) {
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_EXPRESSIONS));
+ Log *log = GetLog(LLDBLog::Expressions);
if (!m_target)
return;
@@ -1036,7 +1037,7 @@ void ClangExpressionDeclMap::LookupInModulesDeclVendor(
LLDB_LOG(log,
" CAS::FEVD Matching decl found for "
- "\"{1}\" in the modules",
+ "\"{0}\" in the modules",
name);
clang::Decl *copied_decl = CopyDecl(decl_from_modules);
@@ -1331,7 +1332,7 @@ void ClangExpressionDeclMap::FindExternalVisibleDecls(
const CompilerDeclContext &namespace_decl) {
assert(m_ast_context);
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_EXPRESSIONS));
+ Log *log = GetLog(LLDBLog::Expressions);
const ConstString name(context.m_decl_name.getAsString().c_str());
if (IgnoreName(name, false))
@@ -1460,7 +1461,7 @@ bool ClangExpressionDeclMap::GetVariableValue(VariableSP &var,
lldb_private::Value &var_location,
TypeFromUser *user_type,
TypeFromParser *parser_type) {
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_EXPRESSIONS));
+ Log *log = GetLog(LLDBLog::Expressions);
Type *var_type = var->GetType();
@@ -1546,7 +1547,7 @@ void ClangExpressionDeclMap::AddOneVariable(NameSearchContext &context,
ValueObjectSP valobj) {
assert(m_parser_vars.get());
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_EXPRESSIONS));
+ Log *log = GetLog(LLDBLog::Expressions);
TypeFromUser ut;
TypeFromParser pt;
@@ -1594,13 +1595,13 @@ void ClangExpressionDeclMap::AddOneVariable(NameSearchContext &context,
if (is_reference)
entity->m_flags |= ClangExpressionVariable::EVTypeIsReference;
- LLDB_LOG(log, " CEDM::FEVD Found variable {1}, returned\n{2} (original {3})",
+ LLDB_LOG(log, " CEDM::FEVD Found variable {0}, returned\n{1} (original {2})",
decl_name, ClangUtil::DumpDecl(var_decl), ClangUtil::ToString(ut));
}
void ClangExpressionDeclMap::AddOneVariable(NameSearchContext &context,
ExpressionVariableSP &pvar_sp) {
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_EXPRESSIONS));
+ Log *log = GetLog(LLDBLog::Expressions);
TypeFromUser user_type(
llvm::cast<ClangExpressionVariable>(pvar_sp.get())->GetTypeFromUser());
@@ -1625,7 +1626,7 @@ void ClangExpressionDeclMap::AddOneVariable(NameSearchContext &context,
parser_vars->m_llvm_value = nullptr;
parser_vars->m_lldb_value.Clear();
- LLDB_LOG(log, " CEDM::FEVD Added pvar {1}, returned\n{2}",
+ LLDB_LOG(log, " CEDM::FEVD Added pvar {0}, returned\n{1}",
pvar_sp->GetName(), ClangUtil::DumpDecl(var_decl));
}
@@ -1633,7 +1634,7 @@ void ClangExpressionDeclMap::AddOneGenericVariable(NameSearchContext &context,
const Symbol &symbol) {
assert(m_parser_vars.get());
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_EXPRESSIONS));
+ Log *log = GetLog(LLDBLog::Expressions);
Target *target = m_parser_vars->m_exe_ctx.GetTargetPtr();
@@ -1677,13 +1678,13 @@ void ClangExpressionDeclMap::AddOneGenericVariable(NameSearchContext &context,
parser_vars->m_llvm_value = nullptr;
parser_vars->m_lldb_sym = &symbol;
- LLDB_LOG(log, " CEDM::FEVD Found variable {1}, returned\n{2}", decl_name,
+ LLDB_LOG(log, " CEDM::FEVD Found variable {0}, returned\n{1}", decl_name,
ClangUtil::DumpDecl(var_decl));
}
void ClangExpressionDeclMap::AddOneRegister(NameSearchContext &context,
const RegisterInfo *reg_info) {
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_EXPRESSIONS));
+ Log *log = GetLog(LLDBLog::Expressions);
CompilerType clang_type =
m_clang_ast_context->GetBuiltinTypeForEncodingAndBitSize(
@@ -1716,7 +1717,7 @@ void ClangExpressionDeclMap::AddOneRegister(NameSearchContext &context,
parser_vars->m_lldb_value.Clear();
entity->m_flags |= ClangExpressionVariable::EVBareRegister;
- LLDB_LOG(log, " CEDM::FEVD Added register {1}, returned\n{2}",
+ LLDB_LOG(log, " CEDM::FEVD Added register {0}, returned\n{1}",
context.m_decl_name.getAsString(), ClangUtil::DumpDecl(var_decl));
}
@@ -1725,7 +1726,7 @@ void ClangExpressionDeclMap::AddOneFunction(NameSearchContext &context,
Symbol *symbol) {
assert(m_parser_vars.get());
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_EXPRESSIONS));
+ Log *log = GetLog(LLDBLog::Expressions);
NamedDecl *function_decl = nullptr;
Address fun_address;
@@ -1766,7 +1767,7 @@ void ClangExpressionDeclMap::AddOneFunction(NameSearchContext &context,
LLDB_LOG(log,
" CEDM::FEVD Imported decl for function template"
- " {1} (description {2}), returned\n{3}",
+ " {0} (description {1}), returned\n{2}",
copied_function_template->getNameAsString(),
ss.GetData(),
ClangUtil::DumpDecl(copied_function_template));
@@ -1784,8 +1785,8 @@ void ClangExpressionDeclMap::AddOneFunction(NameSearchContext &context,
function->DumpSymbolContext(&ss);
LLDB_LOG(log,
- " CEDM::FEVD Imported decl for function {1} "
- "(description {2}), returned\n{3}",
+ " CEDM::FEVD Imported decl for function {0} "
+ "(description {1}), returned\n{2}",
copied_function_decl->getNameAsString(), ss.GetData(),
ClangUtil::DumpDecl(copied_function_decl));
}
@@ -1884,8 +1885,8 @@ void ClangExpressionDeclMap::AddOneFunction(NameSearchContext &context,
Address::DumpStyleResolvedDescription);
LLDB_LOG(log,
- " CEDM::FEVD Found {1} function {2} (description {3}), "
- "returned\n{4}",
+ " CEDM::FEVD Found {0} function {1} (description {2}), "
+ "returned\n{3}",
(function ? "specific" : "generic"), decl_name, ss.GetData(),
ClangUtil::DumpDecl(function_decl));
}
@@ -1895,7 +1896,7 @@ void ClangExpressionDeclMap::AddContextClassType(NameSearchContext &context,
const TypeFromUser &ut) {
CompilerType copied_clang_type = GuardedCopyType(ut);
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_EXPRESSIONS));
+ Log *log = GetLog(LLDBLog::Expressions);
if (!copied_clang_type) {
LLDB_LOG(log,
@@ -1961,7 +1962,7 @@ void ClangExpressionDeclMap::AddOneType(NameSearchContext &context,
CompilerType copied_clang_type = GuardedCopyType(ut);
if (!copied_clang_type) {
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_EXPRESSIONS));
+ Log *log = GetLog(LLDBLog::Expressions);
LLDB_LOG(log,
"ClangExpressionDeclMap::AddOneType - Couldn't import the type");
diff --git a/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp b/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp
index 51f34369c383..fad0f724e4c8 100644
--- a/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp
+++ b/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp
@@ -84,6 +84,7 @@
#include "lldb/Target/ThreadPlanCallFunction.h"
#include "lldb/Utility/DataBufferHeap.h"
#include "lldb/Utility/LLDBAssert.h"
+#include "lldb/Utility/LLDBLog.h"
#include "lldb/Utility/Log.h"
#include "lldb/Utility/ReproducerProvider.h"
#include "lldb/Utility/Stream.h"
@@ -189,7 +190,7 @@ public:
// when we move the expression result ot the ScratchASTContext). Let's at
// least log these diagnostics until we find a way to properly render
// them and display them to the user.
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_EXPRESSIONS));
+ Log *log = GetLog(LLDBLog::Expressions);
if (log) {
llvm::SmallVector<char, 32> diag_str;
Info.FormatDiagnostic(diag_str);
@@ -282,7 +283,7 @@ private:
static void SetupModuleHeaderPaths(CompilerInstance *compiler,
std::vector<std::string> include_directories,
lldb::TargetSP target_sp) {
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_EXPRESSIONS));
+ Log *log = GetLog(LLDBLog::Expressions);
HeaderSearchOptions &search_opts = compiler->getHeaderSearchOpts();
@@ -364,7 +365,7 @@ ClangExpressionParser::ClangExpressionParser(
m_pp_callbacks(nullptr),
m_include_directories(std::move(include_directories)),
m_filename(std::move(filename)) {
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_EXPRESSIONS));
+ Log *log = GetLog(LLDBLog::Expressions);
// We can't compile expressions without a target. So if the exe_scope is
// null or doesn't have a target, then we just need to get out of here. I'll
@@ -1325,7 +1326,7 @@ lldb_private::Status ClangExpressionParser::PrepareForExecution(
bool &can_interpret, ExecutionPolicy execution_policy) {
func_addr = LLDB_INVALID_ADDRESS;
func_end = LLDB_INVALID_ADDRESS;
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_EXPRESSIONS));
+ Log *log = GetLog(LLDBLog::Expressions);
lldb_private::Status err;
diff --git a/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionSourceCode.cpp b/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionSourceCode.cpp
index 977a461e3f6f..5168f637c443 100644
--- a/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionSourceCode.cpp
+++ b/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionSourceCode.cpp
@@ -88,8 +88,7 @@ class AddMacroState {
public:
AddMacroState(const FileSpec &current_file, const uint32_t current_file_line)
- : m_state(CURRENT_FILE_NOT_YET_PUSHED), m_current_file(current_file),
- m_current_file_line(current_file_line) {}
+ : m_current_file(current_file), m_current_file_line(current_file_line) {}
void StartFile(const FileSpec &file) {
m_file_stack.push_back(file);
@@ -127,7 +126,7 @@ public:
private:
std::vector<FileSpec> m_file_stack;
- State m_state;
+ State m_state = CURRENT_FILE_NOT_YET_PUSHED;
FileSpec m_current_file;
uint32_t m_current_file_line;
};
diff --git a/lldb/source/Plugins/ExpressionParser/Clang/ClangFunctionCaller.cpp b/lldb/source/Plugins/ExpressionParser/Clang/ClangFunctionCaller.cpp
index 2cfa9a4c9ccf..f1449c02c9dc 100644
--- a/lldb/source/Plugins/ExpressionParser/Clang/ClangFunctionCaller.cpp
+++ b/lldb/source/Plugins/ExpressionParser/Clang/ClangFunctionCaller.cpp
@@ -37,6 +37,7 @@
#include "lldb/Target/ThreadPlan.h"
#include "lldb/Target/ThreadPlanCallFunction.h"
#include "lldb/Utility/DataExtractor.h"
+#include "lldb/Utility/LLDBLog.h"
#include "lldb/Utility/Log.h"
#include "lldb/Utility/State.h"
@@ -180,7 +181,7 @@ ClangFunctionCaller::CompileFunction(lldb::ThreadSP thread_to_use_sp,
m_wrapper_function_text.append(args_list_buffer);
m_wrapper_function_text.append(");\n}\n");
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_EXPRESSIONS));
+ Log *log = GetLog(LLDBLog::Expressions);
LLDB_LOGF(log, "Expression: \n\n%s\n\n", m_wrapper_function_text.c_str());
// Okay, now compile this expression
diff --git a/lldb/source/Plugins/ExpressionParser/Clang/ClangHost.cpp b/lldb/source/Plugins/ExpressionParser/Clang/ClangHost.cpp
index b76fa6fbf690..2099cfaaefec 100644
--- a/lldb/source/Plugins/ExpressionParser/Clang/ClangHost.cpp
+++ b/lldb/source/Plugins/ExpressionParser/Clang/ClangHost.cpp
@@ -20,6 +20,7 @@
#include "lldb/Host/FileSystem.h"
#include "lldb/Host/HostInfo.h"
#include "lldb/Utility/FileSpec.h"
+#include "lldb/Utility/LLDBLog.h"
#include "lldb/Utility/Log.h"
#include <string>
@@ -29,7 +30,7 @@ using namespace lldb_private;
static bool VerifyClangPath(const llvm::Twine &clang_path) {
if (FileSystem::Instance().IsDirectory(clang_path))
return true;
- Log *log = lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_HOST);
+ Log *log = GetLog(LLDBLog::Host);
LLDB_LOGF(log,
"VerifyClangPath(): "
"failed to stat clang resource directory at \"%s\"",
@@ -47,7 +48,7 @@ static bool VerifyClangPath(const llvm::Twine &clang_path) {
static bool DefaultComputeClangResourceDirectory(FileSpec &lldb_shlib_spec,
FileSpec &file_spec,
bool verify) {
- Log *log = lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_HOST);
+ Log *log = GetLog(LLDBLog::Host);
std::string raw_path = lldb_shlib_spec.GetPath();
llvm::StringRef parent_dir = llvm::sys::path::parent_path(raw_path);
@@ -157,7 +158,7 @@ FileSpec lldb_private::GetClangResourceDir() {
if (FileSpec lldb_file_spec = HostInfo::GetShlibDir())
ComputeClangResourceDirectory(lldb_file_spec, g_cached_resource_dir,
true);
- Log *log = lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_HOST);
+ Log *log = GetLog(LLDBLog::Host);
LLDB_LOGF(log, "GetClangResourceDir() => '%s'",
g_cached_resource_dir.GetPath().c_str());
});
diff --git a/lldb/source/Plugins/ExpressionParser/Clang/ClangModulesDeclVendor.cpp b/lldb/source/Plugins/ExpressionParser/Clang/ClangModulesDeclVendor.cpp
index 336058a5abb9..38dd55bc76d3 100644
--- a/lldb/source/Plugins/ExpressionParser/Clang/ClangModulesDeclVendor.cpp
+++ b/lldb/source/Plugins/ExpressionParser/Clang/ClangModulesDeclVendor.cpp
@@ -32,6 +32,7 @@
#include "lldb/Target/Target.h"
#include "lldb/Utility/FileSpec.h"
#include "lldb/Utility/LLDBAssert.h"
+#include "lldb/Utility/LLDBLog.h"
#include "lldb/Utility/Log.h"
#include "lldb/Utility/ReproducerProvider.h"
#include "lldb/Utility/StreamString.h"
@@ -130,7 +131,7 @@ private:
} // anonymous namespace
StoringDiagnosticConsumer::StoringDiagnosticConsumer() {
- m_log = lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_EXPRESSIONS);
+ m_log = GetLog(LLDBLog::Expressions);
clang::DiagnosticOptions *m_options = new clang::DiagnosticOptions();
m_os = std::make_shared<llvm::raw_string_ostream>(m_output);
@@ -517,8 +518,9 @@ void ClangModulesDeclVendorImpl::ForEachMacro(
bool first_token = true;
- for (clang::MacroInfo::tokens_iterator ti = macro_info->tokens_begin(),
- te = macro_info->tokens_end();
+ for (clang::MacroInfo::const_tokens_iterator
+ ti = macro_info->tokens_begin(),
+ te = macro_info->tokens_end();
ti != te; ++ti) {
if (!first_token)
macro_expansion.append(" ");
@@ -656,14 +658,16 @@ ClangModulesDeclVendor::Create(Target &target) {
for (const std::string &arg : compiler_invocation_arguments)
compiler_invocation_argument_cstrs.push_back(arg.c_str());
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_EXPRESSIONS));
+ Log *log = GetLog(LLDBLog::Expressions);
LLDB_LOG(log, "ClangModulesDeclVendor's compiler flags {0:$[ ]}",
llvm::make_range(compiler_invocation_arguments.begin(),
compiler_invocation_arguments.end()));
+ clang::CreateInvocationOptions CIOpts;
+ CIOpts.Diags = diagnostics_engine;
std::shared_ptr<clang::CompilerInvocation> invocation =
- clang::createInvocationFromCommandLine(compiler_invocation_argument_cstrs,
- diagnostics_engine);
+ clang::createInvocation(compiler_invocation_argument_cstrs,
+ std::move(CIOpts));
if (!invocation)
return nullptr;
@@ -724,8 +728,8 @@ ClangModulesDeclVendor::Create(Target &target) {
parser->Initialize();
clang::Parser::DeclGroupPtrTy parsed;
-
- while (!parser->ParseTopLevelDecl(parsed))
+ auto ImportState = clang::Sema::ModuleImportState::NotACXX20Module;
+ while (!parser->ParseTopLevelDecl(parsed, ImportState))
;
return new ClangModulesDeclVendorImpl(std::move(diagnostics_engine),
diff --git a/lldb/source/Plugins/ExpressionParser/Clang/ClangUserExpression.cpp b/lldb/source/Plugins/ExpressionParser/Clang/ClangUserExpression.cpp
index 1437d7b58293..78b8bf11220a 100644
--- a/lldb/source/Plugins/ExpressionParser/Clang/ClangUserExpression.cpp
+++ b/lldb/source/Plugins/ExpressionParser/Clang/ClangUserExpression.cpp
@@ -49,6 +49,7 @@
#include "lldb/Target/ThreadPlan.h"
#include "lldb/Target/ThreadPlanCallUserExpression.h"
#include "lldb/Utility/ConstString.h"
+#include "lldb/Utility/LLDBLog.h"
#include "lldb/Utility/Log.h"
#include "lldb/Utility/StreamString.h"
@@ -89,7 +90,7 @@ ClangUserExpression::ClangUserExpression(
ClangUserExpression::~ClangUserExpression() = default;
void ClangUserExpression::ScanContext(ExecutionContext &exe_ctx, Status &err) {
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_EXPRESSIONS));
+ Log *log = GetLog(LLDBLog::Expressions);
LLDB_LOGF(log, "ClangUserExpression::ScanContext()");
@@ -456,14 +457,14 @@ static bool SupportsCxxModuleImport(lldb::LanguageType language) {
/// Utility method that puts a message into the expression log and
/// returns an invalid module configuration.
static CppModuleConfiguration LogConfigError(const std::string &msg) {
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_EXPRESSIONS));
+ Log *log = GetLog(LLDBLog::Expressions);
LLDB_LOG(log, "[C++ module config] {0}", msg);
return CppModuleConfiguration();
}
CppModuleConfiguration GetModuleConfig(lldb::LanguageType language,
ExecutionContext &exe_ctx) {
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_EXPRESSIONS));
+ Log *log = GetLog(LLDBLog::Expressions);
// Don't do anything if this is not a C++ module configuration.
if (!SupportsCxxModuleImport(language))
@@ -621,7 +622,7 @@ bool ClangUserExpression::TryParse(
}
void ClangUserExpression::SetupCppModuleImports(ExecutionContext &exe_ctx) {
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_EXPRESSIONS));
+ Log *log = GetLog(LLDBLog::Expressions);
CppModuleConfiguration module_config = GetModuleConfig(m_language, exe_ctx);
m_imported_cpp_modules = module_config.GetImportedModules();
@@ -647,7 +648,7 @@ bool ClangUserExpression::Parse(DiagnosticManager &diagnostic_manager,
lldb_private::ExecutionPolicy execution_policy,
bool keep_result_in_memory,
bool generate_debug_info) {
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_EXPRESSIONS));
+ Log *log = GetLog(LLDBLog::Expressions);
if (!PrepareForParsing(diagnostic_manager, exe_ctx, /*for_completion*/ false))
return false;
@@ -806,7 +807,7 @@ static void AbsPosToLineColumnPos(size_t abs_pos, llvm::StringRef code,
bool ClangUserExpression::Complete(ExecutionContext &exe_ctx,
CompletionRequest &request,
unsigned complete_pos) {
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_EXPRESSIONS));
+ Log *log = GetLog(LLDBLog::Expressions);
// We don't want any visible feedback when completing an expression. Mostly
// because the results we get from an incomplete invocation are probably not
@@ -857,7 +858,7 @@ bool ClangUserExpression::Complete(ExecutionContext &exe_ctx,
// The line and column of the user expression inside the transformed source
// code.
unsigned user_expr_line, user_expr_column;
- if (m_user_expression_start_pos.hasValue())
+ if (m_user_expression_start_pos)
AbsPosToLineColumnPos(*m_user_expression_start_pos, m_transformed_text,
user_expr_line, user_expr_column);
else
diff --git a/lldb/source/Plugins/ExpressionParser/Clang/CxxModuleHandler.cpp b/lldb/source/Plugins/ExpressionParser/Clang/CxxModuleHandler.cpp
index fecffd1183f8..9453cdc3a451 100644
--- a/lldb/source/Plugins/ExpressionParser/Clang/CxxModuleHandler.cpp
+++ b/lldb/source/Plugins/ExpressionParser/Clang/CxxModuleHandler.cpp
@@ -9,6 +9,7 @@
#include "Plugins/ExpressionParser/Clang/CxxModuleHandler.h"
#include "Plugins/TypeSystem/Clang/TypeSystemClang.h"
+#include "lldb/Utility/LLDBLog.h"
#include "lldb/Utility/Log.h"
#include "clang/Sema/Lookup.h"
#include "llvm/Support/Error.h"
@@ -180,7 +181,7 @@ T *createDecl(ASTImporter &importer, Decl *from_d, Args &&... args) {
}
llvm::Optional<Decl *> CxxModuleHandler::tryInstantiateStdTemplate(Decl *d) {
- Log *log = lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_EXPRESSIONS);
+ Log *log = GetLog(LLDBLog::Expressions);
// If we don't have a template to instiantiate, then there is nothing to do.
auto td = dyn_cast<ClassTemplateSpecializationDecl>(d);
diff --git a/lldb/source/Plugins/ExpressionParser/Clang/IRDynamicChecks.cpp b/lldb/source/Plugins/ExpressionParser/Clang/IRDynamicChecks.cpp
index 8b132b54b7e6..0a4af196857c 100644
--- a/lldb/source/Plugins/ExpressionParser/Clang/IRDynamicChecks.cpp
+++ b/lldb/source/Plugins/ExpressionParser/Clang/IRDynamicChecks.cpp
@@ -22,6 +22,7 @@
#include "lldb/Target/StackFrame.h"
#include "lldb/Target/Target.h"
#include "lldb/Utility/ConstString.h"
+#include "lldb/Utility/LLDBLog.h"
#include "lldb/Utility/Log.h"
#include "Plugins/LanguageRuntime/ObjC/ObjCLanguageRuntime.h"
@@ -136,8 +137,7 @@ public:
/// The module being instrumented.
Instrumenter(llvm::Module &module,
std::shared_ptr<UtilityFunction> checker_function)
- : m_module(module), m_checker_function(checker_function),
- m_i8ptr_ty(nullptr), m_intptr_ty(nullptr) {}
+ : m_module(module), m_checker_function(checker_function) {}
virtual ~Instrumenter() = default;
@@ -301,8 +301,8 @@ protected:
m_checker_function; ///< The dynamic checker function for the process
private:
- PointerType *m_i8ptr_ty;
- IntegerType *m_intptr_ty;
+ PointerType *m_i8ptr_ty = nullptr;
+ IntegerType *m_intptr_ty = nullptr;
};
class ValidPointerChecker : public Instrumenter {
@@ -316,7 +316,7 @@ public:
protected:
bool InstrumentInstruction(llvm::Instruction *inst) override {
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_EXPRESSIONS));
+ Log *log = GetLog(LLDBLog::Expressions);
LLDB_LOGF(log, "Instrumenting load/store instruction: %s\n",
PrintValue(inst).c_str());
@@ -467,7 +467,7 @@ protected:
}
bool InspectInstruction(llvm::Instruction &i) override {
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_EXPRESSIONS));
+ Log *log = GetLog(LLDBLog::Expressions);
CallInst *call_inst = dyn_cast<CallInst>(&i);
@@ -538,7 +538,7 @@ IRDynamicChecks::IRDynamicChecks(
IRDynamicChecks::~IRDynamicChecks() = default;
bool IRDynamicChecks::runOnModule(llvm::Module &M) {
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_EXPRESSIONS));
+ Log *log = GetLog(LLDBLog::Expressions);
llvm::Function *function = M.getFunction(StringRef(m_func_name));
diff --git a/lldb/source/Plugins/ExpressionParser/Clang/IRDynamicChecks.h b/lldb/source/Plugins/ExpressionParser/Clang/IRDynamicChecks.h
index a4de527e4512..4abd16c5c326 100644
--- a/lldb/source/Plugins/ExpressionParser/Clang/IRDynamicChecks.h
+++ b/lldb/source/Plugins/ExpressionParser/Clang/IRDynamicChecks.h
@@ -30,7 +30,7 @@ public:
ClangDynamicCheckerFunctions();
/// Destructor
- virtual ~ClangDynamicCheckerFunctions();
+ ~ClangDynamicCheckerFunctions() override;
static bool classof(const DynamicCheckerFunctions *checker_funcs) {
return checker_funcs->GetKind() == DCF_Clang;
diff --git a/lldb/source/Plugins/ExpressionParser/Clang/IRForTarget.cpp b/lldb/source/Plugins/ExpressionParser/Clang/IRForTarget.cpp
index e0e41925f7ef..047aa1e7c084 100644
--- a/lldb/source/Plugins/ExpressionParser/Clang/IRForTarget.cpp
+++ b/lldb/source/Plugins/ExpressionParser/Clang/IRForTarget.cpp
@@ -34,6 +34,7 @@
#include "lldb/Utility/ConstString.h"
#include "lldb/Utility/DataBufferHeap.h"
#include "lldb/Utility/Endian.h"
+#include "lldb/Utility/LLDBLog.h"
#include "lldb/Utility/Log.h"
#include "lldb/Utility/Scalar.h"
#include "lldb/Utility/StreamString.h"
@@ -41,6 +42,7 @@
#include <map>
using namespace llvm;
+using lldb_private::LLDBLog;
typedef SmallVector<Instruction *, 2> InstrList;
@@ -158,8 +160,7 @@ static bool isGuardVariableSymbol(llvm::StringRef mangled_symbol,
}
bool IRForTarget::CreateResultVariable(llvm::Function &llvm_function) {
- lldb_private::Log *log(
- lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_EXPRESSIONS));
+ lldb_private::Log *log(GetLog(LLDBLog::Expressions));
if (!m_resolve_vars)
return true;
@@ -322,14 +323,13 @@ bool IRForTarget::CreateResultVariable(llvm::Function &llvm_function) {
LLDB_LOG(log, "Creating a new result global: \"{0}\" with size {1}",
m_result_name,
- m_result_type.GetByteSize(target_sp.get()).getValueOr(0));
+ m_result_type.GetByteSize(target_sp.get()).value_or(0));
// Construct a new result global and set up its metadata
GlobalVariable *new_result_global = new GlobalVariable(
- (*m_module), result_global->getType()->getElementType(),
- false, /* not constant */
- GlobalValue::ExternalLinkage, nullptr, /* no initializer */
+ (*m_module), result_global->getValueType(), false, /* not constant */
+ GlobalValue::ExternalLinkage, nullptr, /* no initializer */
m_result_name.GetCString());
// It's too late in compilation to create a new VarDecl for this, but we
@@ -399,8 +399,7 @@ bool IRForTarget::CreateResultVariable(llvm::Function &llvm_function) {
bool IRForTarget::RewriteObjCConstString(llvm::GlobalVariable *ns_str,
llvm::GlobalVariable *cstr) {
- lldb_private::Log *log(
- lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_EXPRESSIONS));
+ lldb_private::Log *log(GetLog(LLDBLog::Expressions));
Type *ns_str_ty = ns_str->getType();
@@ -537,8 +536,7 @@ bool IRForTarget::RewriteObjCConstString(llvm::GlobalVariable *ns_str,
}
bool IRForTarget::RewriteObjCConstStrings() {
- lldb_private::Log *log(
- lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_EXPRESSIONS));
+ lldb_private::Log *log(GetLog(LLDBLog::Expressions));
ValueSymbolTable &value_symbol_table = m_module->getValueSymbolTable();
@@ -617,29 +615,7 @@ bool IRForTarget::RewriteObjCConstStrings() {
return false;
}
- ConstantExpr *nsstring_expr = dyn_cast<ConstantExpr>(nsstring_member);
-
- if (!nsstring_expr) {
- LLDB_LOG(log,
- "NSString initializer's str element is not a ConstantExpr");
-
- m_error_stream.Printf("Internal error [IRForTarget]: An Objective-C "
- "constant string's string initializer is not "
- "constant\n");
-
- return false;
- }
-
- GlobalVariable *cstr_global = nullptr;
-
- if (nsstring_expr->getOpcode() == Instruction::GetElementPtr) {
- Constant *nsstring_cstr = nsstring_expr->getOperand(0);
- cstr_global = dyn_cast<GlobalVariable>(nsstring_cstr);
- } else if (nsstring_expr->getOpcode() == Instruction::BitCast) {
- Constant *nsstring_cstr = nsstring_expr->getOperand(0);
- cstr_global = dyn_cast<GlobalVariable>(nsstring_cstr);
- }
-
+ auto *cstr_global = dyn_cast<GlobalVariable>(nsstring_member);
if (!cstr_global) {
LLDB_LOG(log,
"NSString initializer's str element is not a GlobalVariable");
@@ -750,8 +726,7 @@ static bool IsObjCSelectorRef(Value *value) {
// This function does not report errors; its callers are responsible.
bool IRForTarget::RewriteObjCSelector(Instruction *selector_load) {
- lldb_private::Log *log(
- lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_EXPRESSIONS));
+ lldb_private::Log *log(GetLog(LLDBLog::Expressions));
LoadInst *load = dyn_cast<LoadInst>(selector_load);
@@ -761,17 +736,16 @@ bool IRForTarget::RewriteObjCSelector(Instruction *selector_load) {
// Unpack the message name from the selector. In LLVM IR, an objc_msgSend
// gets represented as
//
- // %tmp = load i8** @"OBJC_SELECTOR_REFERENCES_" ; <i8*> %call = call
- // i8* (i8*, i8*, ...)* @objc_msgSend(i8* %obj, i8* %tmp, ...) ; <i8*>
+ // %sel = load ptr, ptr @OBJC_SELECTOR_REFERENCES_, align 8
+ // call i8 @objc_msgSend(ptr %obj, ptr %sel, ...)
//
- // where %obj is the object pointer and %tmp is the selector.
+ // where %obj is the object pointer and %sel is the selector.
//
// @"OBJC_SELECTOR_REFERENCES_" is a pointer to a character array called
// @"\01L_OBJC_llvm_moduleETH_VAR_NAllvm_moduleE_".
// @"\01L_OBJC_llvm_moduleETH_VAR_NAllvm_moduleE_" contains the string.
- // Find the pointer's initializer (a ConstantExpr with opcode GetElementPtr)
- // and get the string from its target
+ // Find the pointer's initializer and get the string from its target.
GlobalVariable *_objc_selector_references_ =
dyn_cast<GlobalVariable>(load->getPointerOperand());
@@ -781,22 +755,13 @@ bool IRForTarget::RewriteObjCSelector(Instruction *selector_load) {
return false;
Constant *osr_initializer = _objc_selector_references_->getInitializer();
-
- ConstantExpr *osr_initializer_expr = dyn_cast<ConstantExpr>(osr_initializer);
-
- if (!osr_initializer_expr ||
- osr_initializer_expr->getOpcode() != Instruction::GetElementPtr)
- return false;
-
- Value *osr_initializer_base = osr_initializer_expr->getOperand(0);
-
- if (!osr_initializer_base)
+ if (!osr_initializer)
return false;
// Find the string's initializer (a ConstantArray) and get the string from it
GlobalVariable *_objc_meth_var_name_ =
- dyn_cast<GlobalVariable>(osr_initializer_base);
+ dyn_cast<GlobalVariable>(osr_initializer);
if (!_objc_meth_var_name_ || !_objc_meth_var_name_->hasInitializer())
return false;
@@ -877,8 +842,7 @@ bool IRForTarget::RewriteObjCSelector(Instruction *selector_load) {
}
bool IRForTarget::RewriteObjCSelectors(BasicBlock &basic_block) {
- lldb_private::Log *log(
- lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_EXPRESSIONS));
+ lldb_private::Log *log(GetLog(LLDBLog::Expressions));
InstrList selector_loads;
@@ -912,8 +876,7 @@ static bool IsObjCClassReference(Value *value) {
// This function does not report errors; its callers are responsible.
bool IRForTarget::RewriteObjCClassReference(Instruction *class_load) {
- lldb_private::Log *log(
- lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_EXPRESSIONS));
+ lldb_private::Log *log(GetLog(LLDBLog::Expressions));
LoadInst *load = dyn_cast<LoadInst>(class_load);
@@ -1029,8 +992,7 @@ bool IRForTarget::RewriteObjCClassReference(Instruction *class_load) {
}
bool IRForTarget::RewriteObjCClassReferences(BasicBlock &basic_block) {
- lldb_private::Log *log(
- lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_EXPRESSIONS));
+ lldb_private::Log *log(GetLog(LLDBLog::Expressions));
InstrList class_loads;
@@ -1057,8 +1019,7 @@ bool IRForTarget::RewriteObjCClassReferences(BasicBlock &basic_block) {
// This function does not report errors; its callers are responsible.
bool IRForTarget::RewritePersistentAlloc(llvm::Instruction *persistent_alloc) {
- lldb_private::Log *log(
- lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_EXPRESSIONS));
+ lldb_private::Log *log(GetLog(LLDBLog::Expressions));
AllocaInst *alloc = dyn_cast<AllocaInst>(persistent_alloc);
@@ -1112,9 +1073,8 @@ bool IRForTarget::RewritePersistentAlloc(llvm::Instruction *persistent_alloc) {
// Now, since the variable is a pointer variable, we will drop in a load of
// that pointer variable.
- LoadInst *persistent_load =
- new LoadInst(persistent_global->getType()->getPointerElementType(),
- persistent_global, "", alloc);
+ LoadInst *persistent_load = new LoadInst(persistent_global->getValueType(),
+ persistent_global, "", alloc);
LLDB_LOG(log, "Replacing \"{0}\" with \"{1}\"", PrintValue(alloc),
PrintValue(persistent_load));
@@ -1129,8 +1089,7 @@ bool IRForTarget::RewritePersistentAllocs(llvm::BasicBlock &basic_block) {
if (!m_resolve_vars)
return true;
- lldb_private::Log *log(
- lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_EXPRESSIONS));
+ lldb_private::Log *log(GetLog(LLDBLog::Expressions));
InstrList pvar_allocs;
@@ -1171,8 +1130,7 @@ bool IRForTarget::RewritePersistentAllocs(llvm::BasicBlock &basic_block) {
// This function does not report errors; its callers are responsible.
bool IRForTarget::MaybeHandleVariable(Value *llvm_value_ptr) {
- lldb_private::Log *log(
- lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_EXPRESSIONS));
+ lldb_private::Log *log(GetLog(LLDBLog::Expressions));
LLDB_LOG(log, "MaybeHandleVariable ({0})", PrintValue(llvm_value_ptr));
@@ -1266,8 +1224,7 @@ bool IRForTarget::MaybeHandleVariable(Value *llvm_value_ptr) {
// This function does not report errors; its callers are responsible.
bool IRForTarget::HandleSymbol(Value *symbol) {
- lldb_private::Log *log(
- lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_EXPRESSIONS));
+ lldb_private::Log *log(GetLog(LLDBLog::Expressions));
lldb_private::ConstString name(symbol->getName().str().c_str());
@@ -1298,8 +1255,7 @@ bool IRForTarget::HandleSymbol(Value *symbol) {
}
bool IRForTarget::MaybeHandleCallArguments(CallInst *Old) {
- lldb_private::Log *log(
- lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_EXPRESSIONS));
+ lldb_private::Log *log(GetLog(LLDBLog::Expressions));
LLDB_LOG(log, "MaybeHandleCallArguments({0})", PrintValue(Old));
@@ -1317,8 +1273,7 @@ bool IRForTarget::MaybeHandleCallArguments(CallInst *Old) {
}
bool IRForTarget::HandleObjCClass(Value *classlist_reference) {
- lldb_private::Log *log(
- lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_EXPRESSIONS));
+ lldb_private::Log *log(GetLog(LLDBLog::Expressions));
GlobalVariable *global_variable =
dyn_cast<GlobalVariable>(classlist_reference);
@@ -1419,8 +1374,7 @@ bool IRForTarget::ResolveCalls(BasicBlock &basic_block) {
}
bool IRForTarget::ResolveExternals(Function &llvm_function) {
- lldb_private::Log *log(
- lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_EXPRESSIONS));
+ lldb_private::Log *log(GetLog(LLDBLog::Expressions));
for (GlobalVariable &global_var : m_module->globals()) {
llvm::StringRef global_name = global_var.getName();
@@ -1638,8 +1592,7 @@ bool IRForTarget::ReplaceVariables(Function &llvm_function) {
if (!m_resolve_vars)
return true;
- lldb_private::Log *log(
- lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_EXPRESSIONS));
+ lldb_private::Log *log(GetLog(LLDBLog::Expressions));
m_decl_map->DoStructLayout();
@@ -1772,20 +1725,19 @@ bool IRForTarget::ReplaceVariables(Function &llvm_function) {
llvm::Instruction *entry_instruction = llvm::cast<Instruction>(
m_entry_instruction_finder.GetValue(function));
+ Type *int8Ty = Type::getInt8Ty(function->getContext());
ConstantInt *offset_int(
ConstantInt::get(offset_type, offset, true));
GetElementPtrInst *get_element_ptr = GetElementPtrInst::Create(
- argument->getType()->getPointerElementType(), argument,
- offset_int, "", entry_instruction);
+ int8Ty, argument, offset_int, "", entry_instruction);
if (name == m_result_name && !m_result_is_pointer) {
BitCastInst *bit_cast = new BitCastInst(
get_element_ptr, value->getType()->getPointerTo(), "",
entry_instruction);
- LoadInst *load =
- new LoadInst(bit_cast->getType()->getPointerElementType(),
- bit_cast, "", entry_instruction);
+ LoadInst *load = new LoadInst(value->getType(), bit_cast, "",
+ entry_instruction);
return load;
} else {
@@ -1827,8 +1779,7 @@ bool IRForTarget::ReplaceVariables(Function &llvm_function) {
}
bool IRForTarget::runOnModule(Module &llvm_module) {
- lldb_private::Log *log(
- lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_EXPRESSIONS));
+ lldb_private::Log *log(GetLog(LLDBLog::Expressions));
m_module = &llvm_module;
m_target_data = std::make_unique<DataLayout>(m_module);
diff --git a/lldb/source/Plugins/ExpressionParser/Clang/NameSearchContext.cpp b/lldb/source/Plugins/ExpressionParser/Clang/NameSearchContext.cpp
index 8709c2b0dcea..a672045dfe31 100644
--- a/lldb/source/Plugins/ExpressionParser/Clang/NameSearchContext.cpp
+++ b/lldb/source/Plugins/ExpressionParser/Clang/NameSearchContext.cpp
@@ -8,6 +8,7 @@
#include "NameSearchContext.h"
#include "ClangUtil.h"
+#include "lldb/Utility/LLDBLog.h"
using namespace clang;
using namespace lldb_private;
@@ -106,7 +107,7 @@ clang::NamedDecl *NameSearchContext::AddFunDecl(const CompilerType &type,
func_decl->setParams(ArrayRef<ParmVarDecl *>(parm_var_decls));
} else {
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_EXPRESSIONS));
+ Log *log = GetLog(LLDBLog::Expressions);
LLDB_LOG(log, "Function type wasn't a FunctionProtoType");
}