Skip to content
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

Expose some cfg/builder APIs to allow inserting jumps and throws. #5156

Merged
merged 2 commits into from
Jun 10, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -482,6 +482,15 @@ public PhaseOneResult process(CompilationUnitTree root, UnderlyingAST underlying
*/
public void handleArtificialTree(Tree tree) {}

/**
* Allow subclasses to access the processing environment and its associated utilities.
*
* @return the ProcessingEnvironment associated with this object
*/
protected ProcessingEnvironment getProcessingEnvironment() {
return env;
}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We technically don't need this one, but it's useful and avoids us keeping a duplicate ProcessingEnvironment field in the subclass.


/**
* Returns the current path for the tree currently being scanned.
*
Expand Down Expand Up @@ -3980,7 +3989,7 @@ public Node visitOther(Tree tree, Void p) {
* @param clazz a class
* @return the TypeMirror for the class
*/
private TypeMirror getTypeMirror(Class<?> clazz) {
protected TypeMirror getTypeMirror(Class<?> clazz) {
return TypesUtils.typeFromClass(clazz, types, elements);
}

Expand All @@ -3994,7 +4003,7 @@ private TypeMirror getTypeMirror(Class<?> clazz) {
* @param clazz a class, which must have a canonical name
* @return the TypeMirror for the class, or {@code null} if the type is not present
*/
private @Nullable TypeMirror maybeGetTypeMirror(Class<?> clazz) {
protected @Nullable TypeMirror maybeGetTypeMirror(Class<?> clazz) {
String name = clazz.getCanonicalName();
assert name != null : clazz + " does not have a canonical name";
TypeElement element = elements.getTypeElement(name);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
* is required to be of boolean type.
*/
@SuppressWarnings("nullness") // TODO
class ConditionalJump extends ExtendedNode {
public class ConditionalJump extends ExtendedNode {

/** The true successor label. */
protected final Label trueSucc;
Expand Down Expand Up @@ -86,7 +86,7 @@ public void setFalseFlowRule(FlowRule rule) {
* Produce a string representation.
*
* @return a string representation
* @see org.checkerframework.dataflow.cfg.builder.CFGBuilder.PhaseOneResult#nodeToString
* @see org.checkerframework.dataflow.cfg.builder.PhaseOneResult#nodeToString
*/
@Override
public String toString() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,18 @@
* An extended node can be one of several things (depending on its {@code type}):
*
* <ul>
* <li><em>NODE</em>: {@link CFGBuilder.NodeHolder}. An extended node of this type is just a
* wrapper for a {@link Node} (that cannot throw exceptions).
* <li><em>EXCEPTION_NODE</em>: {@link CFGBuilder.NodeWithExceptionsHolder}. A wrapper for a
* {@link Node} which can throw exceptions. It contains a label for every possible exception
* type the node might throw.
* <li><em>UNCONDITIONAL_JUMP</em>: {@link CFGBuilder.UnconditionalJump}. An unconditional jump to
* a label.
* <li><em>TWO_TARGET_CONDITIONAL_JUMP</em>: {@link CFGBuilder.ConditionalJump}. A conditional
* jump with two targets for both the 'then' and 'else' branch.
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

References (@link) in these docs were outdated, which tooling complained about as soon as the class was made public. Otherwise this is unchanged.

* <li><em>NODE</em>: {@link NodeHolder}. An extended node of this type is just a wrapper for a
* {@link Node} (that cannot throw exceptions).
* <li><em>EXCEPTION_NODE</em>: {@link NodeWithExceptionsHolder}. A wrapper for a {@link Node}
* which can throw exceptions. It contains a label for every possible exception type the node
* might throw.
* <li><em>UNCONDITIONAL_JUMP</em>: {@link UnconditionalJump}. An unconditional jump to a label.
* <li><em>TWO_TARGET_CONDITIONAL_JUMP</em>: {@link ConditionalJump}. A conditional jump with two
* targets for both the 'then' and 'else' branch.
* </ul>
*/
@SuppressWarnings("nullness") // TODO
abstract class ExtendedNode {
public abstract class ExtendedNode {

/** The basic block this extended node belongs to (as determined in phase two). */
protected BlockImpl block;
Expand Down