File: traditional-cpp.c

package info (click to toggle)
llvm-toolchain-13 1%3A13.0.1-11
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 1,418,840 kB
  • sloc: cpp: 5,290,826; ansic: 996,570; asm: 544,593; python: 188,212; objc: 72,027; lisp: 30,291; f90: 25,395; sh: 24,898; javascript: 9,780; pascal: 9,398; perl: 7,484; ml: 5,432; awk: 3,523; makefile: 2,913; xml: 953; cs: 573; fortran: 539
file content (109 lines) | stat: -rw-r--r-- 2,662 bytes parent folder | download | duplicates (32)
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
/* Clang supports a very limited subset of -traditional-cpp, basically we only
 * intend to add support for things that people actually rely on when doing
 * things like using /usr/bin/cpp to preprocess non-source files. */

/*
 RUN: %clang_cc1 -traditional-cpp %s -E | FileCheck -strict-whitespace %s
 RUN: %clang_cc1 -traditional-cpp %s -E -C | FileCheck -check-prefix=CHECK-COMMENTS %s
 RUN: %clang_cc1 -traditional-cpp -x c++ %s -E | FileCheck -check-prefix=CHECK-CXX %s
*/

/* -traditional-cpp should eliminate all C89 comments. */
/* CHECK-NOT: /*
 * CHECK-COMMENTS: {{^}}/* -traditional-cpp should eliminate all C89 comments. *{{/$}}
 */

/* -traditional-cpp should only eliminate "//" comments in C++ mode. */
/* CHECK: {{^}}foo // bar{{$}}
 * CHECK-CXX: {{^}}foo {{$}}
 */
foo // bar


/* The lines in this file contain hard tab characters and trailing whitespace; 
 * do not change them! */

/* CHECK: {{^}}	indented!{{$}}
 * CHECK: {{^}}tab	separated	values{{$}}
 */
	indented!
tab	separated	values

#define bracket(x) >>>x<<<
bracket(|  spaces  |)
/* CHECK: {{^}}>>>|  spaces  |<<<{{$}}
 */

/* This is still a preprocessing directive. */
# define foo bar
foo!
-
	foo!	foo!	
/* CHECK: {{^}}bar!{{$}}
 * CHECK: {{^}}	bar!	bar!	{{$}}
 */

/* Deliberately check a leading newline with spaces on that line. */
   
# define foo bar
foo!
-
	foo!	foo!	
/* CHECK: {{^}}bar!{{$}}
 * CHECK: {{^}}	bar!	bar!	{{$}}
 */

/* FIXME: -traditional-cpp should not consider this a preprocessing directive
 * because the # isn't in the first column.
 */
 #define foo2 bar
foo2!
/* If this were working, both of these checks would be on.
 * CHECK-NOT: {{^}} #define foo2 bar{{$}}
 * CHECK-NOT: {{^}}foo2!{{$}}
 */

/* FIXME: -traditional-cpp should not homogenize whitespace in macros.
 */
#define bracket2(x) >>>  x  <<<
bracket2(spaces)
/* If this were working, this check would be on.
 * CHECK-NOT: {{^}}>>>  spaces  <<<{{$}}
 */


/* Check that #if 0 blocks work as expected */
#if 0
#error "this is not an error"

#if 1
a b c in skipped block
#endif

/* Comments are whitespace too */

#endif
/* CHECK-NOT: {{^}}a b c in skipped block{{$}}
 * CHECK-NOT: {{^}}/* Comments are whitespace too
 */

Preserve URLs: http://clang.llvm.org
/* CHECK: {{^}}Preserve URLs: http://clang.llvm.org{{$}}
 */

/* The following tests ensure we ignore # and ## in macro bodies */

#define FOO_NO_STRINGIFY(a) test(# a)
FOO_NO_STRINGIFY(foobar)
/* CHECK: {{^}}test(# foobar){{$}}
 */

#define FOO_NO_PASTE(a, b) test(b##a)
FOO_NO_PASTE(xxx,yyy)
/* CHECK: {{^}}test(yyy##xxx){{$}}
 */

#define BAR_NO_STRINGIFY(a) test(#a)
BAR_NO_STRINGIFY(foobar)
/* CHECK: {{^}}test(#foobar){{$}}
 */