Skip to content

Commit

Permalink
Minor improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
mernst committed May 20, 2024
1 parent 7f85b7f commit f66823e
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -431,8 +431,8 @@ protected void initFields(ControlFlowGraph cfg) {
}

/**
* Updates the value of node {@code node} to the value of the {@code transferResult}. Returns true
* if the node's value changed, or a store was updated.
* Updates the value of node {@code node} in {@link #nodeValues} to the value of the {@code
* transferResult}. Returns true if the node's value changed, or a store was updated.
*
* @param node the node to update
* @param transferResult the transfer result being updated
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,7 @@ public Map<VariableElement, V> getFinalLocalValues() {
* available
*/
public @Nullable V getValue(Tree t) {
// This is a set because one Tree might correspond to multiple Nodes.
Set<Node> nodes = treeLookup.get(t);

if (nodes == null) {
Expand All @@ -221,10 +222,12 @@ public Map<VariableElement, V> getFinalLocalValues() {
V merged = null;
for (Node aNode : nodes) {
V a = getValue(aNode);
if (merged == null) {
merged = a;
} else if (a != null) {
merged = merged.leastUpperBound(a);
if (a != null) {
if (merged == null) {
merged = a;
} else {
merged = merged.leastUpperBound(a);
}
}
}
return merged;
Expand Down
4 changes: 2 additions & 2 deletions docs/manual/creating-a-checker.tex
Original file line number Diff line number Diff line change
Expand Up @@ -1645,8 +1645,8 @@
relevant to your run-time check or run-time operation.
Leave the body of the overriding method empty for now.

For example, the Regex Checker refines the type of a run-time test method
call. A method call is represented by a
For example, the Regex Checker refines the type based on a call to the
\<RegexUtil.isRegex> method. A method call is represented by a
\refclass{dataflow/cfg/node}{MethodInvocationNode}. Therefore,
\refclass{checker/regex}{RegexTransfer} overrides the
\code{visitMethodInvocation} method:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2361,12 +2361,6 @@ public Void visitAnnotation(AnnotationTree tree, Void p) {
return null;
}

/**
* If the computation of the type of the ConditionalExpressionTree in
* org.checkerframework.framework.type.TypeFromTree.TypeFromExpression.visitConditionalExpression(ConditionalExpressionTree,
* AnnotatedTypeFactory) is correct, the following checks are redundant. However, let's add
* another failsafe guard and do the checks.
*/
@Override
public Void visitConditionalExpression(ConditionalExpressionTree tree, Void p) {
if (TreeUtils.isPolyExpression(tree)) {
Expand All @@ -2377,6 +2371,10 @@ public Void visitConditionalExpression(ConditionalExpressionTree tree, Void p) {
return super.visitConditionalExpression(tree, p);
}

// If the computation of the type of the ConditionalExpressionTree in
// org.checkerframework.framework.type.TypeFromTree.TypeFromExpression.visitConditionalExpression(ConditionalExpressionTree,
// AnnotatedTypeFactory) is correct, the following checks are redundant. However, let's add
// another failsafe guard and do the checks.
AnnotatedTypeMirror cond = atypeFactory.getAnnotatedType(tree);
this.commonAssignmentCheck(cond, tree.getTrueExpression(), "conditional");
this.commonAssignmentCheck(cond, tree.getFalseExpression(), "conditional");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1691,8 +1691,9 @@ protected AnnotatedTypeMirror mergeAnnotationFileAnnosIntoType(
* Creates an AnnotatedTypeMirror for an ExpressionTree. The AnnotatedTypeMirror contains explicit
* annotations written on the expression and for some expressions, annotations from
* sub-expressions that could have been explicitly written, defaulted, refined, or otherwise
* computed. (Expression whose type include annotations from sub-expressions are: ArrayAccessTree,
* ConditionalExpressionTree, IdentifierTree, MemberSelectTree, and MethodInvocationTree.)
* computed. (Expressions whose type include annotations from sub-expressions are:
* ArrayAccessTree, ConditionalExpressionTree, IdentifierTree, MemberSelectTree, and
* MethodInvocationTree.)
*
* <p>For example, the AnnotatedTypeMirror returned for an array access expression is the fully
* annotated type of the array component of the array being accessed.
Expand Down

0 comments on commit f66823e

Please sign in to comment.