[Lldb-commits] [lldb] [lldb][ClangExpressionParser] Log and assert on failure to create TargetInfo (PR #101697)
Adrian Prantl via lldb-commits
lldb-commits at lists.llvm.org
Fri Aug 2 09:02:51 PDT 2024
================
@@ -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.");
----------------
adrian-prantl wrote:
Based on that there used to be an assert here, should this return?
Same comment as in the previous review — ideally this would return an llvm::Error here if it weren't a constructor.
https://github.com/llvm/llvm-project/pull/101697
More information about the lldb-commits
mailing list