Skip to content

Commit 051c84e

Browse files
committed
[lldb][TypeSystemClang][NFC] Log failure to InitBuiltinTypes
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 (cherry picked from commit 2847020)
1 parent 9fe6ba0 commit 051c84e

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -747,6 +747,10 @@ void TypeSystemClang::CreateASTContext() {
747747
TargetInfo *target_info = getTargetInfo();
748748
if (target_info)
749749
m_ast_up->InitBuiltinTypes(*target_info);
750+
else if (auto *log = GetLog(LLDBLog::Expressions))
751+
LLDB_LOG(log,
752+
"Failed to initialize builtin ASTContext types for target '{0}'",
753+
m_target_triple);
750754

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

0 commit comments

Comments
 (0)