10
10
//
11
11
// ===----------------------------------------------------------------------===//
12
12
13
+ #include " ParseSIL.h"
13
14
#include " swift/AST/ASTWalker.h"
14
15
#include " swift/AST/ExistentialLayout.h"
15
16
#include " swift/AST/GenericEnvironment.h"
@@ -34,38 +35,10 @@ using namespace swift;
34
35
// SILParserState implementation
35
36
// ===----------------------------------------------------------------------===//
36
37
37
- namespace swift {
38
- class SILParserTUState {
39
- public:
40
- SILParserTUState (SILModule &M) : M(M) {}
41
- ~SILParserTUState ();
42
-
43
- SILModule &M;
44
-
45
- // / This is all of the forward referenced functions with
46
- // / the location for where the reference is.
47
- llvm::DenseMap<Identifier,
48
- std::pair<SILFunction*, SourceLoc>> ForwardRefFns;
49
- // / A list of all functions forward-declared by a sil_scope.
50
- llvm::DenseSet<SILFunction *> PotentialZombieFns;
51
-
52
- // / A map from textual .sil scope number to SILDebugScopes.
53
- llvm::DenseMap<unsigned , SILDebugScope *> ScopeSlots;
54
-
55
- // / Did we parse a sil_stage for this module?
56
- bool DidParseSILStage = false ;
57
-
58
- DiagnosticEngine *Diags = nullptr ;
59
- };
60
- } // namespace swift
61
-
62
- SILParserState::SILParserState (SILModule *M) : M(M) {
63
- S = M ? new SILParserTUState (*M) : nullptr ;
64
- }
38
+ SILParserState::SILParserState (SILModule *M)
39
+ : Impl(M ? new SILParserTUState(*M) : nullptr) { }
65
40
66
- SILParserState::~SILParserState () {
67
- delete S;
68
- }
41
+ SILParserState::~SILParserState () = default ;
69
42
70
43
SILParserTUState::~SILParserTUState () {
71
44
if (!ForwardRefFns.empty ())
@@ -138,7 +111,7 @@ namespace {
138
111
bool localScope);
139
112
public:
140
113
SILParser (Parser &P)
141
- : P(P), SILMod(* P.SIL->M), TUState(*P.SIL->S ),
114
+ : P(P), SILMod(P.SIL->M), TUState(*P.SIL),
142
115
ParsedTypeCallback ([](Type ty) {}) {}
143
116
144
117
// / diagnoseProblems - After a function is fully parse, emit any diagnostics
@@ -4885,13 +4858,13 @@ bool Parser::parseDeclSILStage() {
4885
4858
return true ;
4886
4859
}
4887
4860
4888
- if (SIL->S -> DidParseSILStage ) {
4861
+ if (SIL->DidParseSILStage ) {
4889
4862
diagnose (stageLoc, diag::multiple_sil_stage_decls);
4890
4863
return false ;
4891
4864
}
4892
4865
4893
- SIL->M -> setStage (stage);
4894
- SIL->S -> DidParseSILStage = true ;
4866
+ SIL->M . setStage (stage);
4867
+ SIL->DidParseSILStage = true ;
4895
4868
return false ;
4896
4869
}
4897
4870
@@ -4927,7 +4900,7 @@ bool Parser::parseSILGlobal() {
4927
4900
GlobalLinkage = SILLinkage::DefaultForDefinition;
4928
4901
4929
4902
// FIXME: check for existing global variable?
4930
- auto *GV = SILGlobalVariable::create (* SIL->M , GlobalLinkage.getValue (),
4903
+ auto *GV = SILGlobalVariable::create (SIL->M , GlobalLinkage.getValue (),
4931
4904
isSerialized,
4932
4905
GlobalName.str (),GlobalType,
4933
4906
RegularLocation (NameLoc));
@@ -5011,7 +4984,7 @@ bool Parser::parseSILVTable() {
5011
4984
VTableState.parseSILIdentifier (FuncName, FuncLoc,
5012
4985
diag::expected_sil_value_name))
5013
4986
return true ;
5014
- Func = SIL->M -> lookUpFunction (FuncName.str ());
4987
+ Func = SIL->M . lookUpFunction (FuncName.str ());
5015
4988
if (!Func) {
5016
4989
diagnose (FuncLoc, diag::sil_vtable_func_not_found, FuncName);
5017
4990
return true ;
@@ -5027,7 +5000,7 @@ bool Parser::parseSILVTable() {
5027
5000
parseMatchingToken (tok::r_brace, RBraceLoc, diag::expected_sil_rbrace,
5028
5001
LBraceLoc);
5029
5002
5030
- SILVTable::create (* SIL->M , theClass, vtableEntries);
5003
+ SILVTable::create (SIL->M , theClass, vtableEntries);
5031
5004
return false ;
5032
5005
}
5033
5006
@@ -5309,7 +5282,7 @@ bool Parser::parseSILWitnessTable() {
5309
5282
5310
5283
SILWitnessTable *wt = nullptr ;
5311
5284
if (theConformance) {
5312
- wt = SIL->M -> lookUpWitnessTable (theConformance, false );
5285
+ wt = SIL->M . lookUpWitnessTable (theConformance, false );
5313
5286
assert ((!wt || wt->isDeclaration ()) &&
5314
5287
" Attempting to create duplicate witness table." );
5315
5288
}
@@ -5321,7 +5294,7 @@ bool Parser::parseSILWitnessTable() {
5321
5294
Linkage = SILLinkage::PublicExternal;
5322
5295
// We ignore empty witness table without normal protocol conformance.
5323
5296
if (!wt && theConformance)
5324
- wt = SILWitnessTable::create (* SIL->M , *Linkage, theConformance);
5297
+ wt = SILWitnessTable::create (SIL->M , *Linkage, theConformance);
5325
5298
BodyScope.reset ();
5326
5299
return false ;
5327
5300
}
@@ -5441,7 +5414,7 @@ bool Parser::parseSILWitnessTable() {
5441
5414
diag::expected_sil_value_name))
5442
5415
return true ;
5443
5416
5444
- Func = SIL->M -> lookUpFunction (FuncName.str ());
5417
+ Func = SIL->M . lookUpFunction (FuncName.str ());
5445
5418
if (!Func) {
5446
5419
diagnose (FuncLoc, diag::sil_witness_func_not_found, FuncName);
5447
5420
return true ;
@@ -5462,7 +5435,7 @@ bool Parser::parseSILWitnessTable() {
5462
5435
Linkage = SILLinkage::Public;
5463
5436
5464
5437
if (!wt)
5465
- wt = SILWitnessTable::create (* SIL->M , *Linkage, theConformance);
5438
+ wt = SILWitnessTable::create (SIL->M , *Linkage, theConformance);
5466
5439
wt->convertToDefinition (witnessEntries, isSerialized);
5467
5440
BodyScope.reset ();
5468
5441
return false ;
@@ -5532,7 +5505,7 @@ bool Parser::parseSILDefaultWitnessTable() {
5532
5505
diag::expected_sil_value_name))
5533
5506
return true ;
5534
5507
5535
- SILFunction *Func = SIL->M -> lookUpFunction (FuncName.str ());
5508
+ SILFunction *Func = SIL->M . lookUpFunction (FuncName.str ());
5536
5509
if (!Func) {
5537
5510
diagnose (FuncLoc, diag::sil_witness_func_not_found, FuncName);
5538
5511
return true ;
@@ -5549,7 +5522,7 @@ bool Parser::parseSILDefaultWitnessTable() {
5549
5522
if (!Linkage)
5550
5523
Linkage = SILLinkage::Public;
5551
5524
5552
- SILDefaultWitnessTable::create (* SIL->M , *Linkage, protocol, witnessEntries);
5525
+ SILDefaultWitnessTable::create (SIL->M , *Linkage, protocol, witnessEntries);
5553
5526
BodyScope.reset ();
5554
5527
return false ;
5555
5528
}
@@ -5632,7 +5605,7 @@ bool Parser::parseSILCoverageMap() {
5632
5605
diag::expected_sil_value_name))
5633
5606
return true ;
5634
5607
5635
- SILFunction *Func = SIL->M -> lookUpFunction (FuncName.str ());
5608
+ SILFunction *Func = SIL->M . lookUpFunction (FuncName.str ());
5636
5609
if (!Func) {
5637
5610
diagnose (FuncLoc, diag::sil_coverage_func_not_found, FuncName);
5638
5611
return true ;
@@ -5688,7 +5661,7 @@ bool Parser::parseSILCoverageMap() {
5688
5661
LBraceLoc);
5689
5662
5690
5663
if (!BodyHasError)
5691
- SILCoverageMap::create (* SIL->M , Filename.str (), FuncName.str (),
5664
+ SILCoverageMap::create (SIL->M , Filename.str (), FuncName.str (),
5692
5665
Func->isPossiblyUsedExternally (), Hash, Regions,
5693
5666
Builder.getExpressions ());
5694
5667
return false ;
@@ -5763,12 +5736,12 @@ bool Parser::parseSILScope() {
5763
5736
parseMatchingToken (tok::r_brace, RBraceLoc, diag::expected_sil_rbrace,
5764
5737
LBraceLoc);
5765
5738
5766
- auto &Scope = SIL->S -> ScopeSlots [Slot];
5739
+ auto &Scope = SIL->ScopeSlots [Slot];
5767
5740
if (Scope) {
5768
5741
diagnose (SlotLoc, diag::sil_scope_redefined, Slot);
5769
5742
return true ;
5770
5743
}
5771
5744
5772
- Scope = new (* SIL->M ) SILDebugScope (Loc, ParentFn, Parent, InlinedAt);
5745
+ Scope = new (SIL->M ) SILDebugScope (Loc, ParentFn, Parent, InlinedAt);
5773
5746
return false ;
5774
5747
}
0 commit comments