Skip to content

Commit 148d642

Browse files
Merge pull request #5158 from swiftwasm/main
[pull] swiftwasm from main
2 parents e96040c + 08c5553 commit 148d642

File tree

7 files changed

+173
-15
lines changed

7 files changed

+173
-15
lines changed

.github/CODEOWNERS

Lines changed: 107 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,33 @@
11
# Lines starting with '#' are comments.
2-
# Each line is a file pattern followed by one or more owners.
2+
# Each line is a case-sensitive file pattern followed by one or more owners.
33
# Order is important. The last matching pattern has the most precedence.
4+
# More information: https://docs.github.com/en/articles/about-code-owners
45

5-
# Owners of ASTGen
6-
lib/ASTGen @zoecarver @CodaFi
6+
# .github
7+
/.github/ @shahmishal
8+
/.github/CODEOWNERS @AnthonyLatsis @shahmishal
9+
/.github/ISSUE_TEMPLATE/ @AnthonyLatsis @hborla @LucianoPAlmeida @shahmishal @xedin
10+
/.github/PULL_REQUEST_TEMPLATE.md @AnthonyLatsis @hborla @LucianoPAlmeida @shahmishal @xedin
11+
12+
# docs
13+
/docs/HowToGuides/ @AnthonyLatsis @LucianoPAlmeida @xedin
14+
/docs/Generics/ @slavapestov
15+
/docs/Generics.rst @slavapestov
16+
17+
# Standard Library
18+
# TODO: /stdlib/
19+
/stdlib/public/Cxx/ @zoecarver @hyp @egorzhdan
20+
/stdlib/public/Distributed/ @ktoso
21+
/stdlib/public/Windows/ @compnerd
22+
# TODO: /*test/stdlib/
23+
# TODO: /unittests/stdlib/
24+
25+
# ASTGen
26+
/lib/ASTGen/ @zoecarver @CodaFi
27+
/test/ASTGen/ @zoecarver @CodaFi
728

829
# Dependency scanning
930
include/swift/DependencyScan @artemcm
10-
lib/AST/ModuleLoader.cpp @artemcm
1131
lib/DependencyScan @artemcm
1232
lib/Frontend/ModuleInterfaceLoader.cpp @artemcm
1333
lib/Serialization/SerializedModuleLoader.cpp @artemcm
@@ -19,9 +39,10 @@ lib/Driver @artemcm
1939
test/Driver @artemcm
2040

