Skip to content

Commit d1d863c

Browse files
authored
[lldb] Remove lldbassert in AppleObjCTypeEncodingParser (#93332)
AppleObjCTypeEncodingParser::BuildObjCObjectPointerType currently contains an lldbassert to detect situations where we have a forward declaration without a definition. According to the accompanying comment, its purpose is to catch "weird cases" during test suite runs. However, because this is an lldbassert, we show a scary message to our users who think this is a problem and report the issue to us. Unfortunately those reports aren't very actionable without a way to know the name of the type. This patch changes the lldbassert to a regular assert and emits a log message to the types log when this happens. rdar://127439898
1 parent b963931 commit d1d863c

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTypeEncodingParser.cpp

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313
#include "lldb/Symbol/CompilerType.h"
1414
#include "lldb/Target/Process.h"
1515
#include "lldb/Target/Target.h"
16+
#include "lldb/Utility/LLDBLog.h"
17+
#include "lldb/Utility/Log.h"
1618
#include "lldb/Utility/StringLexer.h"
1719

1820
#include "clang/Basic/TargetInfo.h"
@@ -234,12 +236,15 @@ clang::QualType AppleObjCTypeEncodingParser::BuildObjCObjectPointerType(
234236

235237
auto types = decl_vendor->FindTypes(ConstString(name), /*max_matches*/ 1);
236238

237-
// The user can forward-declare something that has no definition. The runtime
238-
// doesn't prohibit this at all. This is a rare and very weird case. We keep
239-
// this assert in debug builds so we catch other weird cases.
240-
lldbassert(!types.empty());
241-
if (types.empty())
239+
if (types.empty()) {
240+
// The user can forward-declare something that has no definition. The
241+
// runtime doesn't prohibit this at all. This is a rare and very weird
242+
// case. Assert assert in debug builds so we catch other weird cases.
243+
assert(false && "forward declaration without definition");
244+
LLDB_LOG(GetLog(LLDBLog::Types),
245+
"forward declaration without definition: {0}", name)
242246
return ast_ctx.getObjCIdType();
247+
}
243248

244249
return ClangUtil::GetQualType(types.front().GetPointerType());
245250
} else {

0 commit comments

Comments
 (0)