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

First Phase of RLC inference #5870

Merged
merged 149 commits into from
Oct 26, 2023
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
Show all changes
149 commits
Select commit Hold shift + click to select a range
695416d
first phase
Nargeshdb May 15, 2023
ab26997
update comments
Nargeshdb May 15, 2023
ad74e0b
Undo wildcard imports
mernst May 15, 2023
1f16be4
Merge ../checker-framework-branch-master into inference-phase-one
mernst May 16, 2023
833231f
Put shorter clauses first
mernst May 16, 2023
22af6f6
address comments
Nargeshdb May 22, 2023
2d23295
address feedbacks
Nargeshdb May 24, 2023
155ded6
address feedbacks
Nargeshdb May 24, 2023
ef2ac88
update shouldPerformWholeProgramInference in MustCallTransfer
Nargeshdb May 24, 2023
6a28bfc
Merge branch 'master' into inference-phase-one
Nargeshdb May 24, 2023
617a7c7
add comments
Nargeshdb May 25, 2023
8f27be1
Merge remote-tracking branch 'origin' into inference-phase-one
Nargeshdb May 25, 2023
e455aa1
Merge branch 'master' into inference-phase-one
Nargeshdb Jun 13, 2023
3a483f5
update
Nargeshdb Jun 16, 2023
2e87329
update comments
Nargeshdb Jun 22, 2023
aae7e30
address Martin's feedback
Nargeshdb Jun 26, 2023
c48227b
address comments
Nargeshdb Jun 29, 2023
d83eb35
address Martin's comments
Nargeshdb Jun 29, 2023
98279da
update java doc for checkMethodInvocation
Nargeshdb Aug 4, 2023
37cd3e2
update
Nargeshdb Aug 4, 2023
9e2cc1a
update java doc for checkMethodInvocation
Nargeshdb Aug 4, 2023
a958009
add a test case
Nargeshdb Apr 28, 2023
f795b0e
update
Nargeshdb Aug 4, 2023
7e678fb
update
Nargeshdb Aug 4, 2023
d32645e
fix deprecation warning
Nargeshdb Aug 8, 2023
ee90781
remove a MustAliasWithDifferentMCSet.java
Nargeshdb Aug 8, 2023
3bd8772
update
Nargeshdb Aug 8, 2023
74cfa33
cleanup
Nargeshdb Aug 11, 2023
6b9f194
handle arguments passed in varArgs position
Nargeshdb Aug 18, 2023
6b787ca
address Martin's feedback
Nargeshdb Aug 18, 2023
7d85c7f
address Martin's feedback
Nargeshdb Aug 18, 2023
3b7d062
update EnsuresCalledMethodsTest
Nargeshdb Aug 19, 2023
421cdbc
remove changes in MCCA
Nargeshdb Aug 22, 2023
bd1372e
pass -AenableWPIForRLC flag to wpi-many test and update manual
Nargeshdb Aug 23, 2023
4993d96
update
Nargeshdb Aug 23, 2023
1849e13
update
Nargeshdb Aug 23, 2023
7dd793a
address Martin's feedback
Nargeshdb Aug 25, 2023
6e518fb
Merge ../checker-framework-branch-master into inference-phase-one
mernst Aug 28, 2023
e5da11a
Documentation tweaks
mernst Aug 28, 2023
6b00ac4
Tweaks
mernst Aug 28, 2023
111c0aa
Documentation improvements
mernst Aug 28, 2023
15097e2
Code review changes
mernst Aug 29, 2023
c968553
Merge ../checker-framework-branch-master into inference-phase-one
mernst Aug 30, 2023
f53afbc
Code review changes
mernst Aug 30, 2023
5216a62
Comment improvements
mernst Aug 30, 2023
885d952
Renaming
mernst Aug 30, 2023
4e9a811
Renaming and comment improvements
mernst Aug 30, 2023
8af4608
Comments
mernst Aug 30, 2023
da6f840
Documentation edits
mernst Aug 30, 2023
6f0ad6e
Code improvements
mernst Aug 30, 2023
16e9687
address Mike's comments (part 1)
Nargeshdb Sep 6, 2023
51cfa50
address Mike's comments
Nargeshdb Sep 7, 2023
3be91db
improve documentation
Nargeshdb Sep 8, 2023
e32a557
Merge ../checker-framework-branch-master into inference-phase-one
mernst Sep 8, 2023
6005941
address Mike's comments
Nargeshdb Sep 14, 2023
ae36399
merge
Nargeshdb Sep 14, 2023
dc24008
Merge ../checker-framework-branch-master into inference-phase-one
mernst Sep 14, 2023
29e941e
Merge ../checker-framework-branch-master into inference-phase-one
mernst Sep 14, 2023
996cce1
Renamings
mernst Sep 14, 2023
e0cb22b
Remove unneeded "Logic"
mernst Sep 15, 2023
998c87a
Merge branch 'inference-phase-one' of github.com:nargeshdb/checker-fr…
mernst Sep 15, 2023
447e1ed
Tweaks
mernst Sep 15, 2023
f4eb105
Tweaks
mernst Sep 15, 2023
a1eb2c1
Renaming, comments
mernst Sep 15, 2023
39c9961
Add import statement
mernst Sep 15, 2023
d4157d0
Merge /scratch/mernst/clones/types/checker-framework-branch-master in…
mernst Sep 16, 2023
4911657
improve documentation and names
Nargeshdb Sep 19, 2023
1ab7ff1
improve comments
Nargeshdb Sep 20, 2023
612ef9d
Merge remote-tracking branch 'origin' into inference-phase-one
Nargeshdb Sep 20, 2023
1299f7a
add more detail about -AenableWpiForRlc
Nargeshdb Sep 20, 2023
372cac3
Merge branch 'master' into inference-phase-one
msridhar Sep 21, 2023
48f5a01
remove static import
msridhar Sep 21, 2023
09fb026
Merge branch 'master' into inference-phase-one
msridhar Sep 23, 2023
2c70b8d
Merge ../checker-framework-branch-master into inference-phase-one
mernst Sep 24, 2023
a6e8546
change AenableWPIForRLC to AenableWpiForRlc
Nargeshdb Sep 25, 2023
12ee23a
revert changes in addOwningToParamsIfDisposedAtAssignment
Nargeshdb Sep 25, 2023
3761941
Compatibility with Java 8; add toString methods
mernst Sep 25, 2023
d7ed3dd
Add diagnostic output
mernst Sep 25, 2023
c6a94f1
Merge branch 'inference-phase-one' of github.com:nargeshdb/checker-fr…
mernst Sep 25, 2023
17b7853
add changes back
Nargeshdb Sep 25, 2023
bc0b737
Merge branch 'master' into inference-phase-one
Nargeshdb Sep 25, 2023
8354a14
improve perf
Nargeshdb Sep 25, 2023
36ddd8e
Merge branch 'master' into inference-phase-one
Nargeshdb Sep 26, 2023
c1c3d7b
make all indexes 1-based
Nargeshdb Sep 26, 2023
f70a11e
fix
Nargeshdb Sep 26, 2023
94bb05f
Merge branch 'inference-phase-one' of github.com:nargeshdb/checker-fr…
mernst Sep 28, 2023
a64af88
Merge ../checker-framework-branch-master into inference-phase-one
mernst Sep 28, 2023
9ffc0a1
Merge branch 'master' into inference-phase-one
msridhar Oct 2, 2023
7110866
fix compile error
msridhar Oct 2, 2023
206643d
Code review changes
mernst Oct 2, 2023
f6e82cc
Merge branch 'inference-phase-one' of github.com:nargeshdb/checker-fr…
mernst Oct 2, 2023
4cda0ed
Brevity
mernst Oct 2, 2023
0bc4ed8
Lazily create HashSet
mernst Oct 2, 2023
5a57c79
Comment tweaks and a renaming
mernst Oct 2, 2023
145bb3e
Reduce duplication in explanation of `-AenableWpiForRlc`
mernst Oct 2, 2023
4caab8a
Comments
mernst Oct 2, 2023
8b6896f
Improve comments
mernst Oct 2, 2023
79e2911
address all feedbacks
Nargeshdb Oct 3, 2023
041fc0a
merge
Nargeshdb Oct 3, 2023
2f6d925
Merge ../checker-framework-branch-master into inference-phase-one
mernst Oct 4, 2023
bbcc548
Merge branch 'inference-phase-one' of github.com:nargeshdb/checker-fr…
mernst Oct 4, 2023
d21d164
update names and docs
Nargeshdb Oct 5, 2023
fa72f43
fix
Nargeshdb Oct 5, 2023
1793e3f
Merge branch 'master' into inference-phase-one
Nargeshdb Oct 5, 2023
ca50189
Update checker/src/main/java/org/checkerframework/checker/resourcelea…
Nargeshdb Oct 7, 2023
61283f1
Update checker/src/main/java/org/checkerframework/checker/resourcelea…
Nargeshdb Oct 7, 2023
cdcb572
Update checker/src/main/java/org/checkerframework/checker/resourcelea…
Nargeshdb Oct 7, 2023
a18c47f
Update checker/src/main/java/org/checkerframework/checker/resourcelea…
Nargeshdb Oct 7, 2023
5a4c853
Update checker/src/main/java/org/checkerframework/checker/resourcelea…
Nargeshdb Oct 7, 2023
39bc3aa
Update checker/src/main/java/org/checkerframework/checker/resourcelea…
Nargeshdb Oct 7, 2023
0155950
update names of methods
Nargeshdb Oct 7, 2023
3f116a1
update comments
msridhar Oct 8, 2023
271d455
address some comments
Nargeshdb Oct 8, 2023
beac03b
Merge branch 'inference-phase-one-2' into inference-phase-one
Nargeshdb Oct 8, 2023
a4ffad6
update
Nargeshdb Oct 9, 2023
a8128d2
address Manu's feedback
Nargeshdb Oct 10, 2023
233d349
Update checker/src/main/java/org/checkerframework/checker/resourcelea…
Nargeshdb Oct 10, 2023
79a6d92
Update checker/src/main/java/org/checkerframework/checker/resourcelea…
Nargeshdb Oct 10, 2023
b473dbc
reformat
Nargeshdb Oct 10, 2023
6c254aa
remove disposedField.clear
Nargeshdb Oct 10, 2023
6be4874
Update checker/src/main/java/org/checkerframework/checker/resourcelea…
Nargeshdb Oct 11, 2023
06900ac
Update checker/src/main/java/org/checkerframework/checker/resourcelea…
Nargeshdb Oct 11, 2023
518a598
Update checker/src/main/java/org/checkerframework/checker/resourcelea…
Nargeshdb Oct 11, 2023
74bf6d2
Update checker/src/main/java/org/checkerframework/checker/resourcelea…
Nargeshdb Oct 11, 2023
ffc2472
imptove comments
Nargeshdb Oct 11, 2023
217e105
update method name
Nargeshdb Oct 11, 2023
3ee6e82
check ownership transfer on object creation node
Nargeshdb Oct 12, 2023
3c7d78a
Merge branch 'master' into inference-phase-one
mernst Oct 12, 2023
13e16da
update
Nargeshdb Oct 12, 2023
8ab8a64
update
Nargeshdb Oct 12, 2023
3acf330
cleanup
Nargeshdb Oct 13, 2023
80323c3
Merge branch 'master' into inference-phase-one
msridhar Oct 13, 2023
f3d465c
Merge branch 'master' into inference-phase-one
msridhar Oct 13, 2023
75f2e84
minor tweaks
msridhar Oct 13, 2023
f089e3c
add annotations after the while loop
Nargeshdb Oct 13, 2023
3a7cfda
Merge branch 'master' into inference-phase-one
msridhar Oct 15, 2023
2b2cca2
improve documentation
Nargeshdb Oct 17, 2023
eb9f86f
update
Nargeshdb Oct 17, 2023
c03056b
improve comments
Nargeshdb Oct 17, 2023
8bfa69c
merge
Nargeshdb Oct 19, 2023
b33b705
add a test
Nargeshdb Oct 23, 2023
3b39cbb
update comments
Nargeshdb Oct 24, 2023
f80dcde
Merge branch 'master' into inference-phase-one
Nargeshdb Oct 24, 2023
bf851fc
remove the test
Nargeshdb Oct 24, 2023
3011552
add arg
Nargeshdb Oct 24, 2023
29cfb1f
make debug method static
kelloggm Oct 25, 2023
4b64bf4
Merge branch 'master' into inference-phase-one
Nargeshdb Oct 25, 2023
73fd978
Merge branch 'master' into inference-phase-one
Nargeshdb Oct 26, 2023
f7f02bf
Merge branch 'master' into inference-phase-one
kelloggm Oct 26, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package org.checkerframework.checker.calledmethods;

