Skip to content

Commit 98f68cb

Browse files
committed
Dataflow: Sync.
1 parent 490df20 commit 98f68cb

28 files changed

+292
-168
lines changed

cpp/ql/lib/semmle/code/cpp/dataflow/internal/DataFlowImpl.qll

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2139,7 +2139,8 @@ private predicate expensiveLen2unfolding(TypedContent tc, Configuration config)
21392139
) and
21402140
accessPathApproxCostLimits(apLimit, tupleLimit) and
21412141
apLimit < tails and
2142-
tupleLimit < (tails - 1) * nodes
2142+
tupleLimit < (tails - 1) * nodes and
2143+
not tc.forceHighPrecision()
21432144
)
21442145
}
21452146

@@ -2973,12 +2974,15 @@ private AccessPathApprox getATail(AccessPathApprox apa, Configuration config) {
29732974
* expected to be expensive. Holds with `unfold = true` otherwise.
29742975
*/
29752976
private predicate evalUnfold(AccessPathApprox apa, boolean unfold, Configuration config) {
2976-
exists(int aps, int nodes, int apLimit, int tupleLimit |
2977-
aps = countPotentialAps(apa, config) and
2978-
nodes = countNodesUsingAccessPath(apa, config) and
2979-
accessPathCostLimits(apLimit, tupleLimit) and
2980-
if apLimit < aps and tupleLimit < (aps - 1) * nodes then unfold = false else unfold = true
2981-
)
2977+
if apa.getHead().forceHighPrecision()
2978+
then unfold = true
2979+
else
2980+
exists(int aps, int nodes, int apLimit, int tupleLimit |
2981+
aps = countPotentialAps(apa, config) and
2982+
nodes = countNodesUsingAccessPath(apa, config) and
2983+
accessPathCostLimits(apLimit, tupleLimit) and
2984+
if apLimit < aps and tupleLimit < (aps - 1) * nodes then unfold = false else unfold = true
2985+
)
29822986
}
29832987

29842988
/**

cpp/ql/lib/semmle/code/cpp/dataflow/internal/DataFlowImpl2.qll

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2139,7 +2139,8 @@ private predicate expensiveLen2unfolding(TypedContent tc, Configuration config)
21392139
) and
21402140
accessPathApproxCostLimits(apLimit, tupleLimit) and
21412141
apLimit < tails and
2142-
tupleLimit < (tails - 1) * nodes
2142+
tupleLimit < (tails - 1) * nodes and
2143+
not tc.forceHighPrecision()
21432144
)
21442145
}
21452146

@@ -2973,12 +2974,15 @@ private AccessPathApprox getATail(AccessPathApprox apa, Configuration config) {
29732974
* expected to be expensive. Holds with `unfold = true` otherwise.
29742975
*/
29752976
private predicate evalUnfold(AccessPathApprox apa, boolean unfold, Configuration config) {
2976-
exists(int aps, int nodes, int apLimit, int tupleLimit |
2977-
aps = countPotentialAps(apa, config) and
2978-
nodes = countNodesUsingAccessPath(apa, config) and
2979-
accessPathCostLimits(apLimit, tupleLimit) and
2980-
if apLimit < aps and tupleLimit < (aps - 1) * nodes then unfold = false else unfold = true
2981-
)
2977+
if apa.getHead().forceHighPrecision()
2978+
then unfold = true
2979+
else
2980+
exists(int aps, int nodes, int apLimit, int tupleLimit |
2981+
aps = countPotentialAps(apa, config) and
2982+
nodes = countNodesUsingAccessPath(apa, config) and
2983+
accessPathCostLimits(apLimit, tupleLimit) and
2984+
if apLimit < aps and tupleLimit < (aps - 1) * nodes then unfold = false else unfold = true
2985+
)
29822986
}
29832987

29842988
/**

cpp/ql/lib/semmle/code/cpp/dataflow/internal/DataFlowImpl3.qll

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2139,7 +2139,8 @@ private predicate expensiveLen2unfolding(TypedContent tc, Configuration config)
21392139
) and
21402140
accessPathApproxCostLimits(apLimit, tupleLimit) and
21412141
apLimit < tails and
2142-
tupleLimit < (tails - 1) * nodes
2142+
tupleLimit < (tails - 1) * nodes and
2143+
not tc.forceHighPrecision()
21432144
)
21442145
}
21452146

@@ -2973,12 +2974,15 @@ private AccessPathApprox getATail(AccessPathApprox apa, Configuration config) {
29732974
* expected to be expensive. Holds with `unfold = true` otherwise.
29742975
*/
29752976
private predicate evalUnfold(AccessPathApprox apa, boolean unfold, Configuration config) {
2976-
exists(int aps, int nodes, int apLimit, int tupleLimit |
2977-
aps = countPotentialAps(apa, config) and
2978-
nodes = countNodesUsingAccessPath(apa, config) and
2979-
accessPathCostLimits(apLimit, tupleLimit) and
2980-
if apLimit < aps and tupleLimit < (aps - 1) * nodes then unfold = false else unfold = true
2981-
)
2977+
if apa.getHead().forceHighPrecision()
2978+
then unfold = true
2979+
else
2980+
exists(int aps, int nodes, int apLimit, int tupleLimit |
2981+
aps = countPotentialAps(apa, config) and
2982+
nodes = countNodesUsingAccessPath(apa, config) and
2983+
accessPathCostLimits(apLimit, tupleLimit) and
2984+
if apLimit < aps and tupleLimit < (aps - 1) * nodes then unfold = false else unfold = true
2985+
)
29822986
}
29832987

29842988
/**

cpp/ql/lib/semmle/code/cpp/dataflow/internal/DataFlowImpl4.qll

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2139,7 +2139,8 @@ private predicate expensiveLen2unfolding(TypedContent tc, Configuration config)
21392139
) and
21402140
accessPathApproxCostLimits(apLimit, tupleLimit) and
21412141
apLimit < tails and
2142-
tupleLimit < (tails - 1) * nodes
2142+
tupleLimit < (tails - 1) * nodes and
2143+
not tc.forceHighPrecision()
21432144
)
21442145
}
21452146

@@ -2973,12 +2974,15 @@ private AccessPathApprox getATail(AccessPathApprox apa, Configuration config) {
29732974
* expected to be expensive. Holds with `unfold = true` otherwise.
29742975
*/
29752976
private predicate evalUnfold(AccessPathApprox apa, boolean unfold, Configuration config) {
2976-
exists(int aps, int nodes, int apLimit, int tupleLimit |
2977-
aps = countPotentialAps(apa, config) and
2978-
nodes = countNodesUsingAccessPath(apa, config) and
2979-
accessPathCostLimits(apLimit, tupleLimit) and
2980-
if apLimit < aps and tupleLimit < (aps - 1) * nodes then unfold = false else unfold = true
2981-
)
2977+
if apa.getHead().forceHighPrecision()
2978+
then unfold = true
2979+
else
2980+
exists(int aps, int nodes, int apLimit, int tupleLimit |
2981+
aps = countPotentialAps(apa, config) and
2982+
nodes = countNodesUsingAccessPath(apa, config) and
2983+
accessPathCostLimits(apLimit, tupleLimit) and
2984+
if apLimit < aps and tupleLimit < (aps - 1) * nodes then unfold = false else unfold = true
2985+
)
29822986
}
29832987

29842988
/**

cpp/ql/lib/semmle/code/cpp/dataflow/internal/DataFlowImplCommon.qll

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1236,6 +1236,13 @@ class TypedContent extends MkTypedContent {
12361236

12371237
/** Gets a textual representation of this content. */
12381238
string toString() { result = c.toString() }
1239+
1240+
/**
1241+
* Holds if accesspaths with this `TypedContent` at their head always should
1242+
* be tracked at high precision. This disables adaptive accesspath precision
1243+
* for such accesspaths.
1244+
*/
1245+
predicate forceHighPrecision() { forceHighPrecision(c) }
12391246
}
12401247

