File tree Expand file tree Collapse file tree 1 file changed +7
-0
lines changed
lib/SILOptimizer/Mandatory Expand file tree Collapse file tree 1 file changed +7
-0
lines changed Original file line number Diff line number Diff line change 16
16
17
17
#include " swift/AST/DiagnosticsSIL.h"
18
18
#include " swift/AST/Stmt.h"
19
+ #include " swift/AST/Decl.h"
19
20
#include " swift/Basic/Defer.h"
20
21
#include " swift/SIL/BasicBlockBits.h"
21
22
#include " swift/SIL/BasicBlockDatastructures.h"
@@ -226,6 +227,12 @@ void DiagnosticEmitter::emitMissingConsumeInDiscardingContext(
226
227
return true ;
227
228
228
229
case SILLocation::RegularKind: {
230
+ Decl *decl = loc.getAsASTNode <Decl>();
231
+ if (decl && isa<AbstractFunctionDecl>(decl)) {
232
+ // Having the function itself as a location results in a location at the
233
+ // first line of the function. Find another location.
234
+ return false ;
235
+ }
229
236
Stmt *stmt = loc.getAsASTNode <Stmt>();
230
237
if (!stmt)
231
238
return true ; // For non-statements, assume it is exiting the func.
You can’t perform that action at this time.
0 commit comments