C#: Get rid of the isOwnInstanceAccess based on ReturnStmt.

This commit is contained in:
Michael Nebel
2022-03-09 14:59:13 +01:00
parent 34a91f1aac
commit cd03af3be4
4 changed files with 12 additions and 8 deletions

View File

@@ -9,9 +9,9 @@ import CaptureSummaryModelsSpecific
* Gets the summary model of `api`, if it follows the `fluent` programming pattern (returns `this`).
*/
string captureQualifierFlow(TargetApi api) {
exists(ReturnStmt rtn |
rtn.getEnclosingCallable() = api and
isOwnInstanceAccess(rtn)
exists(ReturnNodeExt ret |
api = returnNodeEnclosingCallable(ret) and
isOwnInstanceAccessNode(ret)
) and
result = asValueModel(api, qualifierString(), "ReturnValue")
}

View File

@@ -10,7 +10,10 @@ import semmle.code.java.dataflow.internal.DataFlowPrivate
import semmle.code.java.dataflow.InstanceAccess
import ModelGeneratorUtils
predicate isOwnInstanceAccess(ReturnStmt rtn) { rtn.getResult().(ThisAccess).isOwnInstanceAccess() }
pragma[inline]
Callable returnNodeEnclosingCallable(ReturnNodeExt ret) {
result = getNodeEnclosingCallable(ret).asCallable()
}
predicate isOwnInstanceAccessNode(ReturnNode node) {
node.asExpr().(ThisAccess).isOwnInstanceAccess()