12411248
/**

cpp/ql/lib/semmle/code/cpp/dataflow/internal/DataFlowImplLocal.qll

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2139,7 +2139,8 @@ private predicate expensiveLen2unfolding(TypedContent tc, Configuration config)
21392139
) and
21402140
accessPathApproxCostLimits(apLimit, tupleLimit) and
21412141
apLimit < tails and
2142-
tupleLimit < (tails - 1) * nodes
2142+
tupleLimit < (tails - 1) * nodes and
2143+
not tc.forceHighPrecision()
21432144
)
21442145
}
21452146

@@ -2973,12 +2974,15 @@ private AccessPathApprox getATail(AccessPathApprox apa, Configuration config) {
29732974
* expected to be expensive. Holds with `unfold = true` otherwise.
29742975
*/
29752976
private predicate evalUnfold(AccessPathApprox apa, boolean unfold, Configuration config) {
2976-
exists(int aps, int nodes, int apLimit, int tupleLimit |
2977-
aps = countPotentialAps(apa, config) and
2978-
nodes = countNodesUsingAccessPath(apa, config) and
2979-
accessPathCostLimits(apLimit, tupleLimit) and
2980-
if apLimit < aps and tupleLimit < (aps - 1) * nodes then unfold = false else unfold = true
2981-
)
2977+
if apa.getHead().forceHighPrecision()
2978+
then unfold = true
2979+
else
2980+
exists(int aps, int nodes, int apLimit, int tupleLimit |
2981+
aps = countPotentialAps(apa, config) and
2982+
nodes = countNodesUsingAccessPath(apa, config) and
2983+
accessPathCostLimits(apLimit, tupleLimit) and
2984+
if apLimit < aps and tupleLimit < (aps - 1) * nodes then unfold = false else unfold = true
2985+
)
29822986
}
29832987

29842988
/**

cpp/ql/lib/semmle/code/cpp/ir/dataflow/internal/DataFlowImpl.qll

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2139,7 +2139,8 @@ private predicate expensiveLen2unfolding(TypedContent tc, Configuration config)
21392139
) and
21402140
accessPathApproxCostLimits(apLimit, tupleLimit) and
21412141
apLimit < tails and
2142-
tupleLimit < (tails - 1) * nodes
2142+
tupleLimit < (tails - 1) * nodes and
2143+
not tc.forceHighPrecision()
21432144
)
21442145
}
21452146

@@ -2973,12 +2974,15 @@ private AccessPathApprox getATail(AccessPathApprox apa, Configuration config) {
29732974
* expected to be expensive. Holds with `unfold = true` otherwise.
29742975
*/
29752976
private predicate evalUnfold(AccessPathApprox apa, boolean unfold, Configuration config) {
2976-
exists(int aps, int nodes, int apLimit, int tupleLimit |
2977-
aps = countPotentialAps(apa, config) and
2978-
nodes = countNodesUsingAccessPath(apa, config) and
2979-
accessPathCostLimits(apLimit, tupleLimit) and
2980-
if apLimit < aps and tupleLimit < (aps - 1) * nodes then unfold = false else unfold = true
2981-
)
2977+
if apa.getHead().forceHighPrecision()
2978+
then unfold = true
2979+
else
2980+
exists(int aps, int nodes, int apLimit, int tupleLimit |
2981+
aps = countPotentialAps(apa, config) and
2982+
nodes = countNodesUsingAccessPath(apa, config) and
2983+
accessPathCostLimits(apLimit, tupleLimit) and
2984+
if apLimit < aps and tupleLimit < (aps - 1) * nodes then unfold = false else unfold = true
2985+
)
29822986
}
29832987

29842988
/**

cpp/ql/lib/semmle/code/cpp/ir/dataflow/internal/DataFlowImpl2.qll

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2139,7 +2139,8 @@ private predicate expensiveLen2unfolding(TypedContent tc, Configuration config)
21392139
) and
21402140
accessPathApproxCostLimits(apLimit, tupleLimit) and
21412141
apLimit < tails and
2142-
tupleLimit < (tails - 1) * nodes
2142+
tupleLimit < (tails - 1) * nodes and
2143+
not tc.forceHighPrecision()
21432144
)
21442145
}
21452146

@@ -2973,12 +2974,15 @@ private AccessPathApprox getATail(AccessPathApprox apa, Configuration config) {
29732974
* expected to be expensive. Holds with `unfold = true` otherwise.
29742975
*/
29752976
private predicate evalUnfold(AccessPathApprox apa, boolean unfold, Configuration config) {
2976-
exists(int aps, int nodes, int apLimit, int tupleLimit |
2977-
aps = countPotentialAps(apa, config) and
2978-
nodes = countNodesUsingAccessPath(apa, config) and
2979-
accessPathCostLimits(apLimit, tupleLimit) and
2980-
if apLimit < aps and tupleLimit < (aps - 1) * nodes then unfold = false else unfold = true
2981-
)
2977+
if apa.getHead().forceHighPrecision()
2978+
then unfold = true
2979+
else
2980+
exists(int aps, int nodes, int apLimit, int tupleLimit |
2981+
aps = countPotentialAps(apa, config) and
2982+
nodes = countNodesUsingAccessPath(apa, config) and
2983+
accessPathCostLimits(apLimit, tupleLimit) and
2984+
if apLimit < aps and tupleLimit < (aps - 1) * nodes then unfold = false else unfold = true
2985+
)
29822986
}
29832987

