-
Notifications
You must be signed in to change notification settings - Fork 11
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
refine exception type of try-catch edges #134
base: master
Are you sure you want to change the base?
Conversation
Previous PR #131. |
I rollback the code to the origin/master because in PR #131 , there is marker text-related modification that makes the PR not single-purposed, and then push to the remote repository so that the PR is closed automatically. |
…into cfg-try-catch-edges-refinement
@xingweitian Can you have a look at this PR? |
We were looking at the case of an expression When /cc @Nargeshdb |
…ypeMirror,Label>>
…into cfg-try-catch-edges-refinement
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the PR! Here are some of my initial thinking:
|
||
if (caught instanceof DeclaredType) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's the difference between caught instanceof DeclaredType
and caught.getKind() == TypeKind.DECLARED
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A union-type exception, like IOException | NullPointerException
is DeclaredType
. As a result, a catch block parameterized with a union-type exception will also fall into the if-branch.
if (canApply) { | ||
labels.add(pair.second); | ||
} else { | ||
assert false : "caught type must be a union or a declared type"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It might be better to write throw new BugInCF("Caught type must be a union or a declared type.");
here.
// Add Throwable to account for unchecked exceptions | ||
TypeElement throwableElement = elements.getTypeElement("java.lang.Throwable"); | ||
thrownSet.add(throwableElement.asType()); | ||
// |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove this line.
* Given a type of thrown exception, add the set of possible control flow successor {@link | ||
* Label}s to the argument set. Return true if the exception is known to be caught by one of | ||
* those labels and false if it may propagate still further. | ||
* Given a type of thrown exception, add to the argument set all possible pairs of the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks like this is redundant to https://github.com/opprop/checker-framework/pull/134/files#diff-852baab2528be0b3ea885d77fe6cdd8bR604. Can we remove it?
@@ -401,18 +401,21 @@ public String toString() { | |||
protected final Node node; | |||
|
|||
/** | |||
* Map from exception type to labels of successors that may be reached as a result of that | |||
* exception. | |||
* Set of all possible pairs of the refined exception type {@link TypeMirror} and the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pairs of the refined exception types and the corresponding targets' labels?
Maybe remove {@link Label}
? or change label
to {@link Label}s
.
|
||
/** | ||
* Construct a NodeWithExceptionsHolder for the given node and exceptions. | ||
* | ||
* @param node the node to hold | ||
* @param exceptions the exceptions to hold | ||
* @param exceptions set of all possible pairs of the refined exception type {@link |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same as above. Please have a look at all the appears.
* <p>Return true if the exception is known to be caught by one of those labels and false if | ||
* it may propagate still further. | ||
* | ||
* @param thrown the type of the exception that is declared to be thrown from a method |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove .
at the end of the line. @param
and @return
should not write .
at the end of the line. Please change all the usages in this PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we also need to update this? Is it still accurate enough? https://github.com/opprop/checker-framework/pull/134/files#diff-852baab2528be0b3ea885d77fe6cdd8bL579
dataflow/src/main/java/org/checkerframework/dataflow/cfg/CFGBuilder.java
Show resolved
Hide resolved
* invocation, waiting to be refined. | ||
* @param causeLabelPairs the set of all possible pairs of the refined exception type {@link | ||
* TypeMirror} and the corresponding target's label {@link Label} that may be reached as | ||
* a result of {@code thrown}. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A result of the current exception node?
…ixed `getTypeOfExtendsImplements` (opprop#134)
This PR refines the type of exception for try-catch edges, which is shown as the label of each exceptional edge in CFG. The refinement is divided into two cases: (i) If thrown type is a subtype of caught type, then the edge is labeled the type of thrown type; (ii) If thrown type is a supertype of caught type, then the edge is labeled the type of caught type.