llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT--> @llvm/pr-subscribers-lldb Author: Michael Buch (Michael137) <details> <summary>Changes</summary> `CreateTargetInfo` can return a `nullptr` in a couple cases. So we should log that and let the user know something is wrong (hence the `lldbassert`). I didn't actually run into this. Just stumbled upon it from reading the code. --- Full diff: https://github.com/llvm/llvm-project/pull/101697.diff 1 Files Affected: - (modified) lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp (+17-11) ``````````diff diff --git a/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp b/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp index 303e88feea20b..9d9403ebb9051 100644 --- a/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp +++ b/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp @@ -465,18 +465,24 @@ ClangExpressionParser::ClangExpressionParser( // A value of 0 means no limit for both LLDB and Clang. m_compiler->getDiagnostics().setErrorLimit(target_sp->GetExprErrorLimit()); - auto target_info = TargetInfo::CreateTargetInfo( - m_compiler->getDiagnostics(), m_compiler->getInvocation().TargetOpts); - if (log) { - LLDB_LOGF(log, "Target datalayout string: '%s'", - target_info->getDataLayoutString()); - LLDB_LOGF(log, "Target ABI: '%s'", target_info->getABI().str().c_str()); - LLDB_LOGF(log, "Target vector alignment: %d", - target_info->getMaxVectorAlign()); - } - m_compiler->setTarget(target_info); + if (auto *target_info = TargetInfo::CreateTargetInfo( + m_compiler->getDiagnostics(), + m_compiler->getInvocation().TargetOpts)) { + if (log) { + LLDB_LOGF(log, "Target datalayout string: '%s'", + target_info->getDataLayoutString()); + LLDB_LOGF(log, "Target ABI: '%s'", target_info->getABI().str().c_str()); + LLDB_LOGF(log, "Target vector alignment: %d", + target_info->getMaxVectorAlign()); + } + m_compiler->setTarget(target_info); + } else { + if (log) + LLDB_LOGF(log, "Failed to create TargetInfo for '%s'", + m_compiler->getTargetOpts().Triple.c_str()); - assert(m_compiler->hasTarget()); + lldbassert(false && "Failed to create TargetInfo."); + } // 4. Set language options. lldb::LanguageType language = expr.Language().AsLanguageType(); `````````` </details> https://github.com/llvm/llvm-project/pull/101697 _______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits