@@ -345,18 +345,11 @@ class ASTScopeImpl {
345
345
virtual SourceRange sourceRangeForDeferredExpansion () const ;
346
346
347
347
public:
348
- virtual NullablePtr<AbstractStorageDecl>
349
- getEnclosingAbstractStorageDecl () const ;
350
-
351
348
bool isATypeDeclScope () const ;
352
349
353
350
private:
354
351
virtual ScopeCreator &getScopeCreator ();
355
352
356
- #pragma mark - - creation queries
357
- public:
358
- virtual bool isThisAnAbstractStorageDecl () const { return false ; }
359
-
360
353
#pragma mark - lookup
361
354
362
355
public:
@@ -849,9 +842,6 @@ class GenericParamScope final : public ASTScopeImpl {
849
842
void printSpecifics (llvm::raw_ostream &out) const override ;
850
843
851
844
public:
852
- NullablePtr<AbstractStorageDecl>
853
- getEnclosingAbstractStorageDecl () const override ;
854
-
855
845
NullablePtr<const void > addressForPrinting () const override {
856
846
return paramList;
857
847
}
@@ -887,9 +877,6 @@ class AbstractFunctionDeclScope final : public ASTScopeImpl {
887
877
virtual NullablePtr<Decl> getDeclIfAny () const override { return decl; }
888
878
Decl *getDecl () const { return decl; }
889
879
890
- NullablePtr<AbstractStorageDecl>
891
- getEnclosingAbstractStorageDecl () const override ;
892
-
893
880
NullablePtr<const void > getReferrent () const override ;
894
881
895
882
protected:
@@ -914,8 +901,7 @@ class ParameterListScope final : public ASTScopeImpl {
914
901
ASTScopeImpl *expandSpecifically (ScopeCreator &scopeCreator) override ;
915
902
916
903
private:
917
- AnnotatedInsertionPoint
918
- expandAScopeThatCreatesANewInsertionPoint (ScopeCreator &);
904
+ void expandAScopeThatDoesNotCreateANewInsertionPoint (ScopeCreator &);
919
905
SourceLoc fixupEndForBadInput (SourceRange) const ;
920
906
921
907
public:
@@ -924,17 +910,16 @@ class ParameterListScope final : public ASTScopeImpl {
924
910
getSourceRangeOfThisASTNode (bool omitAssertions = false ) const override ;
925
911
virtual NullablePtr<DeclContext> getDeclContext () const override ;
926
912
927
- NullablePtr<AbstractStorageDecl>
928
- getEnclosingAbstractStorageDecl () const override ;
929
913
NullablePtr<const void > addressForPrinting () const override { return params; }
930
914
};
931
915
932
- class AbstractFunctionBodyScope : public ASTScopeImpl {
916
+ // / Body of functions, methods, constructors, destructors and accessors.
917
+ class FunctionBodyScope : public ASTScopeImpl {
933
918
public:
934
919
AbstractFunctionDecl *const decl;
935
920
936
- AbstractFunctionBodyScope (AbstractFunctionDecl *e) : decl(e) {}
937
- virtual ~AbstractFunctionBodyScope () {}
921
+ FunctionBodyScope (AbstractFunctionDecl *e) : decl(e) {}
922
+ virtual ~FunctionBodyScope () {}
938
923
939
924
protected:
940
925
ASTScopeImpl *expandSpecifically (ScopeCreator &scopeCreator) override ;
@@ -956,19 +941,11 @@ class AbstractFunctionBodyScope : public ASTScopeImpl {
956
941
bool lookupLocalsOrMembers (DeclConsumer) const override ;
957
942
958
943
public:
944
+ std::string getClassName () const override ;
959
945
NullablePtr<ASTScopeImpl> insertionPointForDeferredExpansion () override ;
960
946
SourceRange sourceRangeForDeferredExpansion () const override ;
961
947
};
962
948
963
- // / Body of functions and methods.
964
- class FunctionBodyScope final : public AbstractFunctionBodyScope {
965
- public:
966
- FunctionBodyScope (AbstractFunctionDecl *e)
967
- : AbstractFunctionBodyScope(e) {}
968
- std::string getClassName () const override ;
969
- bool lookupLocalsOrMembers (DeclConsumer consumer) const override ;
970
- };
971
-
972
949
class DefaultArgumentInitializerScope final : public ASTScopeImpl {
973
950
public:
974
951
ParamDecl *const decl;
@@ -1001,17 +978,19 @@ class DefaultArgumentInitializerScope final : public ASTScopeImpl {
1001
978
1002
979
class AttachedPropertyWrapperScope final : public ASTScopeImpl {
1003
980
public:
1004
- VarDecl *const decl;
981
+ CustomAttr *attr;
982
+ VarDecl *decl;
983
+
1005
984
// / Because we have to avoid request cycles, we approximate the test for an
1006
985
// / AttachedPropertyWrapper with one based on source location. We might get
1007
986
// / false positives, that that doesn't hurt anything. However, the result of
1008
987
// / the conservative source range computation doesn't seem to be stable. So
1009
988
// / keep the original here, and use it for source range queries.
1010
-
1011
989
const SourceRange sourceRangeWhenCreated;
1012
990
1013
- AttachedPropertyWrapperScope (VarDecl *e)
1014
- : decl(e), sourceRangeWhenCreated(getSourceRangeOfVarDecl(e)) {
991
+ AttachedPropertyWrapperScope (CustomAttr *attr, VarDecl *decl)
992
+ : attr(attr), decl(decl),
993
+ sourceRangeWhenCreated (attr->getTypeRepr ()->getSourceRange()) {
1015
994
ASTScopeAssert (sourceRangeWhenCreated.isValid (),
1016
995
" VarDecls must have ranges to be looked-up" );
1017
996
}
@@ -1027,7 +1006,10 @@ class AttachedPropertyWrapperScope final : public ASTScopeImpl {
1027
1006
NullablePtr<const void > addressForPrinting () const override { return decl; }
1028
1007
virtual NullablePtr<DeclContext> getDeclContext () const override ;
1029
1008
1030
- static SourceRange getSourceRangeOfVarDecl (const VarDecl *);
1009
+ NullablePtr<DeclAttribute> getDeclAttributeIfAny () const override {
1010
+ return attr;
1011
+ }
1012
+ NullablePtr<const void > getReferrent () const override ;
1031
1013
1032
1014
private:
1033
1015
void expandAScopeThatDoesNotCreateANewInsertionPoint (ScopeCreator &);
@@ -1068,11 +1050,8 @@ class AbstractPatternEntryScope : public ASTScopeImpl {
1068
1050
1069
1051
protected:
1070
1052
void printSpecifics (llvm::raw_ostream &out) const override ;
1071
- void forEachVarDeclWithLocalizableAccessors (
1072
- ScopeCreator &scopeCreator, function_ref<void (VarDecl *)> foundOne) const ;
1073
1053
1074
1054
public:
1075
- bool isLastEntry () const ;
1076
1055
NullablePtr<Decl> getDeclIfAny () const override { return decl; }
1077
1056
Decl *getDecl () const { return decl; }
1078
1057
};
@@ -1116,8 +1095,7 @@ class PatternEntryInitializerScope final : public AbstractPatternEntryScope {
1116
1095
ASTScopeImpl *expandSpecifically (ScopeCreator &scopeCreator) override ;
1117
1096
1118
1097
private:
1119
- AnnotatedInsertionPoint
1120
- expandAScopeThatCreatesANewInsertionPoint (ScopeCreator &);
1098
+ void expandAScopeThatDoesNotCreateANewInsertionPoint (ScopeCreator &);
1121
1099
1122
1100
public:
1123
1101
std::string getClassName () const override ;
@@ -1296,9 +1274,6 @@ class SpecializeAttributeScope final : public ASTScopeImpl {
1296
1274
return specializeAttr;
1297
1275
}
1298
1276
1299
- NullablePtr<AbstractStorageDecl>
1300
- getEnclosingAbstractStorageDecl () const override ;
1301
-
1302
1277
NullablePtr<DeclAttribute> getDeclAttributeIfAny () const override {
1303
1278
return specializeAttr;
1304
1279
}
@@ -1329,9 +1304,6 @@ class DifferentiableAttributeScope final : public ASTScopeImpl {
1329
1304
return differentiableAttr;
1330
1305
}
1331
1306
1332
- NullablePtr<AbstractStorageDecl>
1333
- getEnclosingAbstractStorageDecl () const override ;
1334
-
1335
1307
NullablePtr<DeclAttribute> getDeclAttributeIfAny () const override {
1336
1308
return differentiableAttr;
1337
1309
}
@@ -1373,44 +1345,6 @@ class SubscriptDeclScope final : public ASTScopeImpl {
1373
1345
1374
1346
protected:
1375
1347
NullablePtr<const GenericParamList> genericParams () const override ;
1376
- NullablePtr<AbstractStorageDecl>
1377
- getEnclosingAbstractStorageDecl () const override {
1378
- return decl;
1379
- }
1380
- public:
1381
- bool isThisAnAbstractStorageDecl () const override { return true ; }
1382
- };
1383
-
1384
- class VarDeclScope final : public ASTScopeImpl {
1385
-
1386
- public:
1387
- VarDecl *const decl;
1388
- VarDeclScope (VarDecl *e) : decl(e) {}
1389
- virtual ~VarDeclScope () {}
1390
-
1391
- protected:
1392
- ASTScopeImpl *expandSpecifically (ScopeCreator &scopeCreator) override ;
1393
-
1394
- private:
1395
- void expandAScopeThatDoesNotCreateANewInsertionPoint (ScopeCreator &);
1396
-
1397
- public:
1398
- std::string getClassName () const override ;
1399
- SourceRange
1400
- getSourceRangeOfThisASTNode (bool omitAssertions = false ) const override ;
1401
-
1402
- protected:
1403
- void printSpecifics (llvm::raw_ostream &out) const override ;
1404
-
1405
- public:
1406
- virtual NullablePtr<Decl> getDeclIfAny () const override { return decl; }
1407
- Decl *getDecl () const { return decl; }
1408
- NullablePtr<const void > getReferrent () const override ;
1409
- NullablePtr<AbstractStorageDecl>
1410
- getEnclosingAbstractStorageDecl () const override {
1411
- return decl;
1412
- }
1413
- bool isThisAnAbstractStorageDecl () const override { return true ; }
1414
1348
};
1415
1349
1416
1350
class EnumElementScope : public ASTScopeImpl {
0 commit comments