8000 Java: Replace MethodAccess, LValue, RValue with more intuitive names. Introduce NewClassExpr. by smowton · Pull Request #14575 · github/codeql · GitHub
[go: up one dir, main page]

Skip to content

Java: Replace MethodAccess, LValue, RValue with more intuitive names. Introduce NewClassExpr. #14575

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

Merged
merged 16 commits into from
Oct 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ class StringConcat extends AddExpr {
StringConcat() { getType() instanceof TypeString }
}

from MethodAccess ma
from MethodCall ma
Copy link
Contributor

Choose a reason for hiding this comment

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

Should MethodCall variables named ma be renamed to mc?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ideally yes, but it's a harder transformation to script!

where
ma.getMethod().getName().matches("sparql%Query") and
ma.getArgument(0) instanceof StringConcat
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import java
import semmle.code.java.dataflow.DataFlow::DataFlow

from MethodAccess ma, StringConcat stringConcat
from MethodCall ma, StringConcat stringConcat
where
ma.getMethod().getName().matches("sparql%Query") and
localFlow(exprNode(stringConcat), exprNode(ma.getArgument(0)))
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import java

from Method m, MethodAccess ma
from Method m, MethodCall ma
where
m.getName().matches("sparql%Query") and
ma.getMethod() = m
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import java

from Method m, MethodAccess ma
from Method m, MethodCall ma
where
m.getName().matches("sparql%Query") and
ma.getMethod() = m and
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import java

predicate isStringConcat(AddExpr ae) { ae.getType() instanceof TypeString }

from Method m, MethodAccess ma
from Method m, MethodCall ma
where
m.getName().matches("sparql%Query") and
ma.getMethod() = m and
Expand Down
2 changes: 1 addition & 1 deletion java/ql/consistency-queries/calls.ql
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import java

from MethodAccess ma
from MethodCall ma
// Generally Kotlin calls will always use an explicit qualifier, except for calls
// to the synthetic instance initializer <obinit>, which use an implicit `this`.
where
Expand Down
2 changes: 1 addition & 1 deletion java/ql/consistency-queries/cfgDeadEnds.ql
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ predicate shouldBeDeadEnd(ControlFlowNode n) {
or
n instanceof WildcardTypeAccess // TODO
or
n instanceof MethodAccess // TODO
n instanceof MethodCall // TODO
or
n instanceof Method
or
Expand Down
4 changes: 2 additions & 2 deletions java/ql/consistency-queries/children.ql
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,11 @@ predicate gapInChildren(Element e, int i) {
// For statements may or may not declare a new variable (child 0), or
// have a condition (child 1).
not (e instanceof ForStmt and i = [0, 1]) and
// TODO: Clarify situation with Kotlin and MethodAccess.
// TODO: Clarify situation with Kotlin and MethodCall.
// -1 can be skipped (type arguments from -2 down, no qualifier at -1,
// then arguments from 0).
// Can we also skip arguments, e.g. due to defaults for parameters?
not (e instanceof MethodAccess and e.getFile().isKotlinSourceFile()) and
not (e instanceof MethodCall and e.getFile().isKotlinSourceFile()) and
// Kotlin-extracted annotations can have missing children where a default
// value should be, because kotlinc doesn't load annotation defaults and we
// want to leave a space for another extractor to fill in the default if it
Expand Down
2 changes: 1 addition & 1 deletion java/ql/examples/snippets/method_call.ql
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

import java

from MethodAccess call, Method method
from MethodCall call, Method method
where
call.getMethod() = method and
method.hasName("methodName") and
Expand Down
4 changes: 2 additions & 2 deletions java/ql/examples/snippets/mutualrecursion.ql
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import java

from Method m, Method n
where
exists(MethodAccess ma | ma.getCaller() = m and ma.getCallee() = n) and
exists(MethodAccess ma | ma.getCaller() = n and ma.getCallee() = m) and
exists(MethodCall ma | ma.getCaller() = m and ma.getCallee() = n) and
exists(MethodCall ma | ma.getCaller() = n and ma.getCallee() = m) and
m != n
select m, n
2 changes: 1 addition & 1 deletion java/ql/examples/snippets/null_argument.ql
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

import java

from MethodAccess call, Method add
from MethodCall call, Method add
where
call.getMethod().overrides*(add) and
add.hasName("add") and
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ User.java:
# 3| 0: [TypeAccess] Ann2
# 3| 5: [BlockStmt] { ... }
# 4| 0: [ExprStmt] <Expr>;
# 4| 0: [MethodAccess] x(...)
# 4| 0: [MethodCall] x(...)
# 4| -1: [VarAccess] a1
# 4| 1: [ExprStmt] <Expr>;
# 4| 0: [MethodAccess] z(...)
# 4| 0: [MethodCall] z(...)
# 4| -1: [VarAccess] a2
# 4| 2: [ExprStmt] <Expr>;
# 4| 0: [ClassInstanceExpr] new Annotated(...)
Expand Down Expand Up @@ -49,7 +49,7 @@ ktUser.kt:
# 8| 3: [ExprStmt] <Expr>;
# 8| 0: [ImplicitCoercionToUnitExpr] <implicit coercion to unit>
# 8| 0: [TypeAccess] Unit
# 8| 1: [MethodAccess] isJavaLetter(...)
# 8| 1: [MethodCall] isJavaLetter(...)
# 8| -1: [TypeAccess] Character
# 8| 0: [CharacterLiteral] a
test.kt:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ private import semmle.code.java.dataflow.ExternalFlow

module Config implements DataFlow::ConfigSig {
predicate isSource(DataFlow::Node n) {
n.asExpr().(MethodAccess).getCallee().getName() = "source"
n.asExpr().(MethodCall).getCallee().getName() = "source"
or
sourceNode(n, "kotlinMadFlowTest")
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import java

from MethodAccess ma
from MethodCall ma
select ma, ma.getCallee()
Loading
0