diff options
author | Raphael Isemann <teemperor@gmail.com> | 2019-11-29 12:40:19 +0100 |
---|---|---|
committer | Raphael Isemann <teemperor@gmail.com> | 2019-11-29 12:49:33 +0100 |
commit | 76016f9b3a9acdba7728561a7ddfb48b1245dfa7 (patch) | |
tree | 1f7da875b60a17a290a779121b5ce4652467fc92 /lldb/source/Symbol/ClangASTContext.cpp | |
parent | 656a8123deed31d2d7aee313e87911dc153fa6d3 (diff) | |
download | bcm5719-llvm-76016f9b3a9acdba7728561a7ddfb48b1245dfa7.tar.gz bcm5719-llvm-76016f9b3a9acdba7728561a7ddfb48b1245dfa7.zip |
[lldb][NFC] Early exit in ClangASTContext::CreateInstance
Diffstat (limited to 'lldb/source/Symbol/ClangASTContext.cpp')
-rw-r--r-- | lldb/source/Symbol/ClangASTContext.cpp | 82 |
1 files changed, 41 insertions, 41 deletions
diff --git a/lldb/source/Symbol/ClangASTContext.cpp b/lldb/source/Symbol/ClangASTContext.cpp index e70b005550d..adb8d57a74f 100644 --- a/lldb/source/Symbol/ClangASTContext.cpp +++ b/lldb/source/Symbol/ClangASTContext.cpp @@ -562,47 +562,47 @@ uint32_t ClangASTContext::GetPluginVersion() { return 1; } lldb::TypeSystemSP ClangASTContext::CreateInstance(lldb::LanguageType language, lldb_private::Module *module, Target *target) { - if (ClangASTContextSupportsLanguage(language)) { - ArchSpec arch; - if (module) - arch = module->GetArchitecture(); - else if (target) - arch = target->GetArchitecture(); - - if (arch.IsValid()) { - ArchSpec fixed_arch = arch; - // LLVM wants this to be set to iOS or MacOSX; if we're working on - // a bare-boards type image, change the triple for llvm's benefit. - if (fixed_arch.GetTriple().getVendor() == llvm::Triple::Apple && - fixed_arch.GetTriple().getOS() == llvm::Triple::UnknownOS) { - if (fixed_arch.GetTriple().getArch() == llvm::Triple::arm || - fixed_arch.GetTriple().getArch() == llvm::Triple::aarch64 || - fixed_arch.GetTriple().getArch() == llvm::Triple::aarch64_32 || - fixed_arch.GetTriple().getArch() == llvm::Triple::thumb) { - fixed_arch.GetTriple().setOS(llvm::Triple::IOS); - } else { - fixed_arch.GetTriple().setOS(llvm::Triple::MacOSX); - } - } - - if (module) { - std::shared_ptr<ClangASTContext> ast_sp( - new ClangASTContext(fixed_arch)); - return ast_sp; - } else if (target && target->IsValid()) { - std::shared_ptr<ClangASTContextForExpressions> ast_sp( - new ClangASTContextForExpressions(*target, fixed_arch)); - ast_sp->m_scratch_ast_source_up.reset( - new ClangASTSource(target->shared_from_this())); - lldbassert(ast_sp->getFileManager()); - ast_sp->m_scratch_ast_source_up->InstallASTContext( - *ast_sp->getASTContext(), *ast_sp->getFileManager(), true); - llvm::IntrusiveRefCntPtr<clang::ExternalASTSource> proxy_ast_source( - ast_sp->m_scratch_ast_source_up->CreateProxy()); - ast_sp->SetExternalSource(proxy_ast_source); - return ast_sp; - } - } + if (!ClangASTContextSupportsLanguage(language)) + return lldb::TypeSystemSP(); + ArchSpec arch; + if (module) + arch = module->GetArchitecture(); + else if (target) + arch = target->GetArchitecture(); + + if (!arch.IsValid()) + return lldb::TypeSystemSP(); + + ArchSpec fixed_arch = arch; + // LLVM wants this to be set to iOS or MacOSX; if we're working on + // a bare-boards type image, change the triple for llvm's benefit. + if (fixed_arch.GetTriple().getVendor() == llvm::Triple::Apple && + fixed_arch.GetTriple().getOS() == llvm::Triple::UnknownOS) { + if (fixed_arch.GetTriple().getArch() == llvm::Triple::arm || + fixed_arch.GetTriple().getArch() == llvm::Triple::aarch64 || + fixed_arch.GetTriple().getArch() == llvm::Triple::aarch64_32 || + fixed_arch.GetTriple().getArch() == llvm::Triple::thumb) { + fixed_arch.GetTriple().setOS(llvm::Triple::IOS); + } else { + fixed_arch.GetTriple().setOS(llvm::Triple::MacOSX); + } + } + + if (module) { + std::shared_ptr<ClangASTContext> ast_sp(new ClangASTContext(fixed_arch)); + return ast_sp; + } else if (target && target->IsValid()) { + std::shared_ptr<ClangASTContextForExpressions> ast_sp( + new ClangASTContextForExpressions(*target, fixed_arch)); + ast_sp->m_scratch_ast_source_up.reset( + new ClangASTSource(target->shared_from_this())); + lldbassert(ast_sp->getFileManager()); + ast_sp->m_scratch_ast_source_up->InstallASTContext( + *ast_sp->getASTContext(), *ast_sp->getFileManager(), true); + llvm::IntrusiveRefCntPtr<clang::ExternalASTSource> proxy_ast_source( + ast_sp->m_scratch_ast_source_up->CreateProxy()); + ast_sp->SetExternalSource(proxy_ast_source); + return ast_sp; } return lldb::TypeSystemSP(); } |