Java: Data flow for java.util.Objects

This commit is contained in:
Arthur Baars
2020-07-03 20:27:50 +02:00
parent c629f6b13a
commit 9cf6601d02
5 changed files with 57 additions and 0 deletions

View File

@@ -400,6 +400,19 @@ predicate simpleLocalFlowStep(Node node1, Node node2) {
node2.asExpr().(ChooseExpr).getAResultExpr() = node1.asExpr()
or
node2.asExpr().(AssignExpr).getSource() = node1.asExpr()
or
exists(MethodAccess ma, Method m |
ma = node2.asExpr() and
m = ma.getMethod() and
m.getDeclaringType().hasQualifiedName("java.util", "Objects") and
(
m.hasName(["requireNonNull", "requireNonNullElseGet"]) and node1.asExpr() = ma.getArgument(0)
or
m.hasName("requireNonNullElse") and node1.asExpr() = ma.getAnArgument()
or
m.hasName("toString") and node1.asExpr() = ma.getArgument(1)
)
)
}
/**