File tree 1 file changed +34
-0
lines changed
1 file changed +34
-0
lines changed Original file line number Diff line number Diff line change
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 >
You can’t perform that action at this time.
0 commit comments