@@ -236,22 +236,16 @@ class ASTScopeImpl : public ASTAllocated<ASTScopeImpl> {
236236
237237 virtual NullablePtr<AbstractClosureExpr> getClosureIfClosureScope () const ;
238238 virtual NullablePtr<const BraceStmtScope> getAsBraceStmtScope () const ;
239- virtual ASTContext &getASTContext () const ;
240- virtual NullablePtr<Decl> getDeclIfAny () const { return nullptr ; };
241- virtual NullablePtr<Stmt> getStmtIfAny () const { return nullptr ; };
242- virtual NullablePtr<Expr> getExprIfAny () const { return nullptr ; };
243- virtual NullablePtr<DeclAttribute> getDeclAttributeIfAny () const {
244- return nullptr ;
245- }
246-
247- virtual NullablePtr<MacroExpansionDecl> getFreestandingMacro () const {
248- return nullptr ;
249- }
239+ ASTContext &getASTContext () const ;
240+ NullablePtr<Decl> getDeclIfAny () const ;
241+ NullablePtr<Stmt> getStmtIfAny () const ;
242+ NullablePtr<Expr> getExprIfAny () const ;
243+ NullablePtr<DeclAttribute> getDeclAttributeIfAny () const ;
250244
251245#pragma mark - debugging and printing
252246
253247public:
254- virtual const SourceFile *getSourceFile () const ;
248+ const SourceFile *getSourceFile () const ;
255249 StringRef getClassName () const ;
256250
257251 // / Print out this scope for debugging/reporting purposes.
@@ -453,10 +447,8 @@ class ASTSourceFileScope final : public ASTScopeImpl {
453447
454448 void expandFunctionBody (AbstractFunctionDecl *AFD);
455449
456- const SourceFile *getSourceFile () const override ;
457450 NullablePtr<const void > addressForPrinting () const override { return SF; }
458451
459- ASTContext &getASTContext () const override ;
460452 bool ignoreInDebugInfo () const override { return true ; }
461453
462454protected:
@@ -592,7 +584,6 @@ class GenericTypeOrExtensionScope : public ASTScopeImpl {
592584 virtual void expandBody (ScopeCreator &);
593585
594586 virtual Decl *getDecl () const = 0;
595- NullablePtr<Decl> getDeclIfAny () const override { return getDecl (); }
596587
597588private:
598589 AnnotatedInsertionPoint
@@ -825,7 +816,6 @@ class AbstractFunctionDeclScope final : public ASTScopeImpl {
825816 void printSpecifics (llvm::raw_ostream &out) const override ;
826817
827818public:
828- virtual NullablePtr<Decl> getDeclIfAny () const override { return decl; }
829819 Decl *getDecl () const { return decl; }
830820
831821protected:
@@ -889,7 +879,6 @@ class FunctionBodyScope : public ASTScopeImpl {
889879public:
890880 SourceRange
891881 getSourceRangeOfThisASTNode (bool omitAssertions = false ) const override ;
892- virtual NullablePtr<Decl> getDeclIfAny () const override { return decl; }
893882 Decl *getDecl () const { return decl; }
894883 bool ignoreInDebugInfo () const override { return true ; }
895884
@@ -921,7 +910,6 @@ class DefaultArgumentInitializerScope final : public ASTScopeImpl {
921910 void expandAScopeThatDoesNotCreateANewInsertionPoint (ScopeCreator &);
922911 SourceRange
923912 getSourceRangeOfThisASTNode (bool omitAssertions = false ) const override ;
924- virtual NullablePtr<Decl> getDeclIfAny () const override { return decl; }
925913 Decl *getDecl () const { return decl; }
926914 bool ignoreInDebugInfo () const override { return true ; }
927915
@@ -953,9 +941,6 @@ class CustomAttributeScope final : public ASTScopeImpl {
953941 getSourceRangeOfThisASTNode (bool omitAssertions = false ) const override ;
954942 NullablePtr<const void > addressForPrinting () const override { return decl; }
955943
956- NullablePtr<DeclAttribute> getDeclAttributeIfAny () const override {
957- return attr;
958- }
959944 bool ignoreInDebugInfo () const override { return true ; }
960945
961946private:
@@ -1003,7 +988,6 @@ class AbstractPatternEntryScope : public ASTScopeImpl {
1003988 void printSpecifics (llvm::raw_ostream &out) const override ;
1004989
1005990public:
1006- NullablePtr<Decl> getDeclIfAny () const override { return decl; }
1007991 Decl *getDecl () const { return decl; }
1008992};
1009993
@@ -1151,7 +1135,6 @@ class CaptureListScope final : public ASTScopeImpl {
11511135public:
11521136 SourceRange
11531137 getSourceRangeOfThisASTNode (bool omitAssertions = false ) const override ;
1154- NullablePtr<Expr> getExprIfAny () const override { return expr; }
11551138 Expr *getExpr () const { return expr; }
11561139 bool lookupLocalsOrMembers (DeclConsumer) const override ;
11571140
@@ -1177,7 +1160,6 @@ class ClosureParametersScope final : public ASTScopeImpl {
11771160 }
11781161 std::pair<CatchNode, const BraceStmtScope *> getCatchNodeBody () const override ;
11791162
1180- NullablePtr<Expr> getExprIfAny () const override { return closureExpr; }
11811163 Expr *getExpr () const { return closureExpr; }
11821164 bool ignoreInDebugInfo () const override { return true ; }
11831165
@@ -1215,7 +1197,6 @@ class TopLevelCodeScope final : public ASTScopeImpl {
12151197public:
12161198 SourceRange
12171199 getSourceRangeOfThisASTNode (bool omitAssertions = false ) const override ;
1218- virtual NullablePtr<Decl> getDeclIfAny () const override { return decl; }
12191200 Decl *getDecl () const { return decl; }
12201201
12211202 static bool classof (const ASTScopeImpl *scope) {
@@ -1242,7 +1223,7 @@ class SpecializeAttributeScope final : public ASTScopeImpl {
12421223 return specializeAttr;
12431224 }
12441225
1245- NullablePtr< DeclAttribute> getDeclAttributeIfAny () const override {
1226+ DeclAttribute * getDeclAttr () const {
12461227 return specializeAttr;
12471228 }
12481229
@@ -1276,7 +1257,7 @@ class DifferentiableAttributeScope final : public ASTScopeImpl {
12761257 return differentiableAttr;
12771258 }
12781259
1279- NullablePtr< DeclAttribute> getDeclAttributeIfAny () const override {
1260+ DeclAttribute * getDeclAttr () const {
12801261 return differentiableAttr;
12811262 }
12821263
@@ -1313,7 +1294,6 @@ class SubscriptDeclScope final : public ASTScopeImpl {
13131294 void printSpecifics (llvm::raw_ostream &out) const override ;
13141295
13151296public:
1316- virtual NullablePtr<Decl> getDeclIfAny () const override { return decl; }
13171297 Decl *getDecl () const { return decl; }
13181298
13191299protected:
@@ -1336,7 +1316,6 @@ class EnumElementScope : public ASTScopeImpl {
13361316 getSourceRangeOfThisASTNode (bool omitAssertions = false ) const override ;
13371317
13381318 ASTScopeImpl *expandSpecifically (ScopeCreator &) override ;
1339- NullablePtr<Decl> getDeclIfAny () const override { return decl; }
13401319 Decl *getDecl () const { return decl; }
13411320
13421321private:
@@ -1369,7 +1348,6 @@ class MacroDeclScope final : public ASTScopeImpl {
13691348 void printSpecifics (llvm::raw_ostream &out) const override ;
13701349
13711350public:
1372- virtual NullablePtr<Decl> getDeclIfAny () const override { return decl; }
13731351 Decl *getDecl () const { return decl; }
13741352
13751353protected:
@@ -1424,15 +1402,10 @@ class MacroExpansionDeclScope final : public ASTScopeImpl {
14241402 SourceRange
14251403 getSourceRangeOfThisASTNode (bool omitAssertions = false ) const override ;
14261404
1427- NullablePtr<MacroExpansionDecl> getFreestandingMacro () const override {
1428- return decl;
1429- }
1430-
14311405protected:
14321406 void printSpecifics (llvm::raw_ostream &out) const override ;
14331407
14341408public:
1435- virtual NullablePtr<Decl> getDeclIfAny () const override { return decl; }
14361409 Decl *getDecl () const { return decl; }
14371410
14381411 static bool classof (const ASTScopeImpl *scope) {
@@ -1448,7 +1421,6 @@ class AbstractStmtScope : public ASTScopeImpl {
14481421 SourceRange
14491422 getSourceRangeOfThisASTNode (bool omitAssertions = false ) const override ;
14501423 virtual Stmt *getStmt () const = 0;
1451- NullablePtr<Stmt> getStmtIfAny () const override { return getStmt (); }
14521424
14531425protected:
14541426 bool isLabeledStmtLookupTerminator () const override ;
0 commit comments