mirror of
https://github.com/github/codeql.git
synced 2025-12-19 18:33:16 +01:00
34 lines
713 B
Plaintext
34 lines
713 B
Plaintext
/**
|
|
* @name Test that the results of constant folding are recorded, but that the
|
|
* original AST is populated.
|
|
*/
|
|
|
|
import csharp
|
|
|
|
string lost(LocalVariable v) {
|
|
v.fromSource() and
|
|
v.getInitializer() instanceof Literal and
|
|
result = "Folded literal populated - original lost"
|
|
}
|
|
|
|
string noValue(LocalVariable v) {
|
|
v.fromSource() and
|
|
v.getInitializer() instanceof Literal and
|
|
result = "No constant value recorded"
|
|
}
|
|
|
|
string correct(LocalVariable v) {
|
|
v.fromSource() and
|
|
exists(v.getInitializer()) and
|
|
not exists(lost(v)) and
|
|
not exists(noValue(v)) and
|
|
result = "Correct"
|
|
}
|
|
|
|
from LocalVariable v, string msg
|
|
where
|
|
msg = lost(v) or
|
|
msg = noValue(v) or
|
|
msg = correct(v)
|
|
select v, msg
|