Skip to content

Add instanceof.unsafe lint option#1209

Merged
wmdietl merged 33 commits intoeisop:masterfrom
aosen-xiong:fix-instanceof
Jun 15, 2025
Merged

Add instanceof.unsafe lint option#1209
wmdietl merged 33 commits intoeisop:masterfrom
aosen-xiong:fix-instanceof

Conversation

@aosen-xiong
Copy link
Copy Markdown
Collaborator

No description provided.

@aosen-xiong aosen-xiong marked this pull request as ready for review May 4, 2025 19:23
@aosen-xiong aosen-xiong requested a review from wmdietl May 4, 2025 19:23
Copy link
Copy Markdown
Member

@wmdietl wmdietl left a comment

Choose a reason for hiding this comment

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

Is there a relation to #1049?

@@ -0,0 +1,3 @@
InstanceofLintOptionEnabled.java:12:15: warning: [instanceof.pattern.unsafe] instanceof pattern binding '@Tainted Object' to '@Untainted String s' cannot be statically verified.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Where is a reference to this file? It should be the expected output for one of the compile tasks.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Fixed.

* @test
* @summary Test case for instanceof lint option: -Alint=instanceof
* @requires jdk.version >= 17
* @compile -processor org.checkerframework.checker.tainting.TaintingChecker InstanceofLintOptionEnabled.java -Alint=instanceof
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Wouldn't it make more sense for this compilation to produce the output in LintOptionDisabled? If the lint is on, it should produce the additional warnings.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

I realized I was doing it wrong. Now it should be okay.

Comment thread framework/src/main/java/org/checkerframework/common/basetype/BaseTypeVisitor.java Outdated
@wmdietl wmdietl assigned aosen-xiong and unassigned wmdietl May 19, 2025
@aosen-xiong
Copy link
Copy Markdown
Collaborator Author

Is there a relation to #1049?

No, I think these two PRs for different purposes.

@aosen-xiong aosen-xiong assigned wmdietl and unassigned aosen-xiong May 20, 2025
@aosen-xiong aosen-xiong requested a review from wmdietl May 20, 2025 03:27
@wmdietl wmdietl assigned aosen-xiong and unassigned wmdietl May 31, 2025
Copy link
Copy Markdown
Member

@wmdietl wmdietl left a comment

Choose a reason for hiding this comment

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

Thanks for the updates!

Comment thread docs/manual/warnings.tex
Comment thread framework/src/main/java/org/checkerframework/common/basetype/BaseTypeVisitor.java Outdated
@aosen-xiong aosen-xiong requested a review from wmdietl June 5, 2025 02:10
@aosen-xiong aosen-xiong assigned wmdietl and unassigned aosen-xiong Jun 5, 2025
Copy link
Copy Markdown
Member

@wmdietl wmdietl left a comment

Choose a reason for hiding this comment

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

One point to think about.

private final boolean checkEnclosingExpr;

/** True if "-Alint=cast:redundant" was passed on the command line. */
private final boolean lintCastRedundantEnabled;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I'm wondering whether we should call all these fields "xxxDisabled" and not have the negation in every check. Does it make the code easier to read either way?
If you do this, be careful in adapting the Javadocs.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Lint option sounds optional check to me, and we enable unsafe lint options by default (maybe it could be an error?).

I think it would be nicer to keep these as xxxEnabled.

@wmdietl wmdietl assigned aosen-xiong and unassigned wmdietl Jun 6, 2025
@wmdietl
Copy link
Copy Markdown
Member

wmdietl commented Jun 6, 2025

Also, please add a changelog entry.

@aosen-xiong aosen-xiong requested a review from wmdietl June 13, 2025 03:56
@aosen-xiong aosen-xiong assigned wmdietl and unassigned aosen-xiong Jun 13, 2025
Copy link
Copy Markdown
Member

@wmdietl wmdietl left a comment

Choose a reason for hiding this comment

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

Thanks, just a small tweak.

Comment thread docs/CHANGELOG.md Outdated
Comment thread docs/CHANGELOG.md Outdated
@wmdietl wmdietl changed the title Add instanceof as a lint option Add instanceof.unsafe lint option Jun 15, 2025
@wmdietl wmdietl enabled auto-merge (squash) June 15, 2025 17:12
@wmdietl wmdietl merged commit 1567ae8 into eisop:master Jun 15, 2025
42 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants