Skip to content

Commit 4068cc9

Browse files
committed
Shared SSA: Sync files
1 parent bc80c9b commit 4068cc9

File tree

5 files changed

+125
-0
lines changed

5 files changed

+125
-0
lines changed

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

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -634,3 +634,28 @@ class UncertainWriteDefinition extends WriteDefinition {
634634
)
635635
}
636636
}
637+
638+
/** Provides a set of consistency queries. */
639+
module Consistency {
640+
abstract class RelevantDefinition extends Definition {
641+
abstract predicate hasLocationInfo(
642+
string filepath, int startline, int startcolumn, int endline, int endcolumn
643+
);
644+
}
645+
646+
query predicate nonUniqueDef(RelevantDefinition def, SourceVariable v, BasicBlock bb, int i) {
647+
ssaDefReachesRead(v, def, bb, i) and
648+
not exists(unique(Definition def0 | ssaDefReachesRead(_, def0, bb, i)))
649+
}
650+
651+
query predicate readWithoutDef(SourceVariable v, BasicBlock bb, int i) {
652+
variableRead(bb, i, v, _) and
653+
not ssaDefReachesRead(_, _, bb, i)
654+
}
655+
656+
query predicate deadDef(RelevantDefinition def, SourceVariable v) {
657+
v = def.getSourceVariable() and
658+
not ssaDefReachesRead(_, def, _, _) and
659+
not phiHasInputFromBlock(_, def, _)
660+
}
661+
}

csharp/ql/lib/semmle/code/cil/internal/SsaImplCommon.qll

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -634,3 +634,28 @@ class UncertainWriteDefinition extends WriteDefinition {
634634
)
635635
}
636636
}
637+
638+
/** Provides a set of consistency queries. */
639+
module Consistency {
640+
abstract class RelevantDefinition extends Definition {
641+
abstract predicate hasLocationInfo(
642+
string filepath, int startline, int startcolumn, int endline, int endcolumn
643+
);
644+
}
645+
646+
query predicate nonUniqueDef(RelevantDefinition def, SourceVariable v, BasicBlock bb, int i) {
647+
ssaDefReachesRead(v, def, bb, i) and
648+
not exists(unique(Definition def0 | ssaDefReachesRead(_, def0, bb, i)))
649+
}
650+
651+
query predicate readWithoutDef(SourceVariable v, BasicBlock bb, int i) {
652+
variableRead(bb, i, v, _) and
653+
not ssaDefReachesRead(_, _, bb, i)
654+
}
655+
656+
query predicate deadDef(RelevantDefinition def, SourceVariable v) {
657+
v = def.getSourceVariable() and
658+
not ssaDefReachesRead(_, def, _, _) and
659+
not phiHasInputFromBlock(_, def, _)
660+
}
661+
}

csharp/ql/lib/semmle/code/csharp/controlflow/internal/pressa/SsaImplCommon.qll

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -634,3 +634,28 @@ class UncertainWriteDefinition extends WriteDefinition {
634634
)
635635
}
636636
}
637+
638+
/** Provides a set of consistency queries. */
639+
module Consistency {
640+
abstract class RelevantDefinition extends Definition {
641+
abstract predicate hasLocationInfo(
642+
string filepath, int startline, int startcolumn, int endline, int endcolumn
643+
);
644+
}
645+
646+
query predicate nonUniqueDef(RelevantDefinition def, SourceVariable v, BasicBlock bb, int i) {
647+
ssaDefReachesRead(v, def, bb, i) and
648+
not exists(unique(Definition def0 | ssaDefReachesRead(_, def0, bb, i)))
649+
}
650+
651+
query predicate readWithoutDef(SourceVariable v, BasicBlock bb, int i) {
652+
variableRead(bb, i, v, _) and
653+
not ssaDefReachesRead(_, _, bb, i)
654+
}
655+
656+
query predicate deadDef(RelevantDefinition def, SourceVariable v) {
657+
v = def.getSourceVariable() and
658+
not ssaDefReachesRead(_, def, _, _) and
659+
not phiHasInputFromBlock(_, def, _)
660+
}
661+
}

csharp/ql/lib/semmle/code/csharp/dataflow/internal/SsaImplCommon.qll

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -634,3 +634,28 @@ class UncertainWriteDefinition extends WriteDefinition {
634634
)
635635
}
636636
}
637+
638+
/** Provides a set of consistency queries. */
639+
module Consistency {
640+
abstract class RelevantDefinition extends Definition {
641+
abstract predicate hasLocationInfo(
642+
string filepath, int startline, int startcolumn, int endline, int endcolumn
643+
);
644+
}
645+
646+
query predicate nonUniqueDef(RelevantDefinition def, SourceVariable v, BasicBlock bb, int i) {
647+
ssaDefReachesRead(v, def, bb, i) and
648+
not exists(unique(Definition def0 | ssaDefReachesRead(_, def0, bb, i)))
649+
}
650+
651+
query predicate readWithoutDef(SourceVariable v, BasicBlock bb, int i) {
652+
variableRead(bb, i, v, _) and
653+
not ssaDefReachesRead(_, _, bb, i)
654+
}
655+
656+
query predicate deadDef(RelevantDefinition def, SourceVariable v) {
657+
v = def.getSourceVariable() and
658+
not ssaDefReachesRead(_, def, _, _) and
659+
not phiHasInputFromBlock(_, def, _)
660+
}
661+
}

csharp/ql/lib/semmle/code/csharp/dataflow/internal/basessa/SsaImplCommon.qll

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -634,3 +634,28 @@ class UncertainWriteDefinition extends WriteDefinition {
634634
)
635635
}
636636
}
637+
638+
/** Provides a set of consistency queries. */
639+
module Consistency {
640+
abstract class RelevantDefinition extends Definition {
641+
abstract predicate hasLocationInfo(
642+
string filepath, int startline, int startcolumn, int endline, int endcolumn
643+
);
644+
}
645+
646+
query predicate nonUniqueDef(RelevantDefinition def, SourceVariable v, BasicBlock bb, int i) {
647+
ssaDefReachesRead(v, def, bb, i) and
648+
not exists(unique(Definition def0 | ssaDefReachesRead(_, def0, bb, i)))
649+
}
650+
651+
query predicate readWithoutDef(SourceVariable v, BasicBlock bb, int i) {
652+
variableRead(bb, i, v, _) and
653+
not ssaDefReachesRead(_, _, bb, i)
654+
}
655+
656+
query predicate deadDef(RelevantDefinition def, SourceVariable v) {
657+
v = def.getSourceVariable() and
658+
not ssaDefReachesRead(_, def, _, _) and
659+
not phiHasInputFromBlock(_, def, _)
660+
}
661+
}

0 commit comments

Comments
 (0)