import com.sun.source.tree.Tree;
import java.util.Arrays;
import java.util.Collections;
import java.util.LinkedHashMap;
Expand Down Expand Up @@ -61,6 +62,16 @@ public CalledMethodsTransfer(final CalledMethodsAnalysis analysis) {
((CalledMethodsAnnotatedTypeFactory) atypeFactory).calledMethodsValueElement;
}

@Override
protected boolean shouldPerformWholeProgramInference(Tree tree) {
return false;
Nargeshdb marked this conversation as resolved.
Show resolved Hide resolved
}

@Override
protected boolean shouldPerformWholeProgramInference(Tree expressionTree, Tree lhsTree) {
return false;
}

@Override
public TransferResult<CFValue, CFStore> visitMethodInvocation(
final MethodInvocationNode node, final TransferInput<CFValue, CFStore> input) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,9 @@ protected void constructorFromUsePreSubstitution(
*/
private void changeNonOwningParameterTypesToTop(
ExecutableElement declaration, AnnotatedExecutableType type) {
if (getWholeProgramInference() != null) {
kelloggm marked this conversation as resolved.
Show resolved Hide resolved
Nargeshdb marked this conversation as resolved.
Show resolved Hide resolved
return;
}
List<AnnotatedTypeMirror> parameterTypes = type.getParameterTypes();
for (int i = 0; i < parameterTypes.size(); i++) {
Element paramDecl = declaration.getParameters().get(i);
Expand Down Expand Up @@ -411,7 +414,13 @@ public MustCallTreeAnnotator(MustCallAnnotatedTypeFactory mustCallAnnotatedTypeF
@Override
public Void visitIdentifier(IdentifierTree tree, AnnotatedTypeMirror type) {
Element elt = TreeUtils.elementFromUse(tree);
if (elt.getKind() == ElementKind.PARAMETER
if (getWholeProgramInference() != null
&& elt.getKind() == ElementKind.PARAMETER
&& getDeclAnnotation(elt, MustCallAlias.class) != null) {
type.replaceAnnotation(BOTTOM);
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe add a comment explaining this change? Also this does not check isWpiEnabledForRLC(), is that intentional?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This part should be in the next PR when we have inference for @MustCallAlias annotation. So I removed it from this PR and I will add a comment to explain it.

this does not check isWpiEnabledForRLC()

I guess I need to include this check as well to make the wpi mechanism unchanged by using the -AenableWpiForRlc flag.

Copy link
Contributor

Choose a reason for hiding this comment

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

It doesn't appear that the comment that you promised here was actually added to the code.

if (getWholeProgramInference() == null
&& elt.getKind() == ElementKind.PARAMETER
&& (noLightweightOwnership || getDeclAnnotation(elt, Owning.class) == null)) {
type.replaceAnnotation(BOTTOM);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import com.sun.source.tree.ClassTree;
import com.sun.source.tree.ExpressionTree;
import com.sun.source.tree.IdentifierTree;
import com.sun.source.tree.Tree;
import com.sun.source.tree.VariableTree;
import com.sun.source.util.TreePath;
import java.util.List;
Expand Down Expand Up @@ -174,6 +175,16 @@ private void lubWithStoreValue(CFStore store, JavaExpression expr, AnnotationMir
store.insertValue(expr, newValue);
}

@Override
protected boolean shouldPerformWholeProgramInference(Tree tree) {
return false;
}

@Override
protected boolean shouldPerformWholeProgramInference(Tree expressionTree, Tree lhsTree) {
return false;
}

@Override
public TransferResult<CFValue, CFStore> visitObjectCreation(
ObjectCreationNode node, TransferInput<CFValue, CFStore> input) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import org.checkerframework.checker.mustcall.qual.MustCall;
import org.checkerframework.checker.mustcall.qual.MustCallAlias;
import org.checkerframework.checker.mustcall.qual.NotOwning;
import org.checkerframework.checker.mustcall.qual.PolyMustCall;
import org.checkerframework.common.basetype.BaseTypeChecker;
import org.checkerframework.common.basetype.BaseTypeVisitor;
import org.checkerframework.framework.type.AnnotatedTypeMirror;
Expand Down Expand Up @@ -189,9 +190,22 @@ public boolean isValidUse(
// Note that isValidUse does not need to consider component types, on which it should be
// called separately.
Element elt = TreeUtils.elementFromTree(tree);
if (elt != null
&& AnnotationUtils.containsSameByClass(elt.getAnnotationMirrors(), MustCallAlias.class)) {
return true;
if (elt != null) {
// Need to check the type mirror for ajava-derived annotations and the element itself
// for human-written annotations from the source code. Getting to the ajava file directly
// at this point is impossible, so we approximate "the ajava file has an @MustCallAlias
// annotation" with "there is an @PolyMustCall annotation on the use type, but not in the
// source code". This only works because none of our inference techniques infer @PolyMustCall,
// so if @PolyMustCall is present but wasn't in the source, it must have been derived from
// an @MustCallAlias annotation (which we do infer).
boolean ajavaFileHasMustCallAlias =
useType.hasAnnotation(PolyMustCall.class)
&& !AnnotationUtils.containsSameByClass(
elt.getAnnotationMirrors(), PolyMustCall.class);
if (ajavaFileHasMustCallAlias
|| AnnotationUtils.containsSameByClass(elt.getAnnotationMirrors(), MustCallAlias.class)) {
return true;
}
}
return super.isValidUse(declarationType, useType, tree);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1021,7 +1021,7 @@ private void updateObligationsForOwningReturn(
* @param node a node
* @return the temporary for node, or node if no temporary exists
*/
private Node getTempVarOrNode(final Node node) {
protected Node getTempVarOrNode(final Node node) {
Node temp = typeFactory.getTempVarForNode(node);
if (temp != null) {
return temp;
Expand Down Expand Up @@ -1150,7 +1150,7 @@ private boolean hasAtMostOneOwningField(TypeElement element) {
* @param node the node
* @return true if must-call type of node only contains close
*/
private boolean isMustCallClose(Node node) {
protected boolean isMustCallClose(Node node) {
MustCallAnnotatedTypeFactory mcAtf =
typeFactory.getTypeFactoryOfSubchecker(MustCallChecker.class);
AnnotatedTypeMirror mustCallAnnotatedType = mcAtf.getAnnotatedType(node.getTree());
Expand All @@ -1164,7 +1164,8 @@ private boolean isMustCallClose(Node node) {
* @param obligations the set of Obligations
* @param var a variable
*/
private void removeObligationsContainingVar(Set<Obligation> obligations, LocalVariableNode var) {
protected void removeObligationsContainingVar(
Set<Obligation> obligations, LocalVariableNode var) {
Obligation obligationForVar = getObligationForVar(obligations, var);
while (obligationForVar != null) {
obligations.remove(obligationForVar);
Expand Down Expand Up @@ -1585,7 +1586,7 @@ private Node removeCastsAndGetTmpVarIfPresent(Node node) {
* @param node a MethodInvocation or ObjectCreation node
* @return the arguments, in order
*/
private List<Node> getArgumentsOfInvocation(Node node) {
protected List<Node> getArgumentsOfInvocation(Node node) {
if (node instanceof MethodInvocationNode) {
MethodInvocationNode invocationNode = (MethodInvocationNode) node;
return invocationNode.getArguments();
Expand All @@ -1604,7 +1605,7 @@ private List<Node> getArgumentsOfInvocation(Node node) {
* @return a list of the declarations of the formal parameters of the method or constructor being
* invoked
*/
private List<? extends VariableElement> getParametersOfInvocation(Node node) {
protected List<? extends VariableElement> getParametersOfInvocation(Node node) {
ExecutableElement executableElement;
if (node instanceof MethodInvocationNode) {
MethodInvocationNode invocationNode = (MethodInvocationNode) node;
Expand Down Expand Up @@ -1987,7 +1988,7 @@ private static boolean varTrackedInObligations(
* @return the Obligation in {@code obligations} whose resource alias set contains {@code node},
* or {@code null} if there is no such Obligation
*/
private static @Nullable Obligation getObligationForVar(
protected static @Nullable Obligation getObligationForVar(
Nargeshdb marked this conversation as resolved.
Show resolved Hide resolved
Set<Obligation> obligations, LocalVariableNode node) {
for (Obligation obligation : obligations) {
if (obligation.canBeSatisfiedThrough(node)) {
Expand Down Expand Up @@ -2225,7 +2226,7 @@ private static void propagate(
* consists of BlockWithObligations objects, each representing the need to handle the set of
* dataflow facts reaching the block during analysis.
*/
private static class BlockWithObligations {
static class BlockWithObligations {
Nargeshdb marked this conversation as resolved.
Show resolved Hide resolved

/** The block. */
public final Block block;
Expand Down
Loading