-
Notifications
You must be signed in to change notification settings - Fork 1.7k
/
Copy pathSMAP.qll
57 lines (53 loc) · 1.99 KB
/
SMAP.qll
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
/**
* Provides classes and predicates for working with SMAP files (see JSR-045).
*/
import java
/**
* Holds if there exists a mapping between an SMAP input file and line
* and a corresponding SMAP output file and line range.
*/
private predicate smap(File inputFile, int inLine, File outputFile, int outLineStart, int outLineEnd) {
exists(
string defaultStratum, int inputFileNum, int inStart, int inCount, int outStart, int outIncr,
int n
|
smap_header(outputFile, _, defaultStratum) and
smap_files(outputFile, defaultStratum, inputFileNum, _, inputFile) and
smap_lines(outputFile, defaultStratum, inputFileNum, inStart, inCount, outStart, outIncr) and
inLine in [inStart .. inStart + inCount - 1] and
outLineStart = outStart + n * outIncr and
outLineEnd = (n + 1) * outIncr - 1 + outStart and
n = inLine - inStart
)
}
/**
* Holds if there exists a mapping between an SMAP input file and line
* and a corresponding SMAP output file and line.
*/
pragma[nomagic]
private predicate smap(File inputFile, int inLine, File outputFile, int outLine) {
exists(int outLineStart, int outLineEnd |
smap(inputFile, inLine, outputFile, outLineStart, outLineEnd) and
outLine in [outLineStart .. outLineEnd]
)
}
/**
* Holds if an SMAP input location (with path, line and column information)
* has a corresponding SMAP output location (with path and line information).
*
* For example, an SMAP input location may be a location within a JSP file,
* which may have a corresponding SMAP output location in generated Java code.
*/
predicate hasSmapLocationInfo(
string inputPath, int isl, int isc, int iel, int iec, string outputPath, int osl, int oel
) {
exists(File inputFile, File outputFile |
inputPath = inputFile.getAbsolutePath() and
outputPath = outputFile.getAbsolutePath() and
locations_default(_, outputFile, osl, _, oel, _) and
smap(inputFile, isl, outputFile, osl) and
smap(inputFile, iel - 1, outputFile, oel) and
isc = 1 and
iec = 1
)
}