Skip to content

Commit

Permalink
[lldb][TypeSystemClang][NFC] Log failure to InitBuiltinTypes
Browse files Browse the repository at this point in the history
If we fail to initialize the ASTContext builtins, LLDB
may crash in non-obvious ways down-the-line, e.g., when
it tries to call `ASTContext::getTypeSize` on a builtin like
`ast.UnsignedCharTy`, which would derefernce a `null` `QualType`.

The initialization can fail if we either didn't set the
`TypeSystemClang` target triple, or if the embedded clang isn't
enabled for a certain target.

This patch attempts to help pin-point the failure case post-mortem
by adding a log message here that prints the triple.

rdar://134260837
  • Loading branch information
Michael137 committed Aug 25, 2024
1 parent f22b1da commit 2847020
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -697,6 +697,10 @@ void TypeSystemClang::CreateASTContext() {
TargetInfo *target_info = getTargetInfo();
if (target_info)
m_ast_up->InitBuiltinTypes(*target_info);
else if (auto *log = GetLog(LLDBLog::Expressions))
LLDB_LOG(log,
"Failed to initialize builtin ASTContext types for target '{0}'",
m_target_triple);

GetASTMap().Insert(m_ast_up.get(), this);

Expand Down

0 comments on commit 2847020

Please # to comment.