Skip to content

Commit 9793f77

Browse files
committed
AST: New mangling for expansion locations to avoid request cycles
Fixes rdar://127078338.
1 parent c270597 commit 9793f77

17 files changed

+137
-48
lines changed

include/swift/Demangling/DemangleNodes.def

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,7 @@ NODE(LazyProtocolWitnessTableAccessor)
164164
NODE(LazyProtocolWitnessTableCacheVariable)
165165
NODE(LocalDeclName)
166166
NODE(Macro)
167+
NODE(MacroExpansionLoc)
167168
NODE(MacroExpansionUniqueName)
168169
CONTEXT_NODE(MaterializeForSet)
169170
NODE(MemberAttachedMacroExpansion)

lib/AST/ASTMangler.cpp

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4441,10 +4441,21 @@ void ASTMangler::appendMacroExpansionContext(
44414441
ASTContext &ctx = origDC->getASTContext();
44424442
SourceManager &sourceMgr = ctx.SourceMgr;
44434443

4444+
auto appendMacroExpansionLoc = [&]() {
4445+
appendIdentifier(origDC->getParentModule()->getName().str());
4446+
4447+
auto *SF = origDC->getParentSourceFile();
4448+
appendIdentifier(llvm::sys::path::filename(SF->getFilename()));
4449+
4450+
auto lineColumn = sourceMgr.getLineAndColumnInBuffer(loc);
4451+
appendOperator("fMX", Index(lineColumn.first), Index(lineColumn.second));
4452+
};
4453+
44444454
auto bufferID = sourceMgr.findBufferContainingLoc(loc);
44454455
auto generatedSourceInfo = sourceMgr.getGeneratedSourceInfo(bufferID);
4446-
if (!generatedSourceInfo)
4447-
return appendContext(origDC, nullBase, StringRef());
4456+
if (!generatedSourceInfo) {
4457+
return appendMacroExpansionLoc();
4458+
}
44484459

44494460
SourceLoc outerExpansionLoc;
44504461
DeclContext *outerExpansionDC;
@@ -4463,7 +4474,7 @@ void ASTMangler::appendMacroExpansionContext(
44634474
case GeneratedSourceInfo::PrettyPrinted:
44644475
case GeneratedSourceInfo::ReplacedFunctionBody:
44654476
case GeneratedSourceInfo::DefaultArgument:
4466-
return appendContext(origDC, nullBase, StringRef());
4477+
return appendMacroExpansionLoc();
44674478
}
44684479

44694480
switch (generatedSourceInfo->kind) {
@@ -4520,7 +4531,7 @@ void ASTMangler::appendMacroExpansionContext(
45204531
// If we hit the point where the structure is represented as a DeclContext,
45214532
// we're done.
45224533
if (origDC->isChildContextOf(outerExpansionDC))
4523-
return appendContext(origDC, nullBase, StringRef());
4534+
return appendMacroExpansionLoc();
45244535

45254536
// Append our own context and discriminator.
45264537
appendMacroExpansionContext(outerExpansionLoc, origDC);

lib/Demangling/Demangler.cpp

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4294,7 +4294,8 @@ static bool isMacroExpansionNodeKind(Node::Kind kind) {
42944294
kind == Node::Kind::MemberAttachedMacroExpansion ||
42954295
kind == Node::Kind::PeerAttachedMacroExpansion ||
42964296
kind == Node::Kind::ConformanceAttachedMacroExpansion ||
4297-
kind == Node::Kind::ExtensionAttachedMacroExpansion;
4297+
kind == Node::Kind::ExtensionAttachedMacroExpansion ||
4298+
kind == Node::Kind::MacroExpansionLoc;
42984299
}
42994300

43004301
NodePointer Demangler::demangleMacroExpansion() {
@@ -4323,6 +4324,20 @@ NodePointer Demangler::demangleMacroExpansion() {
43234324
isFreestanding = false;
43244325
break;
43254326

4327+
case 'X': {
4328+
kind = Node::Kind::MacroExpansionLoc;
4329+
4330+
int line = demangleIndex();
4331+
int col = demangleIndex();
4332+
4333+
auto lineNode = createNode(Node::Kind::Index, line);
4334+
auto colNode = createNode(Node::Kind::Index, col);
4335+
4336+
NodePointer buffer = popNode(Node::Kind::Identifier);
4337+
NodePointer module = popNode(Node::Kind::Identifier);
4338+
return createWithChildren(kind, module, buffer, lineNode, colNode);
4339+
}
4340+
43264341
default:
43274342
return nullptr;
43284343
}

lib/Demangling/NodePrinter.cpp

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -457,6 +457,7 @@ class NodePrinter {
457457
case Node::Kind::LazyProtocolWitnessTableCacheVariable:
458458
case Node::Kind::LocalDeclName:
459459
case Node::Kind::Macro:
460+
case Node::Kind::MacroExpansionLoc:
460461
case Node::Kind::MacroExpansionUniqueName:
461462
case Node::Kind::MaterializeForSet:
462463
case Node::Kind::MemberAttributeAttachedMacroExpansion:
@@ -1544,6 +1545,24 @@ NodePointer NodePrinter::print(NodePointer Node, unsigned depth,
15441545
return printEntity(Node, depth, asPrefixContext, TypePrinting::NoType,
15451546
/*hasName*/true, "freestanding macro expansion #",
15461547
(int)Node->getChild(2)->getIndex() + 1);
1548+
case Node::Kind::MacroExpansionLoc:
1549+
if (Node->getNumChildren() > 0) {
1550+
Printer << "module ";
1551+
print(Node->getChild(0), depth + 1);
1552+
}
1553+
if (Node->getNumChildren() > 1) {
1554+
Printer << " file ";
1555+
print(Node->getChild(1), depth + 1);
1556+
}
1557+
if (Node->getNumChildren() > 2) {
1558+
Printer << " line ";
1559+
print(Node->getChild(2), depth + 1);
1560+
}
1561+
if (Node->getNumChildren() > 3) {
1562+
Printer << " column ";
1563+
print(Node->getChild(3), depth + 1);
1564+
}
1565+
return nullptr;
15471566
case Node::Kind::MacroExpansionUniqueName:
15481567
return printEntity(Node, depth, asPrefixContext, TypePrinting::NoType,
15491568
/*hasName*/true, "unique name #",

lib/Demangling/OldRemangler.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1115,6 +1115,11 @@ ManglingError Remangler::mangleMacroExpansionUniqueName(
11151115
return mangleChildNodes(node, depth + 1);
11161116
}
11171117

1118+
ManglingError Remangler::mangleMacroExpansionLoc(
1119+
Node *node, unsigned depth) {
1120+
return MANGLING_ERROR(ManglingError::UnsupportedNodeKind, node);
1121+
}
1122+
11181123
ManglingError Remangler::mangleAccessor(Node *storageNode,
11191124
StringRef accessorCode,
11201125
EntityContext &ctx, unsigned depth) {

lib/Demangling/Remangler.cpp

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3120,6 +3120,21 @@ ManglingError Remangler::mangle##Name##AttachedMacroExpansion( \
31203120
}
31213121
#include "swift/Basic/MacroRoles.def"
31223122

3123+
ManglingError Remangler::mangleMacroExpansionLoc(
3124+
Node *node, unsigned depth) {
3125+
RETURN_IF_ERROR(mangleChildNode(node, 0, depth + 1));
3126+
RETURN_IF_ERROR(mangleChildNode(node, 1, depth + 1));
3127+
3128+
auto line = node->getChild(2)->getIndex();
3129+
auto col = node->getChild(3)->getIndex();
3130+
3131+
Buffer << "fMX";
3132+
mangleIndex(line);
3133+
mangleIndex(col);
3134+
3135+
return ManglingError::Success;
3136+
}
3137+
31233138
ManglingError Remangler::mangleMacroExpansionUniqueName(
31243139
Node *node, unsigned depth) {
31253140
RETURN_IF_ERROR(mangleChildNode(node, 0, depth + 1));
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// RUN: %target-swift-frontend -emit-silgen %s -disable-availability-checking
2+
3+
public func hasIsolatedParam<T>(isolation: isolated (any Actor)? = #isolation) async -> T {}
4+
5+
func callee<T>(_: @autoclosure () -> T, _: @autoclosure () -> T) {}
6+
7+
func outer() async {
8+
func inner() async -> String {
9+
let x = #isolation
10+
return await hasIsolatedParam()
11+
}
12+
13+
var value = await inner()
14+
callee(value, "hi")
15+
}

test/Demangle/Inputs/manglings.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -473,3 +473,5 @@ $sSRyxG15Synchronization19AtomicRepresentableABRi0_zrlMc ---> protocol conforman
473473
$sSRyxG15Synchronization19AtomicRepresentableABRi1_zrlMc ---> protocol conformance descriptor for < where A: ~Swift.<bit 2>> Swift.UnsafeBufferPointer<A> : Synchronization.AtomicRepresentable in Synchronization
474474

475475
$s23variadic_generic_opaque2G2VyAA2S1V_AA2S2VQPGAA1PHPAeA1QHPyHC_AgaJHPyHCHX_HC ---> concrete protocol conformance variadic_generic_opaque.G2<Pack{variadic_generic_opaque.S1, variadic_generic_opaque.S2}> to protocol conformance ref (type's module) variadic_generic_opaque.P with conditional requirements: (pack protocol conformance (concrete protocol conformance variadic_generic_opaque.S1 to protocol conformance ref (type's module) variadic_generic_opaque.Q, concrete protocol conformance variadic_generic_opaque.S2 to protocol conformance ref (type's module) variadic_generic_opaque.Q))
476+
477+
$s9MacroUser0023macro_expandswift_elFCffMX436_4_23bitwidthNumberedStructsfMf_ ---> freestanding macro expansion #1 of bitwidthNumberedStructs in module MacroUser file macro_expand.swift line 437 column 5

test/Macros/freestanding_multifile.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ macro anonymousTypes(public: Bool, _: () -> String) = #externalMacro(module: "Ma
88

99
// RUN: %target-swift-frontend -swift-version 5 -emit-ir -load-plugin-library %t/%target-library-name(MacroDefinition) -module-name MacroUser %S/Inputs/AnonTypes1.swift %S/Inputs/AnonTypes2.swift %s -o - -g | %FileCheck --check-prefix CHECK-IR %s
1010

11-
// CHECK-IR: $s9MacroUser33{{.*}}14anonymousTypesfMf_4namefMu_
12-
// CHECK-IR-NOT: $s9MacroUser33{{.*}}14anonymousTypesfMf0_4namefMu_
13-
// CHECK-IR: $s9MacroUser33{{.*}}14anonymousTypesfMf_4namefMu_
14-
// CHECK-IR-NOT: $s9MacroUser33{{.*}}14anonymousTypesfMf0_4namefMu_
11+
// CHECK-IR: $s9MacroUser{{.*}}fMX{{.*}}_33{{.*}}14anonymousTypesfMf_4namefMu_
12+
// CHECK-IR-NOT: $s9MacroUser{{.*}}fMX{{.*}}_33{{.*}}14anonymousTypesfMf0_4namefMu_
13+
// CHECK-IR: $s9MacroUser{{.*}}fMX{{.*}}_33{{.*}}14anonymousTypesfMf_4namefMu_
14+
// CHECK-IR-NOT: $s9MacroUser{{.*}}fMX{{.*}}_33{{.*}}14anonymousTypesfMf0_4namefMu_

test/Macros/macro_expand.swift

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ struct MemberNotCovered {
7171
// expected-note@-1 {{in expansion of macro 'NotCovered' here}}
7272

7373
// CHECK-DIAGS: error: declaration name 'value' is not covered by macro 'NotCovered'
74-
// CHECK-DIAGS: CONTENTS OF FILE @__swiftmacro_9MacroUser16MemberNotCoveredV33_4361AD9339943F52AE6186DD51E04E91Ll0dE0fMf_.swift
74+
// CHECK-DIAGS: CONTENTS OF FILE @__swiftmacro_9MacroUser0023macro_expandswift_elFCffMX69_2_33_4361AD9339943F52AE6186DD51E04E91Ll10NotCoveredfMf_.swift
7575
// CHECK-DIAGS: var value: Int
7676
// CHECK-DIAGS: END CONTENTS OF FILE
7777
}
@@ -137,7 +137,7 @@ macro AccidentalCodeItem() = #externalMacro(module: "MacroDefinition", type: "Fa
137137
func invalidDeclarationMacro() {
138138
#accidentalCodeItem
139139
// expected-note@-1 {{in expansion of macro 'accidentalCodeItem' here}}
140-
// CHECK-DIAGS: @__swiftmacro_9MacroUser018invalidDeclarationA0yyF18accidentalCodeItemfMf_.swift:1:1: error: expected macro expansion to produce a declaration
140+
// CHECK-DIAGS: @__swiftmacro_9MacroUser0023macro_expandswift_elFCffMX{{.*}}_18accidentalCodeItemfMf_.swift:1:1: error: expected macro expansion to produce a declaration
141141

142142
@AccidentalCodeItem struct S {}
143143
// expected-note@-1 {{in expansion of macro 'AccidentalCodeItem' on struct 'S' here}}
@@ -155,17 +155,17 @@ func testFileID(a: Int, b: Int) {
155155
print("Result is \(#customFileID)")
156156
// CHECK-SIL: sil_scope [[SRC_SCOPE:[0-9]+]] { loc "{{.*}}macro_expand.swift":[[@LINE-3]]:6 parent {{.*}}testFileID
157157
// CHECK-SIL: sil_scope [[EXPANSION_SCOPE:[0-9]+]] { loc "{{.*}}macro_expand.swift":[[@LINE-2]]:22 parent [[SRC_SCOPE]]
158-
// CHECK-SIL: sil_scope [[MACRO_SCOPE:[0-9]+]] { loc "@__swiftmacro{{.*}}":1:1 parent @$s9MacroUser10testFileID1a1bySi_SitF06customdE0fMf_ {{.*}} inlined_at [[EXPANSION_SCOPE]] }
159-
// CHECK-SIL: string_literal utf8 "MacroUser/macro_expand.swift", loc "@__swiftmacro_9MacroUser10testFileID1a1bySi_SitF06customdE0fMf_.swift":1:1, scope [[MACRO_SCOPE]]
160-
// CHECK-IR-DAG: !DISubprogram(name: "customFileID", linkageName: "$s9MacroUser10testFileID1a1bySi_SitF06customdE0fMf_"
158+
// CHECK-SIL: sil_scope [[MACRO_SCOPE:[0-9]+]] { loc "@__swiftmacro{{.*}}":1:1 parent @$s9MacroUser0023macro_expandswift_elFCffMX{{.*}}_12customFileIDfMf_ {{.*}} inlined_at [[EXPANSION_SCOPE]] }
159+
// CHECK-SIL: string_literal utf8 "MacroUser/macro_expand.swift", loc "@__swiftmacro_9MacroUser0023macro_expandswift_elFCffMX{{.*}}_12customFileIDfMf_.swift":1:1, scope [[MACRO_SCOPE]]
160+
// CHECK-IR-DAG: !DISubprogram(name: "customFileID", linkageName: "$s9MacroUser0023macro_expandswift_elFCffMX{{.*}}_12customFileIDfMf_"
161161

162162
// CHECK: Builtin result is MacroUser/macro_expand.swift
163163
// CHECK-AST: macro_expansion_expr type='String'{{.*}}name=line
164164
print("Builtin result is \(#fileID)")
165165
print(
166166
// CHECK-IR-DAG: ![[L1:[0-9]+]] = distinct !DILocation(line: [[@LINE+3]], column: 5
167167
// CHECK-IR-DAG: ![[L2:[0-9]+]] = distinct !DILocation({{.*}}inlinedAt: ![[L1]])
168-
// CHECK-IR-DAG: !DIFile(filename: "{{.*}}@__swiftmacro_9MacroUser10testFileID1a1bySi_SitF06customdE0fMf_.swift", {{.*}}source: "{{.*}}MacroUser/macro_expand.swift{{.*}}// original-source-range: {{.*}}")
168+
// CHECK-IR-DAG: !DIFile(filename: "{{.*}}@__swiftmacro_9MacroUser0023macro_expandswift_elFCffMX{{.*}}_12customFileIDfMf_.swift", {{.*}}source: "{{.*}}MacroUser/macro_expand.swift{{.*}}// original-source-range: {{.*}}")
169169
#addBlocker(
170170
#stringify(a - b)
171171
)
@@ -278,7 +278,7 @@ func testNested() {
278278
_ = #stringify(#assertAny(Nested()))
279279
// expected-note@-1 {{in expansion of macro 'stringify' here}}
280280
// CHECK-DIAGS-NOT: error: cannot convert value of type 'Nested' to expected argument type 'Bool'
281-
// CHECK-DIAGS: @__swiftmacro_9MacroUser10testNestedyyF9stringifyfMf_9assertAnyfMf_.swift:1:8: error: cannot convert value of type 'Nested' to expected argument type 'Bool'
281+
// CHECK-DIAGS: @__swiftmacro_9MacroUser0023macro_expandswift_elFCffMX{{.*}}_9stringifyfMf_9assertAnyfMf_.swift:1:8: error: cannot convert value of type 'Nested' to expected argument type 'Bool'
282282
// CHECK-DIAGS-NOT: error: cannot convert value of type 'Nested' to expected argument type 'Bool'
283283

284284
// PRETTY-DIAGS: 1:8: error: cannot convert value of type 'Nested' to expected argument type 'Bool'
@@ -299,7 +299,7 @@ func testStringifyWithThrows() throws {
299299
// FIXME: Lots of duplicate notes here
300300
_ = #stringify(maybeThrowing()) // expected-note 4{{in expansion of macro 'stringify' here}}
301301

302-
// CHECK-DIAGS: @__swiftmacro_9MacroUser23testStringifyWithThrowsyyKF9stringifyfMf1_.swift:1:2: error: call can throw but is not marked with 'try'
302+
// CHECK-DIAGS: @__swiftmacro_9MacroUser0023macro_expandswift_elFCffMX{{.*}}_9stringifyfMf1_.swift:1:2: error: call can throw but is not marked with 'try'
303303
#endif
304304

305305
// The macro adds the 'try' for us.
@@ -328,8 +328,8 @@ func testAddBlocker(a: Int, b: Int, c: Int, oa: OnlyAdds) {
328328
// expected-note@-1{{in expansion of macro 'addBlocker' here}}
329329
// expected-note@-2{{use '-'}}{{22-23=-}}
330330

331-
// CHECK-DIAGS: @__swiftmacro_9MacroUser14testAddBlocker1a1b1c2oaySi_S2iAA8OnlyAddsVtF03addE0fMf1_.swift:1:4: error: binary operator '-' cannot be applied to two 'OnlyAdds' operands [] []
332-
// CHECK-DIAGS: CONTENTS OF FILE @__swiftmacro_9MacroUser14testAddBlocker1a1b1c2oaySi_S2iAA8OnlyAddsVtF03addE0fMf1_.swift:
331+
// CHECK-DIAGS: @__swiftmacro_9MacroUser0023macro_expandswift_elFCffMX{{.*}}_10addBlockerfMf1_.swift:1:4: error: binary operator '-' cannot be applied to two 'OnlyAdds' operands [] []
332+
// CHECK-DIAGS: CONTENTS OF FILE @__swiftmacro_9MacroUser0023macro_expandswift_elFCffMX{{.*}}_10addBlockerfMf1_.swift:
333333
// CHECK-DIAGS-NEXT: Original source range: {{.*}}macro_expand.swift:[[@LINE-6]]:7 - {{.*}}macro_expand.swift:[[@LINE-6]]:27
334334
// CHECK-DIAGS-NEXT: oa - oa
335335
// CHECK-DIAGS-NEXT: END CONTENTS OF FILE
@@ -373,7 +373,7 @@ func testNestedDeclInExpr() {
373373
macro defineDeclsWithKnownNames() = #externalMacro(module: "MacroDefinition", type: "DefineDeclsWithKnownNamesMacro")
374374

375375
// Freestanding macros are not in inlined scopes.
376-
// CHECK-SIL: sil_scope {{.*}} { loc "@__swiftmacro_9MacroUser016testFreestandingA9ExpansionyyF4Foo2L_V25defineDeclsWithKnownNamesfMf_.swift"{{.*}} -> Int }
376+
// CHECK-SIL: sil_scope {{.*}} { loc "@__swiftmacro_9MacroUser0023macro_expandswift_elFCffMX{{.*}}_25defineDeclsWithKnownNamesfMf_.swift"{{.*}} -> Int }
377377

378378
// FIXME: Macros producing arbitrary names are not supported yet
379379
#if false
@@ -436,10 +436,10 @@ func testFreestandingMacroExpansion() {
436436
struct Foo3 {
437437
#bitwidthNumberedStructs("BUG", blah: false)
438438
// expected-note@-1 4{{in expansion of macro 'bitwidthNumberedStructs' here}}
439-
// CHECK-DIAGS: CONTENTS OF FILE @__swiftmacro_9MacroUser016testFreestandingA9ExpansionyyF4Foo3L_V23bitwidthNumberedStructsfMf_.swift
439+
// CHECK-DIAGS: CONTENTS OF FILE @__swiftmacro_9MacroUser0023macro_expandswift_elFCffMX{{.*}}_23bitwidthNumberedStructsfMf_.swift
440440
// CHECK-DIAGS: struct BUG {
441-
// CHECK-DIAGS: func $s9MacroUser016testFreestandingA9ExpansionyyF4Foo3L_V23bitwidthNumberedStructsfMf_6methodfMu_()
442-
// CHECK-DIAGS: func $s9MacroUser016testFreestandingA9ExpansionyyF4Foo3L_V23bitwidthNumberedStructsfMf_6methodfMu0{{_?}}()
441+
// CHECK-DIAGS: func $s9MacroUser0023macro_expandswift_elFCffMX{{.*}}_23bitwidthNumberedStructsfMf_6methodfMu_()
442+
// CHECK-DIAGS: func $s9MacroUser0023macro_expandswift_elFCffMX{{.*}}_23bitwidthNumberedStructsfMf_6methodfMu0{{_?}}()
443443
}
444444
#endif
445445

test/Macros/macro_expand_closure.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,12 @@ func multiStatementInference() -> Int {
1919

2020
// The closure intruduced by the macro expansion should not contain any inline
2121
// locations, but instead point directly into the macro buffer.
22-
// CHECK-SIL: sil_scope [[S0:[0-9]+]] { loc "@__swiftmacro_9MacroUser23multiStatementInferenceSiyF0cD0fMf_.swift":1:1 parent @$s9MacroUser23multiStatementInferenceSiyFSiyXEfU_
23-
// CHECK-SIL: sil_scope [[S2:[0-9]+]] { loc "@__swiftmacro_9MacroUser23multiStatementInferenceSiyF0cD0fMf_.swift":2:14 parent [[S0]] }
22+
// CHECK-SIL: sil_scope [[S0:[0-9]+]] { loc "@__swiftmacro_9MacroUser0031macro_expand_closureswift_yFFIifMX16_2_14multiStatementfMf_.swift":1:1 parent @$s9MacroUser23multiStatementInferenceSiyFSiyXEfU_
23+
// CHECK-SIL: sil_scope [[S2:[0-9]+]] { loc "@__swiftmacro_9MacroUser0031macro_expand_closureswift_yFFIifMX16_2_14multiStatementfMf_.swift":2:14 parent [[S0]] }
2424

2525
// CHECK-SIL: sil {{.*}} @$s9MacroUser23multiStatementInferenceSiyFSiyXEfU_
2626
// CHECK-SIL-NOT: return
27-
// CHECK-SIL: %0 = integer_literal $Builtin.Int{{64|32}}, 10, loc "@__swiftmacro_9MacroUser23multiStatementInferenceSiyF0cD0fMf_.swift":2:14, scope [[S2]]
27+
// CHECK-SIL: %0 = integer_literal $Builtin.Int{{64|32}}, 10, loc "@__swiftmacro_9MacroUser0031macro_expand_closureswift_yFFIifMX16_2_14multiStatementfMf_.swift":2:14, scope [[S2]]
2828

2929
// CHECK: 10
3030
print(multiStatementInference())

test/Macros/macro_expand_codeitems.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ func testFreestandingMacroExpansion() {
2121
// CHECK: from stmt
2222
// CHECK: from usedInExpandedStmt
2323
// CHECK: from expr
24-
// CHECK-DIAGS: struct $s9MacroUser016testFreestandingA9ExpansionyyF9codeItemsfMf_3foofMu_ {
24+
// CHECK-DIAGS: struct $s9MacroUser0033macro_expand_codeitemsswift_DbGHjfMX25_2_9codeItemsfMf_3foofMu_ {
2525
// CHECK-DIAGS: END CONTENTS OF FILE
2626
#codeItems
2727

test/Macros/skip_non_exportable_decls.swift

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,11 @@
1010
@freestanding(declaration)
1111
macro anonymousTypes(public: Bool = false, causeErrors: Bool = false, _: () -> String) = #externalMacro(module: "MacroDefinition", type: "DefineAnonymousTypesMacro")
1212

13-
// CHECK: sil @$s9MacroUser03$s9A70User33_B2D49A1BE4DC7AF5CC327EB8EE2214BDLl14anonymousTypesfMf_4namefMu_C5helloSSyF : $@convention(method) (@guaranteed $s9MacroUser33_B2D49A1BE4DC7AF5CC327EB8EE2214BDLl14anonymousTypesfMf_4namefMu_) -> @owned String {
13+
// CHECK: sil @$s9MacroUser03$s9A118User0036skip_non_exportable_declsswift_tjBBlfMX14_0_33_B2D49A1BE4DC7AF5CC327EB8EE2214BDLl14anonymousTypesfMf_4namefMu_C5helloSSyF : $@convention(method) (@guaranteed $s9MacroUser0036skip_non_exportable_declsswift_tjBBlfMX14_0_33_B2D49A1BE4DC7AF5CC327EB8EE2214BDLl14anonymousTypesfMf_4namefMu_) -> @owned String {
14+
1415
#anonymousTypes(public: true) { "hello" }
1516

16-
// CHECK-NOT: s9MacroUser03$s9A71User33_B2D49A1BE4DC7AF5CC327EB8EE2214BDLl14anonymousTypesfMf_4namefMu0_O5helloSSyF
1717
#anonymousTypes(public: false) { "goodbye" }
18+
19+
// FIXME: Changing 'public: false' to 'public: true' above doesn't seem to
20+
// have any effect on the generated SIL. Perhaps there is a bug here.

0 commit comments

Comments
 (0)