Skip to content

Commit 2847020

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
1 parent f22b1da commit 2847020

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
@@ -697,6 +697,10 @@ void TypeSystemClang::CreateASTContext() {
697697
TargetInfo *target_info = getTargetInfo();
698698
if (target_info)
699699
m_ast_up->InitBuiltinTypes(*target_info);
700+
else if (auto *log = GetLog(LLDBLog::Expressions))
701+
LLDB_LOG(log,
702+
"Failed to initialize builtin ASTContext types for target '{0}'",
703+
m_target_triple);
700704

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

0 commit comments

Comments
 (0)