[Lldb-commits] [lldb] 93b6e19 - [lldb] Initialize NameSearchContext::m_namespace_map in constructor
Raphael Isemann via lldb-commits
lldb-commits at lists.llvm.org
Tue Feb 25 04:27:34 PST 2020
Author: Raphael Isemann
Date: 2020-02-25T13:20:54+01:00
New Revision: 93b6e1924081874039e6c88828db8e0ab7bbba04
URL: https://github.com/llvm/llvm-project/commit/93b6e1924081874039e6c88828db8e0ab7bbba04
DIFF: https://github.com/llvm/llvm-project/commit/93b6e1924081874039e6c88828db8e0ab7bbba04.diff
LOG: [lldb] Initialize NameSearchContext::m_namespace_map in constructor
This member is for some reason initialized in ClangASTSource::FindExternalVisibleDecls
so all other functions using this member dereference a nullptr unless we
call this function before that. Let's just initialize this in the constructor.
This should be NFC as the only side effect is that we don't reset the namespace map
when calling ClangASTSource::FindExternalVisibleDecls multiple times (and we never
call this function multiple times for one NameSearchContext from what I can see).
Added:
Modified:
lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.cpp
lldb/source/Plugins/ExpressionParser/Clang/NameSearchContext.h
Removed:
################################################################################
diff --git a/lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.cpp b/lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.cpp
index a6910a140865..bf0a354c890b 100644
--- a/lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.cpp
+++ b/lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.cpp
@@ -551,8 +551,6 @@ void ClangASTSource::FindExternalVisibleDecls(NameSearchContext &context) {
context.m_decl_context->getDeclKindName());
}
- context.m_namespace_map = std::make_shared<ClangASTImporter::NamespaceMap>();
-
if (isa<NamespaceDecl>(context.m_decl_context)) {
LookupInNamespace(context);
} else if (isa<ObjCInterfaceDecl>(context.m_decl_context)) {
diff --git a/lldb/source/Plugins/ExpressionParser/Clang/NameSearchContext.h b/lldb/source/Plugins/ExpressionParser/Clang/NameSearchContext.h
index 4f6b68b302aa..52d2a19a404b 100644
--- a/lldb/source/Plugins/ExpressionParser/Clang/NameSearchContext.h
+++ b/lldb/source/Plugins/ExpressionParser/Clang/NameSearchContext.h
@@ -64,8 +64,10 @@ struct NameSearchContext {
NameSearchContext(TypeSystemClang &clang_ts,
llvm::SmallVectorImpl<clang::NamedDecl *> &decls,
clang::DeclarationName &name, const clang::DeclContext *dc)
- : m_clang_ts(clang_ts), m_decls(decls), m_decl_name(name),
- m_decl_context(dc) {
+ : m_clang_ts(clang_ts), m_decls(decls),
+ m_namespace_map(std::make_shared<ClangASTImporter::NamespaceMap>()),
+ m_decl_name(name), m_decl_context(dc) {
+ ;
}
/// Create a VarDecl with the name being searched for and the provided type
More information about the lldb-commits
mailing list