@@ -218,6 +218,10 @@ class ASTScopeImpl : public ASTAllocated<ASTScopeImpl> {
218
218
return nullptr ;
219
219
}
220
220
221
+ virtual NullablePtr<MacroExpansionDecl> getFreestandingMacro () const {
222
+ return nullptr ;
223
+ }
224
+
221
225
#pragma mark - debugging and printing
222
226
223
227
public:
@@ -278,6 +282,10 @@ class ASTScopeImpl : public ASTAllocated<ASTScopeImpl> {
278
282
static std::pair<CaseStmt *, CaseStmt *>
279
283
lookupFallthroughSourceAndDest (SourceFile *sourceFile, SourceLoc loc);
280
284
285
+ static void lookupEnclosingMacroScope (
286
+ SourceFile *sourceFile, SourceLoc loc,
287
+ llvm::function_ref<bool (ASTScope::PotentialMacro)> consume);
288
+
281
289
// / Scopes that cannot bind variables may set this to true to create more
282
290
// / compact scope tree in the debug info.
283
291
virtual bool ignoreInDebugInfo () const { return false ; }
@@ -840,24 +848,20 @@ class DefaultArgumentInitializerScope final : public ASTScopeImpl {
840
848
bool ignoreInDebugInfo () const override { return true ; }
841
849
};
842
850
843
- // / Consider:
844
- // / @_propertyWrapper
845
- // / struct WrapperWithInitialValue {
846
- // / }
847
- // / struct HasWrapper {
848
- // / @WrapperWithInitialValue var y = 17
849
- // / }
850
- // / Lookup has to be able to find the use of WrapperWithInitialValue, that's
851
- // / what this scope is for. Because the source positions are screwy.
852
-
853
- class AttachedPropertyWrapperScope final : public ASTScopeImpl {
851
+ // / The scope for custom attributes and their arguments, such as for
852
+ // / attached property wrappers and for attached macros.
853
+ // /
854
+ // / Source locations for the attribute name and its arguments are in the
855
+ // / custom attribute, so lookup is invoked from within the attribute
856
+ // / itself.
857
+ class CustomAttributeScope final : public ASTScopeImpl {
854
858
public:
855
859
CustomAttr *attr;
856
- VarDecl *decl;
860
+ Decl *decl;
857
861
858
- AttachedPropertyWrapperScope (CustomAttr *attr, VarDecl *decl)
862
+ CustomAttributeScope (CustomAttr *attr,Decl *decl)
859
863
: attr(attr), decl(decl) {}
860
- virtual ~AttachedPropertyWrapperScope () {}
864
+ virtual ~CustomAttributeScope () {}
861
865
862
866
protected:
863
867
ASTScopeImpl *expandSpecifically (ScopeCreator &) override ;
@@ -871,7 +875,8 @@ class AttachedPropertyWrapperScope final : public ASTScopeImpl {
871
875
NullablePtr<DeclAttribute> getDeclAttributeIfAny () const override {
872
876
return attr;
873
877
}
874
- bool ignoreInDebugInfo () const override { return true ; }
878
+ bool ignoreInDebugInfo () const override { return true ; }
879
+
875
880
private:
876
881
void expandAScopeThatDoesNotCreateANewInsertionPoint (ScopeCreator &);
877
882
};
@@ -1134,9 +1139,9 @@ class SpecializeAttributeScope final : public ASTScopeImpl {
1134
1139
class DifferentiableAttributeScope final : public ASTScopeImpl {
1135
1140
public:
1136
1141
DifferentiableAttr *const differentiableAttr;
1137
- ValueDecl *const attributedDeclaration;
1142
+ Decl *const attributedDeclaration;
1138
1143
1139
- DifferentiableAttributeScope (DifferentiableAttr *diffAttr, ValueDecl *decl)
1144
+ DifferentiableAttributeScope (DifferentiableAttr *diffAttr, Decl *decl)
1140
1145
: differentiableAttr(diffAttr), attributedDeclaration(decl) {}
1141
1146
virtual ~DifferentiableAttributeScope () {}
1142
1147
@@ -1270,6 +1275,10 @@ class MacroExpansionDeclScope final : public ASTScopeImpl {
1270
1275
SourceRange
1271
1276
getSourceRangeOfThisASTNode (bool omitAssertions = false ) const override ;
1272
1277
1278
+ NullablePtr<MacroExpansionDecl> getFreestandingMacro () const override {
1279
+ return decl;
1280
+ }
1281
+
1273
1282
protected:
1274
1283
void printSpecifics (llvm::raw_ostream &out) const override ;
1275
1284
0 commit comments