@@ -52,8 +52,9 @@ class ScopedLexicalDeclEraser {
52
52
ClangASTSource::ClangASTSource (const lldb::TargetSP &target,
53
53
const lldb::ClangASTImporterSP &importer)
54
54
: m_import_in_progress(false ), m_lookups_enabled(false ), m_target(target),
55
- m_ast_context(nullptr ), m_active_lexical_decls(), m_active_lookups() {
56
- m_ast_importer_sp = importer;
55
+ m_ast_context(nullptr ), m_ast_importer_sp(importer),
56
+ m_active_lexical_decls(), m_active_lookups() {
57
+ assert (m_ast_importer_sp && " No ClangASTImporter passed to ClangASTSource?" );
57
58
}
58
59
59
60
void ClangASTSource::InstallASTContext (TypeSystemClang &clang_ast_context) {
@@ -64,9 +65,6 @@ void ClangASTSource::InstallASTContext(TypeSystemClang &clang_ast_context) {
64
65
}
65
66
66
67
ClangASTSource::~ClangASTSource () {
67
- if (!m_ast_importer_sp)
68
- return ;
69
-
70
68
m_ast_importer_sp->ForgetDestination (m_ast_context);
71
69
72
70
if (!m_target)
@@ -216,10 +214,6 @@ void ClangASTSource::CompleteType(TagDecl *tag_decl) {
216
214
m_active_lexical_decls.insert (tag_decl);
217
215
ScopedLexicalDeclEraser eraser (m_active_lexical_decls, tag_decl);
218
216
219
- if (!m_ast_importer_sp) {
220
- return ;
221
- }
222
-
223
217
if (!m_ast_importer_sp->CompleteTagDecl (tag_decl)) {
224
218
// We couldn't complete the type. Maybe there's a definition somewhere
225
219
// else that can be completed.
@@ -343,11 +337,6 @@ void ClangASTSource::CompleteType(clang::ObjCInterfaceDecl *interface_decl) {
343
337
LLDB_LOG (log, " [COID] Before:\n {0}" ,
344
338
ClangUtil::DumpDecl (interface_decl));
345
339
346
- if (!m_ast_importer_sp) {
347
- lldbassert (0 && " No mechanism for completing a type!" );
348
- return ;
349
- }
350
-
351
340
ClangASTImporter::DeclOrigin original = m_ast_importer_sp->GetDeclOrigin (interface_decl);
352
341
353
342
if (original.Valid ()) {
@@ -420,9 +409,6 @@ void ClangASTSource::FindExternalLexicalDecls(
420
409
llvm::function_ref<bool (Decl::Kind)> predicate,
421
410
llvm::SmallVectorImpl<Decl *> &decls) {
422
411
423
- if (!m_ast_importer_sp)
424
- return ;
425
-
426
412
Log *log (lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS));
427
413
428
414
const Decl *context_decl = dyn_cast<Decl>(decl_context);
@@ -587,8 +573,8 @@ void ClangASTSource::FindExternalVisibleDecls(NameSearchContext &context) {
587
573
588
574
if (const NamespaceDecl *namespace_context =
589
575
dyn_cast<NamespaceDecl>(context.m_decl_context )) {
590
- ClangASTImporter::NamespaceMapSP namespace_map = m_ast_importer_sp ?
591
- m_ast_importer_sp->GetNamespaceMap (namespace_context) : nullptr ;
576
+ ClangASTImporter::NamespaceMapSP namespace_map =
577
+ m_ast_importer_sp->GetNamespaceMap (namespace_context);
592
578
593
579
if (log && log->GetVerbose ())
594
580
LLDB_LOG (log,
@@ -1791,21 +1777,11 @@ NamespaceDecl *ClangASTSource::AddNamespace(
1791
1777
}
1792
1778
1793
1779
clang::Decl *ClangASTSource::CopyDecl (Decl *src_decl) {
1794
- if (m_ast_importer_sp) {
1795
- return m_ast_importer_sp->CopyDecl (m_ast_context, src_decl);
1796
- } else {
1797
- lldbassert (0 && " No mechanism for copying a decl!" );
1798
- return nullptr ;
1799
- }
1780
+ return m_ast_importer_sp->CopyDecl (m_ast_context, src_decl);
1800
1781
}
1801
1782
1802
1783
ClangASTImporter::DeclOrigin ClangASTSource::GetDeclOrigin (const clang::Decl *decl) {
1803
- if (m_ast_importer_sp) {
1804
- return m_ast_importer_sp->GetDeclOrigin (decl);
1805
- } else {
1806
- // this can happen early enough that no ExternalASTSource is installed.
1807
- return ClangASTImporter::DeclOrigin ();
1808
- }
1784
+ return m_ast_importer_sp->GetDeclOrigin (decl);
1809
1785
}
1810
1786
1811
1787
CompilerType ClangASTSource::GuardedCopyType (const CompilerType &src_type) {
@@ -1816,15 +1792,8 @@ CompilerType ClangASTSource::GuardedCopyType(const CompilerType &src_type) {
1816
1792
1817
1793
SetImportInProgress (true );
1818
1794
1819
- QualType copied_qual_type;
1820
-
1821
- if (m_ast_importer_sp) {
1822
- copied_qual_type = ClangUtil::GetQualType (
1823
- m_ast_importer_sp->CopyType (*m_clang_ast_context, src_type));
1824
- } else {
1825
- lldbassert (0 && " No mechanism for copying a type!" );
1826
- return CompilerType ();
1827
- }
1795
+ QualType copied_qual_type = ClangUtil::GetQualType (
1796
+ m_ast_importer_sp->CopyType (*m_clang_ast_context, src_type));
1828
1797
1829
1798
SetImportInProgress (false );
1830
1799
0 commit comments