Skip to content

Commit 0dcd813

Browse files
committed
FieldRecord: Guard when field name is null
Field name relative offsets can be null if -strip-reflection-names is passed to the frontend.
1 parent 23a823a commit 0dcd813

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

include/swift/Reflection/Records.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,9 @@ class FieldRecord {
5757
}
5858

5959
std::string getFieldName() const {
60-
return FieldName.get();
60+
if (FieldName)
61+
return FieldName.get();
62+
return "";
6163
}
6264

6365
bool isObjC() const {

include/swift/Reflection/ReflectionContext.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -573,7 +573,10 @@ class ReflectionContext {
573573
if (!Unsubstituted)
574574
return {};
575575
auto Substituted = Unsubstituted->subst(*this, Subs);
576-
Fields.push_back({Field.getFieldName(), Substituted});
576+
auto FieldName = Field.getFieldName();
577+
if (FieldName.empty())
578+
FieldName = "<Redacted Field Name>";
579+
Fields.push_back({FieldName, Substituted});
577580
}
578581
}
579582
}

0 commit comments

Comments
 (0)