Skip to content

Commit

Permalink
Expose some cfg/builder APIs to allow inserting jumps and throws. (ty…
Browse files Browse the repository at this point in the history
  • Loading branch information
lazaroclapp authored and wmdietl committed Jul 13, 2022
1 parent c09d261 commit f9c3cbd
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -492,6 +492,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;
}

/**
* Returns the current path for the tree currently being scanned.
*
Expand Down Expand Up @@ -4058,7 +4067,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 @@ -4072,7 +4081,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
/*package-private*/ 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.
* <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
/*package-private*/ 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
2 changes: 1 addition & 1 deletion docs/manual/contributors.tex
Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,11 @@
Kartikeya Goswami,
Kivanc Muslu,
Konstantin Weitz,
Lazaro Clapp,
Leo Liu,
Liam Miller-Cushon,
Lian Sun,
Luqman Aden,
L\'azaro Clapp,
Mahmood Ali,
Manu Sridharan,
Mark Roberts,
Expand Down

0 comments on commit f9c3cbd

Please sign in to comment.