[lldb][NFC] Early exit in ClangASTContext::CreateInstance

This commit is contained in:
Raphael Isemann 2019-11-29 12:40:19 +01:00
parent 656a8123de
commit 76016f9b3a
1 changed files with 38 additions and 38 deletions

View File

@ -562,14 +562,17 @@ uint32_t ClangASTContext::GetPluginVersion() { return 1; }
lldb::TypeSystemSP ClangASTContext::CreateInstance(lldb::LanguageType language,
lldb_private::Module *module,
Target *target) {
if (ClangASTContextSupportsLanguage(language)) {
if (!ClangASTContextSupportsLanguage(language))
return lldb::TypeSystemSP();
ArchSpec arch;
if (module)
arch = module->GetArchitecture();
else if (target)
arch = target->GetArchitecture();
if (arch.IsValid()) {
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.
@ -586,8 +589,7 @@ lldb::TypeSystemSP ClangASTContext::CreateInstance(lldb::LanguageType language,
}
if (module) {
std::shared_ptr<ClangASTContext> ast_sp(
new ClangASTContext(fixed_arch));
std::shared_ptr<ClangASTContext> ast_sp(new ClangASTContext(fixed_arch));
return ast_sp;
} else if (target && target->IsValid()) {
std::shared_ptr<ClangASTContextForExpressions> ast_sp(
@ -602,8 +604,6 @@ lldb::TypeSystemSP ClangASTContext::CreateInstance(lldb::LanguageType language,
ast_sp->SetExternalSource(proxy_ast_source);
return ast_sp;
}
}
}
return lldb::TypeSystemSP();
}