Skip to content

Add a [nonoverridden] kind for SILVTable entries. #32126

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions include/swift/SIL/SILVTable.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,9 @@ class SILVTable : public llvm::ilist_node<SILVTable>,
enum Kind : uint8_t {
/// The vtable entry is for a method defined directly in this class.
Normal,
/// The vtable entry is for a method defined directly in this class, and is never overridden
/// by subclasses.
NormalNonOverridden,
/// The vtable entry is inherited from the superclass.
Inherited,
/// The vtable entry is inherited from the superclass, and overridden
Expand Down
3 changes: 3 additions & 0 deletions lib/SIL/IR/SILPrinter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3127,6 +3127,9 @@ void SILVTable::print(llvm::raw_ostream &OS, bool Verbose) const {
switch (entry.TheKind) {
case SILVTable::Entry::Kind::Normal:
break;
case SILVTable::Entry::Kind::NormalNonOverridden:
OS << " [nonoverridden]";
break;
case SILVTable::Entry::Kind::Inherited:
OS << " [inherited]";
break;
Expand Down
3 changes: 3 additions & 0 deletions lib/SIL/Parser/ParseSIL.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6090,6 +6090,9 @@ bool SILParserState::parseSILVTable(Parser &P) {
} else if (P.Tok.getText() == "inherited") {
P.consumeToken();
Kind = SILVTable::Entry::Kind::Inherited;
} else if (P.Tok.getText() == "nonoverridden") {
P.consumeToken();
Kind = SILVTable::Entry::Kind::NormalNonOverridden;
} else {
P.diagnose(P.Tok.getLoc(), diag::sil_vtable_bad_entry_kind);
return true;
Expand Down
2 changes: 2 additions & 0 deletions lib/Serialization/DeserializeSIL.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,8 @@ static Optional<SILVTable::Entry::Kind>
fromStableVTableEntryKind(unsigned value) {
switch (value) {
case SIL_VTABLE_ENTRY_NORMAL: return SILVTable::Entry::Kind::Normal;
case SIL_VTABLE_ENTRY_NORMAL_NON_OVERRIDDEN:
return SILVTable::Entry::Kind::NormalNonOverridden;
case SIL_VTABLE_ENTRY_INHERITED: return SILVTable::Entry::Kind::Inherited;
case SIL_VTABLE_ENTRY_OVERRIDE: return SILVTable::Entry::Kind::Override;
default: return None;
Expand Down
2 changes: 1 addition & 1 deletion lib/Serialization/ModuleFormat.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ const uint16_t SWIFTMODULE_VERSION_MAJOR = 0;
/// describe what change you made. The content of this comment isn't important;
/// it just ensures a conflict if two people change the module format.
/// Don't worry about adhering to the 80-column limit for this line.
const uint16_t SWIFTMODULE_VERSION_MINOR = 557; // COW instructions
const uint16_t SWIFTMODULE_VERSION_MINOR = 558; // SILVTable entry kind for non-overridden entries

/// A standard hash seed used for all string hashes in a serialized module.
///
Expand Down
1 change: 1 addition & 0 deletions lib/Serialization/SILFormat.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ using SILLinkageField = BCFixed<4>;

enum SILVTableEntryKindEncoding : uint8_t {
SIL_VTABLE_ENTRY_NORMAL,
SIL_VTABLE_ENTRY_NORMAL_NON_OVERRIDDEN,
SIL_VTABLE_ENTRY_INHERITED,
SIL_VTABLE_ENTRY_OVERRIDE,
};
Expand Down
2 changes: 2 additions & 0 deletions lib/Serialization/SerializeSIL.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,8 @@ static unsigned toStableSILLinkage(SILLinkage linkage) {
static unsigned toStableVTableEntryKind(SILVTable::Entry::Kind kind) {
switch (kind) {
case SILVTable::Entry::Kind::Normal: return SIL_VTABLE_ENTRY_NORMAL;
case SILVTable::Entry::Kind::NormalNonOverridden:
return SIL_VTABLE_ENTRY_NORMAL_NON_OVERRIDDEN;
case SILVTable::Entry::Kind::Inherited: return SIL_VTABLE_ENTRY_INHERITED;
case SILVTable::Entry::Kind::Override: return SIL_VTABLE_ENTRY_OVERRIDE;
}
Expand Down