Skip to content

Commit 12fc353

Browse files
committed
[Serialization] Remove superfluous helper function
No functionality change (based on where it was used)
1 parent e969db9 commit 12fc353

File tree

1 file changed

+3
-33
lines changed

1 file changed

+3
-33
lines changed

lib/Serialization/Serialization.cpp

Lines changed: 3 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -459,36 +459,6 @@ static bool shouldSerializeAsLocalContext(const DeclContext *DC) {
459459
!isa<SubscriptDecl>(DC);
460460
}
461461

462-
static const Decl *getDeclForContext(const DeclContext *DC) {
463-
switch (DC->getContextKind()) {
464-
case DeclContextKind::Module:
465-
// Use a null decl to represent the module.
466-
return nullptr;
467-
case DeclContextKind::FileUnit:
468-
return getDeclForContext(DC->getParent());
469-
case DeclContextKind::SerializedLocal:
470-
llvm_unreachable("Serialized local contexts should only come from deserialization");
471-
case DeclContextKind::Initializer:
472-
case DeclContextKind::AbstractClosureExpr:
473-
// FIXME: What about default functions?
474-
llvm_unreachable("shouldn't serialize decls from anonymous closures");
475-
case DeclContextKind::GenericTypeDecl:
476-
return cast<GenericTypeDecl>(DC);
477-
case DeclContextKind::ExtensionDecl:
478-
return cast<ExtensionDecl>(DC);
479-
case DeclContextKind::TopLevelCodeDecl:
480-
llvm_unreachable("shouldn't serialize the main module");
481-
case DeclContextKind::AbstractFunctionDecl:
482-
return cast<AbstractFunctionDecl>(DC);
483-
case DeclContextKind::SubscriptDecl:
484-
return cast<SubscriptDecl>(DC);
485-
case DeclContextKind::EnumElementDecl:
486-
return cast<EnumElementDecl>(DC);
487-
}
488-
489-
llvm_unreachable("Unhandled DeclContextKind in switch.");
490-
}
491-
492462
namespace {
493463
struct Accessors {
494464
uint8_t OpaqueReadOwnership;
@@ -634,7 +604,7 @@ DeclContextID Serializer::addDeclContextRef(const DeclContext *DC) {
634604
if (shouldSerializeAsLocalContext(DC))
635605
addLocalDeclContextRef(DC);
636606
else
637-
addDeclRef(getDeclForContext(DC));
607+
addDeclRef(DC->getAsDecl());
638608

639609
auto &id = DeclContextIDs[DC];
640610
if (id)
@@ -1538,7 +1508,7 @@ Serializer::writeConformance(ProtocolConformanceRef conformanceRef,
15381508
switch (conformance->getKind()) {
15391509
case ProtocolConformanceKind::Normal: {
15401510
auto normal = cast<NormalProtocolConformance>(conformance);
1541-
if (!isDeclXRef(getDeclForContext(normal->getDeclContext()))
1511+
if (!isDeclXRef(normal->getDeclContext()->getAsDecl())
15421512
&& !isa<ClangModuleUnit>(normal->getDeclContext()
15431513
->getModuleScopeContext())) {
15441514
// A normal conformance in this module file.
@@ -2046,7 +2016,7 @@ void Serializer::writeDeclContext(const DeclContext *DC) {
20462016
case DeclContextKind::GenericTypeDecl:
20472017
case DeclContextKind::ExtensionDecl:
20482018
case DeclContextKind::EnumElementDecl:
2049-
declOrDeclContextID = addDeclRef(getDeclForContext(DC));
2019+
declOrDeclContextID = addDeclRef(DC->getAsDecl());
20502020
isDecl = true;
20512021
break;
20522022

0 commit comments

Comments
 (0)