Skip to content

Commit 11c71f0

Browse files
committed
C++: Accept changes after C++ extractor preprocessor fix
1 parent 179bae8 commit 11c71f0

File tree

2 files changed

+57
-5
lines changed

2 files changed

+57
-5
lines changed

cpp/ql/test/library-tests/preprocessor/preprocessor/pp.cpp

Lines changed: 39 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
// semmle-extractor-options: -I${testdir}/more_headers/ "-U SOME_SYM"
1111
#undef BAR
1212
#define SCARY(a,aa,aaah) /* we ignore a */ (aa /* but we take aa */) /* and we ignore aaa */
13-
#define LOG(fmt, ...) printf("Warning: %s", fmt, __VA__ARGS__)
13+
#define LOG(fmt, ...) printf("Warning: %s", fmt, __VA__ARGS__)
1414
#include "pp.h"
1515

1616
#if 0
@@ -59,7 +59,7 @@ class templateClassContext
5959
#else
6060
#define IN_TEMPLATE
6161
#endif
62-
62+
6363
static int val;
6464
};
6565

@@ -71,7 +71,43 @@ templateClassContext<int> tcci;
7171

7272
#define BAR
7373

74-
#if defined(BAR) && \
74+
#if defined(BAR) &&\
7575
defined(BAR)
7676
#warning BAR defined
7777
#endif
78+
79+
#if defined MACROTHREE/**hello*/ && /*world*/\
80+
/*hw*/(defined(MACROONE)) /* macroone */
81+
#endif
82+
83+
#if defined SIMPLE_COMMENT //this comment \
84+
(defined(SIMPLE_COMMENT)) spans over multiple lines
85+
#endif
86+
87+
#if defined(FOO) &&\
88+
defined(BAR)
89+
#define CONDITIONAL_MACRO_1 1
90+
#endif
91+
92+
#if defined(FOO) && \
93+
defined(BAR) && \
94+
!defined(BAZ)
95+
#define CONDITIONAL_MACRO_2 2
96+
#endif
97+
98+
#define FOO 8
99+
#define BAR 2
100+
#define BAZ 4
101+
#if ((FOO / BAR) \
102+
== 4) && ((BAZ \
103+
* QUX) \
104+
> 10)
105+
#define CONDITIONAL_MACRO_3 3
106+
#endif
107+
108+
// Testing \t spaced PreprocessorIf
109+
#if defined(FOO) && \
110+
defined(BAR) && \
111+
defined(BAZ)
112+
#define CONDITIONAL_MACRO_4 4
113+
#endif

cpp/ql/test/library-tests/preprocessor/preprocessor/preproc.expected

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,12 +38,28 @@
3838
| pp.cpp:0:0:0:0 | pp.cpp | 61 | 1 | 61 | 7 | PreprocessorEndif | N/A | N/A |
3939
| pp.cpp:0:0:0:0 | pp.cpp | 69 | 1 | 69 | 21 | Macro | INSTANTIATION | |
4040
| pp.cpp:0:0:0:0 | pp.cpp | 72 | 1 | 72 | 11 | Macro | BAR | |
41-
| pp.cpp:0:0:0:0 | pp.cpp | 74 | 1 | 74 | 21 | PreprocessorIf | defined(BAR) && \\ | N/A |
41+
| pp.cpp:0:0:0:0 | pp.cpp | 74 | 1 | 75 | 13 | PreprocessorIf | defined(BAR) && defined(BAR) | N/A |
4242
| pp.cpp:0:0:0:0 | pp.cpp | 76 | 1 | 76 | 20 | PreprocessorWarning | BAR defined | N/A |
4343
| pp.cpp:0:0:0:0 | pp.cpp | 77 | 1 | 77 | 6 | PreprocessorEndif | N/A | N/A |
44+
| pp.cpp:0:0:0:0 | pp.cpp | 79 | 1 | 80 | 18 | PreprocessorIf | defined MACROTHREE && (defined(MACROONE)) | N/A |
45+
| pp.cpp:0:0:0:0 | pp.cpp | 81 | 1 | 81 | 6 | PreprocessorEndif | N/A | N/A |
46+
| pp.cpp:0:0:0:0 | pp.cpp | 83 | 1 | 84 | 26 | PreprocessorIf | defined SIMPLE_COMMENT | N/A |
47+
| pp.cpp:0:0:0:0 | pp.cpp | 85 | 1 | 85 | 6 | PreprocessorEndif | N/A | N/A |
48+
| pp.cpp:0:0:0:0 | pp.cpp | 87 | 1 | 88 | 15 | PreprocessorIf | defined(FOO) && defined(BAR) | N/A |
49+
| pp.cpp:0:0:0:0 | pp.cpp | 90 | 1 | 90 | 6 | PreprocessorEndif | N/A | N/A |
50+
| pp.cpp:0:0:0:0 | pp.cpp | 92 | 1 | 94 | 14 | PreprocessorIf | defined(FOO) && defined(BAR) && !defined(BAZ) | N/A |
51+
| pp.cpp:0:0:0:0 | pp.cpp | 96 | 1 | 96 | 6 | PreprocessorEndif | N/A | N/A |
52+
| pp.cpp:0:0:0:0 | pp.cpp | 98 | 1 | 98 | 13 | Macro | FOO | 8 |
53+
| pp.cpp:0:0:0:0 | pp.cpp | 99 | 1 | 99 | 13 | Macro | BAR | 2 |
54+
| pp.cpp:0:0:0:0 | pp.cpp | 100 | 1 | 100 | 13 | Macro | BAZ | 4 |
55+
| pp.cpp:0:0:0:0 | pp.cpp | 101 | 1 | 104 | 3 | PreprocessorIf | ((FOO / BAR) == 4) && ((BAZ * QUX) > 10) | N/A |
56+
| pp.cpp:0:0:0:0 | pp.cpp | 106 | 1 | 106 | 6 | PreprocessorEndif | N/A | N/A |
57+
| pp.cpp:0:0:0:0 | pp.cpp | 109 | 1 | 111 | 10 | PreprocessorIf | defined(FOO) && defined(BAR) && defined(BAZ) | N/A |
58+
| pp.cpp:0:0:0:0 | pp.cpp | 112 | 1 | 112 | 29 | Macro | CONDITIONAL_MACRO_4 | 4 |
59+
| pp.cpp:0:0:0:0 | pp.cpp | 113 | 1 | 113 | 6 | PreprocessorEndif | N/A | N/A |
4460
| pp.h:0:0:0:0 | pp.h | 1 | 1 | 1 | 12 | PreprocessorPragma | once | N/A |
4561
| pp.h:0:0:0:0 | pp.h | 2 | 1 | 2 | 29 | PreprocessorWarning | "This should happen" | N/A |
46-
| pp.h:0:0:0:0 | pp.h | 3 | 1 | 3 | 27 | PreprocessorLine | 33 "emerald_city.h" | N/A |
62+
| pp.h:0:0:0:0 | pp.h | 3 | 1 | 3 | 27 | PreprocessorLine | 33 "emerald_city.h" | N/A |
4763
| pp.h:0:0:0:0 | pp.h | 4 | 1 | 4 | 30 | PreprocessorPragma | byte_order(big_endian) | N/A |
4864
| pp.h:0:0:0:0 | pp.h | 5 | 1 | 5 | 33 | PreprocessorWarning | "Not in Kansas any more" | N/A |
4965
| pp.h:0:0:0:0 | pp.h | 7 | 1 | 11 | 8 | Macro | MULTILINE | world a long |

0 commit comments

Comments
 (0)