-
Notifications
You must be signed in to change notification settings - Fork 29
Add ignoreDeadCode option
#633
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from 2 commits
7102456
bd2e5e7
58f4773
1d1c348
2540cd3
02c69a8
a3e4013
73de62f
30638eb
6392013
decd355
f7b1bb5
a93748b
1576672
3571c39
fa183ec
f678255
2117ffc
aff7485
1508ca6
bf1652c
85d3a9a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -150,6 +150,9 @@ | |
| // org.checkerframework.framework.source.SourceChecker.report | ||
| "warns", | ||
|
|
||
| // Make checker ignore the expression in dead branch | ||
|
aosen-xiong marked this conversation as resolved.
Outdated
|
||
| "notCheckDeadCode", | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. How about
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. By convention, for each option we list the main point where that option is used. Please add such a reference.
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Thanks, already addressed the comment in 1d1c348
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
addressed this comment in 58f4773 |
||
|
|
||
| /// | ||
| /// More sound (strict checking): enable errors that are disabled by default | ||
| /// | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -458,7 +458,9 @@ public void setRoot(@Nullable CompilationUnitTree root) { | |
|
|
||
| super.setRoot(root); | ||
| this.scannedClasses.clear(); | ||
| // this.reachableNodes.clear(); | ||
| if (checker.hasOption("notCheckDeadCode")) { | ||
| this.reachableNodes.clear(); | ||
| } | ||
| this.flowResult = null; | ||
| this.regularExitStores.clear(); | ||
| this.exceptionalExitStores.clear(); | ||
|
|
@@ -1078,6 +1080,7 @@ public IPair<JavaExpression, String> getExpressionAndOffsetFromJavaExpressionStr | |
| * @param exprTree an expression tree | ||
| * @return true if the {@code exprTree} is unreachable | ||
| * | ||
| */ | ||
| public boolean isUnreachable(ExpressionTree exprTree) { | ||
| if (!everUseFlow) { | ||
| return false; | ||
|
|
@@ -1096,7 +1099,6 @@ public boolean isUnreachable(ExpressionTree exprTree) { | |
| // None of the corresponding nodes is reachable, so this tree is dead. | ||
| return true; | ||
| } | ||
| */ | ||
|
|
||
| /** | ||
| * Track the state of org.checkerframework.dataflow analysis scanning for each class tree in the | ||
|
|
@@ -1120,7 +1122,7 @@ protected enum ScanState { | |
| * same name but represent different uses of the variable. So instead of storing Nodes, it | ||
| * stores the result of {@code Node#getTree}. | ||
| */ | ||
| // private final Set<Tree> reachableNodes = new HashSet<>(); | ||
| private final Set<Tree> reachableNodes = new HashSet<>(); | ||
|
|
||
| /** | ||
| * The result of the flow analysis. Invariant: | ||
|
|
@@ -1598,15 +1600,15 @@ protected void analyze( | |
| boolean isStatic, | ||
| @Nullable Store capturedStore) { | ||
| ControlFlowGraph cfg = CFCFGBuilder.build(root, ast, checker, this, processingEnv); | ||
| /* | ||
| cfg.getAllNodes(this::isIgnoredExceptionType) | ||
| .forEach( | ||
| node -> { | ||
| if (node.getTree() != null) { | ||
| reachableNodes.add(node.getTree()); | ||
| } | ||
| }); | ||
| */ | ||
| if (checker.hasOption("notCheckDeadCode")) { | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Here, and probably in the
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
addressed this comment in 2540cd3 |
||
| cfg.getAllNodes(this::isIgnoredExceptionType) | ||
| .forEach( | ||
| node -> { | ||
| if (node.getTree() != null) { | ||
| reachableNodes.add(node.getTree()); | ||
| } | ||
| }); | ||
| } | ||
| if (isInitializationCode) { | ||
| Store initStore = !isStatic ? initializationStore : initializationStaticStore; | ||
| if (initStore != null) { | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.