29842988
/**

cpp/ql/lib/semmle/code/cpp/ir/dataflow/internal/DataFlowImpl3.qll

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2139,7 +2139,8 @@ private predicate expensiveLen2unfolding(TypedContent tc, Configuration config)
21392139
) and
21402140
accessPathApproxCostLimits(apLimit, tupleLimit) and
21412141
apLimit < tails and
2142-
tupleLimit < (tails - 1) * nodes
2142+
tupleLimit < (tails - 1) * nodes and
2143+
not tc.forceHighPrecision()
21432144
)
21442145
}
21452146

@@ -2973,12 +2974,15 @@ private AccessPathApprox getATail(AccessPathApprox apa, Configuration config) {
29732974
* expected to be expensive. Holds with `unfold = true` otherwise.
29742975
*/
29752976
private predicate evalUnfold(AccessPathApprox apa, boolean unfold, Configuration config) {
2976-
exists(int aps, int nodes, int apLimit, int tupleLimit |
2977-
aps = countPotentialAps(apa, config) and
2978-
nodes = countNodesUsingAccessPath(apa, config) and
2979-
accessPathCostLimits(apLimit, tupleLimit) and
2980-
if apLimit < aps and tupleLimit < (aps - 1) * nodes then unfold = false else unfold = true
2981-
)
2977+
if apa.getHead().forceHighPrecision()
2978+
then unfold = true
2979+
else
2980+
exists(int aps, int nodes, int apLimit, int tupleLimit |
2981+
aps = countPotentialAps(apa, config) and
2982+
nodes = countNodesUsingAccessPath(apa, config) and
2983+
accessPathCostLimits(apLimit, tupleLimit) and
2984+
if apLimit < aps and tupleLimit < (aps - 1) * nodes then unfold = false else unfold = true
2985+
)
29822986
}
29832987

29842988
/**

cpp/ql/lib/semmle/code/cpp/ir/dataflow/internal/DataFlowImpl4.qll

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2139,7 +2139,8 @@ private predicate expensiveLen2unfolding(TypedContent tc, Configuration config)
21392139
) and
21402140
accessPathApproxCostLimits(apLimit, tupleLimit) and
21412141
apLimit < tails and
2142-
tupleLimit < (tails - 1) * nodes
2142+
tupleLimit < (tails - 1) * nodes and
2143+
not tc.forceHighPrecision()
21432144
)
21442145
}
21452146

@@ -2973,12 +2974,15 @@ private AccessPathApprox getATail(AccessPathApprox apa, Configuration config) {
29732974
* expected to be expensive. Holds with `unfold = true` otherwise.
29742975
*/
29752976
private predicate evalUnfold(AccessPathApprox apa, boolean unfold, Configuration config) {
2976-
exists(int aps, int nodes, int apLimit, int tupleLimit |
2977-
aps = countPotentialAps(apa, config) and
2978-
nodes = countNodesUsingAccessPath(apa, config) and
2979-
accessPathCostLimits(apLimit, tupleLimit) and
2980-
if apLimit < aps and tupleLimit < (aps - 1) * nodes then unfold = false else unfold = true
2981-
)
2977+
if apa.getHead().forceHighPrecision()
2978+
then unfold = true
2979+
else
2980+
exists(int aps, int nodes, int apLimit, int tupleLimit |
2981+
aps = countPotentialAps(apa, config) and
2982+
nodes = countNodesUsingAccessPath(apa, config) and
2983+
accessPathCostLimits(apLimit, tupleLimit) and
2984+
if apLimit < aps and tupleLimit < (aps - 1) * nodes then unfold = false else unfold = true
2985+
)
29822986
}
29832987

29842988
/**

0 commit comments

Comments
 (0)