forked from github/codeql
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpp.cpp
More file actions
113 lines (92 loc) · 1.96 KB
/
pp.cpp
File metadata and controls
113 lines (92 loc) · 1.96 KB
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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
#if defined(FOO)
#error "This shouldn't happen"
#elif !defined(BAR)
#define BAR // I'm not a stool
#define BAR_val 1 /* I'm not a function */
#define BAR_fn() BAR_val
#else
#warning "This shouldn't happen either"
#endif
// semmle-extractor-options: -I${testdir}/more_headers/ "-U SOME_SYM"
#undef BAR
#define SCARY(a,aa,aaah) /* we ignore a */ (aa /* but we take aa */) /* and we ignore aaa */
#define LOG(fmt, ...) printf("Warning: %s", fmt, __VA__ARGS__)
#include "pp.h"
#if 0
#else
#endif
#if 1
#else
#endif
#import "a.h"
// --- contexts and templates ---
void functionContext()
{
#define MACRO_FUNCTIONCONTEXT 1
}
class classContext
{
public:
#define MACRO_CLASSCONTEXT 2
};
template <class T>
void templateFunctionContext()
{
#define MACRO_TEMPLATEFUNCTIONCONTEXT 3
}
template <class T>
class templateClassContext
{
public:
#define MACRO_TEMPLATECLASSCONTEXT 4
#define MACRO_TEMPLATECLASSCONTEXT_REFERENCED 5
template <class U>
void templateMethodContext() {
#define MACRO_TEMPLATEMETHODCONTEXT 6
}
#ifdef INSTANTIATION
#define IN_INSTANTIATION
#else
#define IN_TEMPLATE
#endif
static int val;
};
template <class T>
int templateClassContext<T> :: val = MACRO_TEMPLATECLASSCONTEXT_REFERENCED;
#define INSTANTIATION
templateClassContext<int> tcci;
#define BAR
#if defined(BAR) &&\
defined(BAR)
#warning BAR defined
#endif
#if defined MACROTHREE/**hello*/ && /*world*/\
/*hw*/(defined(MACROONE)) /* macroone */
#endif
#if defined SIMPLE_COMMENT //this comment \
(defined(SIMPLE_COMMENT)) spans over multiple lines
#endif
#if defined(FOO) &&\
defined(BAR)
#define CONDITIONAL_MACRO_1 1
#endif
#if defined(FOO) && \
defined(BAR) && \
!defined(BAZ)
#define CONDITIONAL_MACRO_2 2
#endif
#define FOO 8
#define BAR 2
#define BAZ 4
#if ((FOO / BAR) \
== 4) && ((BAZ \
* QUX) \
> 10)
#define CONDITIONAL_MACRO_3 3
#endif
// Testing \t spaced PreprocessorIf
#if defined(FOO) && \
defined(BAR) && \
defined(BAZ)
#define CONDITIONAL_MACRO_4 4
#endif