2141
# Owners of the parser
22-
include/swift/Parse @ahoppen @bnbarham @CodaFi @DougGregor @rintaro
23-
lib/Parse @ahoppen @bnbarham @CodaFi @DougGregor @rintaro
24-
test/Parse @ahoppen @bnbarham @CodaFi @DougGregor @rintaro
42+
/include/swift/Parse/ @ahoppen @bnbarham @CodaFi @DougGregor @rintaro
43+
/lib/Parse/ @ahoppen @bnbarham @CodaFi @DougGregor @rintaro
44+
/*test/Parse/ @ahoppen @bnbarham @CodaFi @DougGregor @rintaro
45+
/unittests/Parse/ @ahoppen @bnbarham @CodaFi @DougGregor @rintaro
2546

2647
SwiftCompilerSources @eeckstein
2748

@@ -30,7 +51,6 @@ include/swift/ClangImporter @zoecarver @hyp @egorzhdan
3051
include/swift/PrintAsClang @zoecarver @hyp @egorzhdan
3152
lib/ClangImporter @zoecarver @hyp @egorzhdan
3253
lib/PrintAsClang @zoecarver @hyp @egorzhdan
33-
stdlib/public/Cxx @zoecarver @hyp @egorzhdan
3454
test/Interop @zoecarver @hyp @egorzhdan
3555

3656
# Threading implementation
@@ -40,5 +60,83 @@ lib/Threading @al45tair
4060
# Windows support
4161
cmake/**/*Windows* @compnerd
4262
lib/Basic/Windows @compnerd
43-
stdlib/public/Windows @compnerd
4463
utils/*windows* @compnerd
64+
65+
# AST
66+
/include/swift/AST/ @hborla @slavapestov @xedin
67+
/include/swift/AST/*Conformance* @slavapestov
68+
/include/swift/AST/*Distributed* @ktoso
69+
/include/swift/AST/Evaluator* @CodaFi @slavapestov
70+
/include/swift/AST/*Generic* @hborla @slavapestov
71+
/include/swift/AST/*Protocol* @hborla @slavapestov
72+
/include/swift/AST/*Requirement* @hborla @slavapestov
73+
/include/swift/AST/*Substitution* @slavapestov
74+
/lib/AST/ @hborla @slavapestov @xedin
75+
/lib/AST/*Conformance* @slavapestov
76+
/lib/AST/Evaluator* @CodaFi @slavapestov
77+
/lib/AST/*Generic* @hborla @slavapestov
78+
/lib/AST/ModuleLoader.cpp @artemcm
79+
/lib/AST/*Requirement* @hborla @slavapestov
80+
/lib/AST/RequirementMachine/ @slavapestov
81+
/lib/AST/*Substitution @slavapestov
82+
/unittests/AST/ @hborla @slavapestov @xedin
83+
/unittests/AST/*Evaluator* @CodaFi @slavapestov
84+
85+
# Sema
86+
/include/swift/Sema/ @hborla @slavapestov @xedin
87+
/include/swift/Sema/Constraint* @hborla @xedin
88+
/include/swift/Sema/CS* @hborla @xedin
89+
/lib/Sema/ @hborla @slavapestov @xedin
90+
/lib/Sema/Constraint* @hborla @xedin
91+
/lib/Sema/CS* @hborla @xedin
92+
/lib/Sema/CodeSynthesisDistributed* @hborla @ktoso
93+
/lib/Sema/DerivedConformance* @slavapestov
94+
/lib/Sema/DerivedConformanceDistributed* @ktoso @slavapestov
95+
/lib/Sema/TypeCheckDistributed* @hborla @ktoso @xedin
96+
/lib/Sema/TypeCheckType* @AnthonyLatsis @hborla @slavapestov @xedin
97+
/lib/Sema/TypeCheckProtocol* @AnthonyLatsis @hborla @slavapestov
98+
/test/Constraints/ @hborla @xedin
99+
/test/decl/ @hborla @slavapestov
100+
/test/decl/protocol/ @AnthonyLatsis @hborla @slavapestov
101+
# FIXME: This file could have a dedicated directory.
102+
/test/decl/protocol/special/DistributedActor.swift @ktoso
103+
# FIXME: Should there be a 'Sema' folder under 'Distributed'? Or perhaps it
104+
# should be the other way around, i.e 'Sema/Distributed', 'SILGen/Distributed',
105+
# etc.?
106+
/test/Distributed/* @ktoso
107+
# FIXME: Is there a better way to structure this high-level 'Inputs' dir.? We
108+
# want only the Sema bits here.
109+
/test/Distributed/Inputs/ @ktoso
110+
/test/expr/ @hborla @slavapestov @xedin
111+
/test/Generics/ @hborla @slavapestov
112+
/test/Sema/ @hborla @slavapestov @xedin
113+
/test/stmt/ @hborla @xedin
114+
/test/type/ @hborla @slavapestov @xedin
115+
/validation-test/Sema/ @hborla @slavapestov @xedin
116+
/unittests/Sema/ @hborla @xedin
117+
118+
# SIL/SILGen
119+
# TODO: /include/swift/SIL/
120+
# TODO: /lib/SIL/
121+
# TODO: /lib/SILGen/
122+
/lib/SILGen/*Distributed* @ktoso
123+
/test/Distributed/SIL/ @ktoso
124+
# TODO: /*test/SIL/
125+
# TODO: /*test/SILGen/
126+
# TODO: /unittests/SIL/
127+
128+
# SILOptimizer
129+
# TODO: /include/swift/SILOptimizer/
130+
/include/swift/SILOptimizer/Utils/Distributed* @ktoso
131+
# TODO: /lib/SILOptimizer/
132+
/lib/SILOptimizer/Utils/Distributed* @ktoso
133+
# TODO: /*test/SILOptimizer/
134+
135+
# IRGen
136+
# TODO: /include/swift/IRGen/
137+
# TODO: /lib/IRGen/
138+
/lib/IRGen/*Distributed* @ktoso
139+
# TODO: /*test/IRGen/
140+
141+
# TODO: Find a better place for this entry.
142+
/test/Distributed/Runtime @ktoso

lib/AST/Decl.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2027,11 +2027,11 @@ SourceLoc PatternBindingDecl::getEqualLoc(unsigned i) const {
20272027
}
20282028

20292029
SourceLoc TopLevelCodeDecl::getStartLoc() const {
2030-
return Body->getStartLoc();
2030+
return Body ? Body->getStartLoc() : SourceLoc();
20312031
}
20322032

20332033
SourceRange TopLevelCodeDecl::getSourceRange() const {
2034-
return Body->getSourceRange();
2034+
return Body? Body->getSourceRange() : SourceRange();
20352035
}
20362036

20372037
SourceRange IfConfigDecl::getSourceRange() const {

lib/AST/DeclContext.cpp

Lines changed: 37 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -283,9 +283,44 @@ ModuleDecl *DeclContext::getParentModule() const {
283283

284284
SourceFile *DeclContext::getParentSourceFile() const {
285285
const DeclContext *DC = this;
286-
while (!DC->isModuleScopeContext())
286+
SourceLoc loc;
287+
while (!DC->isModuleScopeContext()) {
288+
// If we don't have a source location yet, try to grab one from this
289+
// context.
290+
if (loc.isInvalid()) {
291+
switch (DC->getContextKind()) {
292+
case DeclContextKind::AbstractClosureExpr:
293+
loc = cast<AbstractClosureExpr>(DC)->getLoc();
294+
break;
295+
296+
case DeclContextKind::AbstractFunctionDecl:
297+
case DeclContextKind::EnumElementDecl:
298+
case DeclContextKind::ExtensionDecl:
299+
case DeclContextKind::GenericTypeDecl:
300+
case DeclContextKind::MacroDecl:
301+
case DeclContextKind::SubscriptDecl:
302+
case DeclContextKind::TopLevelCodeDecl:
303+
loc = DC->getAsDecl()->getLoc(/*SerializedOK=*/false);
304+
break;
305+
306+
case DeclContextKind::Initializer:
307+
case DeclContextKind::FileUnit:
308+
case DeclContextKind::Module:
309+
case DeclContextKind::SerializedLocal:
310+
break;
311+
}
312+
}
313+
287314
DC = DC->getParent();
288-
return const_cast<SourceFile *>(dyn_cast<SourceFile>(DC));
315+
}
316+
317+
auto fallbackSF = const_cast<SourceFile *>(dyn_cast<SourceFile>(DC));
318+
if (auto module = DC->getParentModule()) {
319+
if (auto sf = module->getSourceFileContainingLocation(loc))
320+
return sf;
321+
}
322+
323+
return fallbackSF;
289324
}
290325

