Skip to content

Commit 047db83

Browse files
authored
Merge pull request swiftlang#60144 from slavapestov/local-type-originally-defined-in-fix-5.7
ASTMangler: Don't consider @_originallyDefinedIn when mangling local type discriminators [5.7]
2 parents 49796c9 + 74abdce commit 047db83

File tree

4 files changed

+24
-1
lines changed

4 files changed

+24
-1
lines changed

lib/AST/ASTMangler.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -822,6 +822,11 @@ std::string ASTMangler::mangleLocalTypeDecl(const TypeDecl *type) {
822822
AllowNamelessEntities = true;
823823
OptimizeProtocolNames = false;
824824

825+
// Local types are not ABI anyway. To avoid problems with the ASTDemangler,
826+
// don't respect @_originallyDefinedIn here, since we don't respect it
827+
// when mangling DWARF types for debug info.
828+
RespectOriginallyDefinedIn = false;
829+
825830
if (auto GTD = dyn_cast<GenericTypeDecl>(type)) {
826831
appendAnyGenericType(GTD);
827832
} else {

lib/Serialization/ModuleFormat.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ const uint16_t SWIFTMODULE_VERSION_MAJOR = 0;
5656
/// describe what change you made. The content of this comment isn't important;
5757
/// it just ensures a conflict if two people change the module format.
5858
/// Don't worry about adhering to the 80-column limit for this line.
59-
const uint16_t SWIFTMODULE_VERSION_MINOR = 696; // `distributed thunk` bit on `AbstractFunctionDecl`
59+
const uint16_t SWIFTMODULE_VERSION_MINOR = 697; // change local type mangling
6060

6161
/// A standard hash seed used for all string hashes in a serialized module.
6262
///
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
@available(macOS 10, *)
2+
@_originallyDefinedIn(module: "Barn", macOS 10.1) public struct Horse {}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
// RUN: %empty-directory(%t)
2+
// RUN: %target-swift-frontend -emit-module -emit-module-path %t/local_type_originally_defined_in_other.swiftmodule %S/Inputs/local_type_originally_defined_in_other.swift
3+
// RUN: %target-swift-frontend -I%t -g -emit-ir %s
4+
5+
import local_type_originally_defined_in_other
6+
7+
public func localTypeAliasTest(horse: Horse) {
8+
// The local type mangling for 'A' mentions 'Horse', which must
9+
// be mangled using it's current module name, and not the
10+
// original module name, for consistency with the debug info
11+
// mangling.
12+
typealias A = Int
13+
14+
let info = UnsafeMutablePointer<A>.allocate(capacity: 1)
15+
_ = info
16+
}

0 commit comments

Comments
 (0)