Skip to content

Commit 09ebd6e

Browse files
committed
C++: Instantiate inline expectation test framework to test model generation.
1 parent f241e4b commit 09ebd6e

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed
+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
private import cpp
2+
private import codeql.mad.test.InlineMadTest
3+
4+
class MadRelevantFunction extends Function {
5+
MadRelevantFunction() { not this.isFromUninstantiatedTemplate(_) }
6+
}
7+
8+
private module InlineMadTestLang implements InlineMadTestLangSig {
9+
class Callable = MadRelevantFunction;
10+
11+
/**
12+
* Holds if `c` is the closest `Callable` that suceeds `comment` in the file.
13+
*/
14+
private predicate hasClosestCallable(CppStyleComment comment, Callable c) {
15+
c =
16+
min(Callable cand, int dist |
17+
// This has no good join order, but should hopefully be good enough for tests.
18+
cand.getFile() = comment.getFile() and
19+
dist = cand.getLocation().getStartLine() - comment.getLocation().getStartLine() and
20+
dist > 0
21+
|
22+
cand order by dist
23+
)
24+
}
25+
26+
string getComment(Callable c) {
27+
exists(CppStyleComment comment |
28+
hasClosestCallable(comment, c) and
29+
result = comment.getContents().suffix(2)
30+
)
31+
}
32+
}
33+
34+
import InlineMadTestImpl<InlineMadTestLang>

0 commit comments

Comments
 (0)