291326
DeclContext *DeclContext::getModuleScopeContext() const {

lib/AST/Expr.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2024,15 +2024,19 @@ swift::_getRef__AbstractClosureExpr_getActorIsolation() {
20242024

20252025
#define FORWARD_SOURCE_LOCS_TO(CLASS, NODE) \
20262026
SourceRange CLASS::getSourceRange() const { \
2027+
if (!NODE) { return SourceRange(); } \
20272028
return (NODE)->getSourceRange(); \
20282029
} \
20292030
SourceLoc CLASS::getStartLoc() const { \
2031+
if (!NODE) { return SourceLoc(); } \
20302032
return (NODE)->getStartLoc(); \
20312033
} \
20322034
SourceLoc CLASS::getEndLoc() const { \
2035+
if (!NODE) { return SourceLoc(); } \
20332036
return (NODE)->getEndLoc(); \
20342037
} \
20352038
SourceLoc CLASS::getLoc() const { \
2039+
if (!NODE) { return SourceLoc(); } \
20362040
return (NODE)->getStartLoc(); \
20372041
}
20382042

lib/AST/Module.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -573,7 +573,8 @@ void ModuleDecl::updateSourceFileLocationMap() {
573573
}
574574

575575
// If we are up-to-date, there's nothing to do.
576-
if (sourceFileLocationMap->numFiles == getFiles().size() &&
576+
ArrayRef<FileUnit *> files = Files;
577+
if (sourceFileLocationMap->numFiles == files.size() &&
577578
sourceFileLocationMap->numAuxiliaryFiles ==
578579
AuxiliaryFiles.size())
579580
return;
@@ -582,7 +583,7 @@ void ModuleDecl::updateSourceFileLocationMap() {
582583
sourceFileLocationMap->allSourceFiles.clear();
583584

584585
// First, add all of the source files with a backing buffer.
585-
for (auto *fileUnit : getFiles()) {
586+
for (auto *fileUnit : files) {
586587
if (auto sourceFile = dyn_cast<SourceFile>(fileUnit)) {
587588
if (sourceFile->getBufferID())
588589
sourceFileLocationMap->allSourceFiles.push_back(sourceFile);

test/Macros/Inputs/syntax_macro_definitions.swift

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,3 +167,16 @@ public class RecursiveMacro: ExpressionMacro {
167167
return "()"
168168
}
169169
}
170+
171+
public class NestedDeclInExprMacro: ExpressionMacro {
172+
public static func expansion(
173+
of macro: MacroExpansionExprSyntax, in context: inout MacroExpansionContext
174+
) -> ExprSyntax {
175+
return """
176+
{ () -> Void in
177+
struct Foo { }
178+
return ()
179+
}
180+
"""
181+
}
182+
}

test/Macros/macro_expand.swift

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,3 +92,10 @@ func testAddBlocker(a: Int, b: Int, c: Int, oa: OnlyAdds) {
9292
#recurse(true) // expected-note{{in expansion of macro 'recurse' here}}
9393
#endif
9494
}
95+
96+
// Make sure we don't crash with declarations produced by expansions.
97+
@expression macro nestedDeclInExpr: () -> Void = #externalMacro(module: "MacroDefinition", type: "NestedDeclInExprMacro")
98+
99+
func testNestedDeclInExpr() {
100+
let _: () -> Void = #nestedDeclInExpr
101+
}

0 commit comments

Comments
 (0)