-
Notifications
You must be signed in to change notification settings - Fork 419
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add lint rule for UnusedTaskIntent (#26005)
Adds a new lint rule UnusedTaskIntent. This is similar to UnusedFormal and UnusedLoopIndex and warns for unused task intents like the following ```chapel var a = 1; begin with (ref a) { } ``` Since `a` is not used, it can be safely removed. Note that the following is not warning for, since task private variables could have side effects ```chapel begin with (var x = ...) { } ``` This PR also fixes an issue where `@chplcheck.ignore` was being added to AstNode's that did not support attributes for the `IncorrectIndentation` rule Future work: Improve the naming of sub-location method names like `block_header` and `header_location` [Reviewed by @DanilaFe]
- Loading branch information
Showing
12 changed files
with
207 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
module UnusedTaskIntent { | ||
var A: [1..10] int = 10; | ||
var B: int = 1; | ||
|
||
forall 1..10 with (var x: int) {} | ||
|
||
forall 1..10 with (var x = B) {} | ||
|
||
foreach 1..10 | ||
with (ref A, | ||
in B) {} | ||
|
||
coforall 1..10 with (+ reduce A) {} | ||
|
||
begin with (ref A, | ||
+ reduce B) {} | ||
|
||
begin with | ||
(ref A) {} | ||
|
||
cobegin with | ||
(const in A) { } | ||
|
||
[1..10 with(ref A)] { ; } | ||
|
||
[1..10 with (in A, | ||
const in B)] { ; } | ||
|
||
@chplcheck.ignore("UnusedTaskIntent") | ||
[1..10 with(ref A)] { ; } | ||
|
||
forall 1..10 with (const A) { } | ||
forall 1..10 with (const x: int) { } | ||
forall 1..10 with (const x = 1) { } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
UnusedTaskIntent.chpl:21: warning: cobegin has no effect if it contains fewer than 2 statements | ||
UnusedTaskIntent.chpl:10: node violates rule UnusedTaskIntent | ||
UnusedTaskIntent.chpl:11: node violates rule UnusedTaskIntent | ||
UnusedTaskIntent.chpl:13: node violates rule UnusedTaskIntent | ||
UnusedTaskIntent.chpl:15: node violates rule UnusedTaskIntent | ||
UnusedTaskIntent.chpl:16: node violates rule UnusedTaskIntent | ||
UnusedTaskIntent.chpl:19: node violates rule UnusedTaskIntent | ||
UnusedTaskIntent.chpl:22: node violates rule UnusedTaskIntent | ||
UnusedTaskIntent.chpl:24: node violates rule UnusedTaskIntent | ||
UnusedTaskIntent.chpl:26: node violates rule UnusedTaskIntent | ||
UnusedTaskIntent.chpl:27: node violates rule UnusedTaskIntent | ||
UnusedTaskIntent.chpl:32: node violates rule UnusedTaskIntent | ||
[Success matching fixit for UnusedTaskIntent] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
module UnusedTaskIntent { | ||
var A: [1..10] int = 10; | ||
var B: int = 1; | ||
|
||
forall 1..10 with (var x: int) {} | ||
|
||
forall 1..10 with (var x = B) {} | ||
|
||
@chplcheck.ignore("UnusedTaskIntent") | ||
foreach 1..10 | ||
with (ref A, | ||
in B) {} | ||
|
||
coforall 1..10 {} | ||
|
||
begin with (ref A, | ||
+ reduce B) {} | ||
|
||
begin {} | ||
|
||
cobegin { } | ||
|
||
[1..10] { ; } | ||
|
||
@chplcheck.ignore("UnusedTaskIntent") | ||
[1..10 with (in A, | ||
const in B)] { ; } | ||
|
||
@chplcheck.ignore("UnusedTaskIntent") | ||
[1..10 with(ref A)] { ; } | ||
|
||
forall 1..10 { } | ||
forall 1..10 with (const x: int) { } | ||
forall 1..10 with (const x = 1) { } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.