Skip to content

Commit f4a595d

Browse files
committed
Modernize LLDB_LOGF uses.
Some of these had interesting bugs in the form of incorrect % placeholders.
1 parent 3c1c797 commit f4a595d

File tree

1 file changed

+30
-31
lines changed

1 file changed

+30
-31
lines changed

lldb/source/Plugins/LanguageRuntime/Swift/SwiftLanguageRuntimeDynamicTypeResolution.cpp

Lines changed: 30 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -611,8 +611,8 @@ SwiftLanguageRuntimeImpl::GetNumChildren(CompilerType type,
611611
}
612612
// Structs and Tuples.
613613
if (auto *rti = llvm::dyn_cast<swift::reflection::RecordTypeInfo>(ti)) {
614-
LLDB_LOGF(GetLog(LLDBLog::Types), "%s: RecordTypeInfo(num_fields=%i)",
615-
type.GetMangledTypeName().GetCString(), rti->getNumFields());
614+
LLDB_LOG(GetLog(LLDBLog::Types), "{0}: RecordTypeInfo(num_fields={1})",
615+
type.GetMangledTypeName(), rti->getNumFields());
616616
switch (rti->getRecordKind()) {
617617
case swift::reflection::RecordKind::ExistentialMetatype:
618618
case swift::reflection::RecordKind::ThickFunction:
@@ -630,15 +630,14 @@ SwiftLanguageRuntimeImpl::GetNumChildren(CompilerType type,
630630
}
631631
}
632632
if (auto *eti = llvm::dyn_cast<swift::reflection::EnumTypeInfo>(ti)) {
633-
LLDB_LOGF(GetLog(LLDBLog::Types), "%s: EnumTypeInfo(num_payload_cases=%i)",
634-
type.GetMangledTypeName().GetCString(),
635-
eti->getNumPayloadCases());
633+
LLDB_LOG(GetLog(LLDBLog::Types), "{0}: EnumTypeInfo(num_payload_cases={1})",
634+
type.GetMangledTypeName(), eti->getNumPayloadCases());
636635
return eti->getNumPayloadCases();
637636
}
638637
// Objects.
639638
if (auto *rti = llvm::dyn_cast<swift::reflection::ReferenceTypeInfo>(ti)) {
640-
LLDB_LOGF(GetLog(LLDBLog::Types), "%s: ReferenceTypeInfo()",
641-
type.GetMangledTypeName().GetCString());
639+
LLDB_LOG(GetLog(LLDBLog::Types), "{0}: ReferenceTypeInfo()",
640+
type.GetMangledTypeName().GetCString());
642641
switch (rti->getReferenceKind()) {
643642
case swift::reflection::ReferenceKind::Weak:
644643
case swift::reflection::ReferenceKind::Unowned:
@@ -665,8 +664,8 @@ SwiftLanguageRuntimeImpl::GetNumChildren(CompilerType type,
665664
if (auto *rti =
666665
llvm::dyn_cast_or_null<swift::reflection::RecordTypeInfo>(cti)) {
667666
LLDB_LOG(GetLog(LLDBLog::Types),
668-
"{0}: class RecordTypeInfo(num_fields=%i)",
669-
type.GetMangledTypeName().GetCString(), rti->getNumFields());
667+
"{0}: class RecordTypeInfo(num_fields={1})",
668+
type.GetMangledTypeName(), rti->getNumFields());
670669

671670
// The superclass, if any, is an extra child.
672671
if (reflection_ctx->LookupSuperclass(tr,
@@ -679,7 +678,7 @@ SwiftLanguageRuntimeImpl::GetNumChildren(CompilerType type,
679678
}
680679
// FIXME: Implement more cases.
681680
LLDB_LOG(GetLog(LLDBLog::Types), "{0}: unimplemented type info",
682-
type.GetMangledTypeName().GetCString());
681+
type.GetMangledTypeName());
683682
return {};
684683
}
685684

@@ -1109,9 +1108,9 @@ CompilerType SwiftLanguageRuntimeImpl::GetChildCompilerTypeAtIndex(
11091108
});
11101109

11111110
if (supers.size() == 0) {
1112-
LLDB_LOGF(GetLog(LLDBLog::Types),
1113-
"Couldn't find the type metadata for %s in instance",
1114-
type.GetTypeName().AsCString());
1111+
LLDB_LOG(GetLog(LLDBLog::Types),
1112+
"Couldn't find the type metadata for {0} in instance",
1113+
type.GetTypeName());
11151114
return {};
11161115
}
11171116

@@ -1185,8 +1184,8 @@ CompilerType SwiftLanguageRuntimeImpl::GetChildCompilerTypeAtIndex(
11851184
i);
11861185
return {};
11871186
}
1188-
LLDB_LOGF(GetLog(LLDBLog::Types), "Cannot retrieve type information for %s",
1189-
type.GetTypeName().AsCString());
1187+
LLDB_LOG(GetLog(LLDBLog::Types), "Cannot retrieve type information for {0}",
1188+
type.GetTypeName());
11901189
return {};
11911190
}
11921191

@@ -1311,8 +1310,8 @@ bool SwiftLanguageRuntimeImpl::GetDynamicTypeAndAddress_Pack(
13111310
++i;
13121311
}
13131312
if (!pack_expansion) {
1314-
LLDB_LOGF(log, "cannot decode pack_expansion type: failed to find a "
1315-
"matching type in the function signature");
1313+
LLDB_LOG(log, "cannot decode pack_expansion type: failed to find a "
1314+
"matching type in the function signature");
13161315
return {};
13171316
}
13181317

@@ -1324,10 +1323,10 @@ bool SwiftLanguageRuntimeImpl::GetDynamicTypeAndAddress_Pack(
13241323
llvm::Optional<lldb::addr_t> count =
13251324
GetTypeMetadataForTypeNameAndFrame(count_var, *frame);
13261325
if (!count) {
1327-
LLDB_LOGF(log,
1328-
"cannot decode pack_expansion type: failed to find count "
1329-
"argument \"%s\" in frame",
1330-
count_var.str().c_str());
1326+
LLDB_LOG(log,
1327+
"cannot decode pack_expansion type: failed to find count "
1328+
"argument \"%s\" in frame",
1329+
count_var.str());
13311330
return {};
13321331
}
13331332

@@ -1354,11 +1353,11 @@ bool SwiftLanguageRuntimeImpl::GetDynamicTypeAndAddress_Pack(
13541353
llvm::Optional<lldb::addr_t> mds_ptr =
13551354
GetTypeMetadataForTypeNameAndFrame(mds_var, *frame);
13561355
if (!mds_ptr) {
1357-
LLDB_LOGF(log,
1356+
LLDB_LOG(log,
13581357
"cannot decode pack_expansion type: failed to find "
13591358
"metadata "
1360-
"for \"%s\" in frame",
1361-
mds_var.str().c_str());
1359+
"for \"{0}\" in frame",
1360+
mds_var.str());
13621361
error = true;
13631362
return;
13641363
}
@@ -2695,10 +2694,10 @@ SwiftLanguageRuntimeImpl::GetTypeRef(CompilerType type,
26952694
if (log && log->GetVerbose()) {
26962695
std::stringstream ss;
26972696
type_ref->dump(ss);
2698-
LLDB_LOGF(log,
2699-
"[SwiftLanguageRuntimeImpl::GetTypeRef] Found typeref for "
2700-
"type: %s:\n%s",
2701-
type.GetMangledTypeName().GetCString(), ss.str().c_str());
2697+
LLDB_LOG(log,
2698+
"[SwiftLanguageRuntimeImpl::GetTypeRef] Found typeref for "
2699+
"type: {0}:\n{0}",
2700+
type.GetMangledTypeName(), ss.str());
27022701
}
27032702
return type_ref;
27042703
}
@@ -2710,9 +2709,9 @@ SwiftLanguageRuntimeImpl::GetSwiftRuntimeTypeInfo(
27102709
Log *log(GetLog(LLDBLog::Types));
27112710

27122711
if (log && log->GetVerbose())
2713-
LLDB_LOGF(log, "[SwiftLanguageRuntimeImpl::GetSwiftRuntimeTypeInfo] Getting "
2714-
"type info for type: %s\n",
2715-
type.GetMangledTypeName().GetCString());
2712+
LLDB_LOG(log, "[SwiftLanguageRuntimeImpl::GetSwiftRuntimeTypeInfo] Getting "
2713+
"type info for type: {0}",
2714+
type.GetMangledTypeName());
27162715

27172716
auto ts = type.GetTypeSystem().dyn_cast_or_null<TypeSystemSwift>();
27182717
if (!ts)

0 commit comments

Comments
 (0)