File: raw_ptr_system_test.h

package info (click to toggle)
chromium 139.0.7258.127-1
  • links: PTS, VCS
  • area: main
  • in suites:
  • size: 6,122,068 kB
  • sloc: cpp: 35,100,771; ansic: 7,163,530; javascript: 4,103,002; python: 1,436,920; asm: 946,517; xml: 746,709; pascal: 187,653; perl: 88,691; sh: 88,436; objc: 79,953; sql: 51,488; cs: 44,583; fortran: 24,137; makefile: 22,147; tcl: 15,277; php: 13,980; yacc: 8,984; ruby: 7,485; awk: 3,720; lisp: 3,096; lex: 1,327; ada: 727; jsp: 228; sed: 36
file content (132 lines) | stat: -rw-r--r-- 5,821 bytes parent folder | download | duplicates (6)
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
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
// Copyright 2023 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef TOOLS_CLANG_RAW_PTR_PLUGIN_TESTS_SYSTEM_RAW_PTR_SYSTEM_TEST_H_
#define TOOLS_CLANG_RAW_PTR_PLUGIN_TESTS_SYSTEM_RAW_PTR_SYSTEM_TEST_H_
#line 7 "/src/tools/clang/plugins/tests/system/raw_ptr_system_test.h"

#define SYS_INT int
#define SYS_INTP int*
#define SYS_CONST const
#define SYS_ATTR [[fake_attribute]]
#define SYS_INTP_FIELD() int* macro_ptr
#define SYS_TYPE_WITH_SUFFIX(TYP) TYP##Suffix
#define SYS_SYMBOL(SYM) SYM
#define SYS_SYMBOL_WITH_SUFFIX(SYM) SYM##_Suffix
#define SYS_EQ =
#define SYS_NULLPTR nullptr
class SysTypSuffix;

// OK: code owner has no control over system header.
struct SysStructWithSysMacro {
  int* ptr0;                                     // OK.
  SYS_INT* ptr1;                                 // OK.
  SYS_INTP ptr2;                                 // OK.
  int* SYS_CONST ptr3;                           // OK.
  int* SYS_ATTR ptr4;                            // OK.
  SYS_INTP_FIELD();                              // OK.
  SYS_TYPE_WITH_SUFFIX(SysTyp) * ptr5;           // OK.
  int* SYS_SYMBOL(ptr6);                         // OK.
  int* SYS_SYMBOL_WITH_SUFFIX(ptr7);             // OK.
  int* ptr8 SYS_EQ nullptr;                      // OK.
  int* ptr9 = SYS_NULLPTR;                       // OK.
  int* SYS_SYMBOL_WITH_SUFFIX(ptr10) = nullptr;  // OK.
};

// OK: code owner has no control over system header and command line.
struct SysStructWithCmdMacro {
  int* ptr0;                                     // OK.
  CMD_INT* ptr1;                                 // OK.
  CMD_INTP ptr2;                                 // OK.
  int* CMD_CONST ptr3;                           // OK.
  int* CMD_ATTR ptr4;                            // OK.
  CMD_INTP_FIELD();                              // OK.
  CMD_TYPE_WITH_SUFFIX(SysTyp) * ptr5;           // OK.
  int* CMD_SYMBOL(ptr6);                         // OK.
  int* CMD_SYMBOL_WITH_SUFFIX(ptr7);             // OK.
  int* ptr8 CMD_EQ nullptr;                      // OK.
  int* ptr9 = CMD_NULLPTR;                       // OK.
  int* CMD_SYMBOL_WITH_SUFFIX(ptr10) = nullptr;  // OK.
};

// These `USR_***` macro should be defined before including this header,
// in `//tools/clang/plugins/tests/raw_ptr_fields_macro.cpp`.
struct SysStructWithUsrMacro {
  // OK: code owner has no control over system header.
  int* ptr0;
  // OK: code owner has no control over system header.
  USR_INT* ptr1;
  // OK: code owner has no control over system header.
  USR_INTP ptr2;
  // OK: code owner has no control over system header.
  int* USR_CONST ptr3;
  // OK: code owner has no control over system header.
  int* USR_ATTR ptr4;
  // Error: user has control over the macro.
  USR_INTP_FIELD();
  // OK: code owner has no control over system header.
  USR_TYPE_WITH_SUFFIX(SysTyp) * ptr5;
  // OK: code owner has no control over system header.
  int* USR_SYMBOL(ptr6);
  // OK: the source location for this field declaration will be "<scratch
  // space>" and the real file path cannot be detected.
  int* USR_SYMBOL_WITH_SUFFIX(ptr7);
  // OK: code owner has no control over system header.
  int* ptr8 USR_EQ nullptr;
  // OK: code owner has no control over system header.
  int* ptr9 = USR_NULLPTR;
  // OK: the source location for this field declaration will be "<scratch
  // space>" and the real file path cannot be detected.
  int* USR_SYMBOL_WITH_SUFFIX(ptr10) = nullptr;
};

// Same as for SysStructWithSysMacro.
struct SysStructWithThirdPartyMacro {
  int* ptr0;                                    // OK.
  TP_INT* ptr1;                                 // OK.
  TP_INTP ptr2;                                 // OK.
  int* TP_CONST ptr3;                           // OK.
  int* TP_ATTR ptr4;                            // OK.
  TP_INTP_FIELD();                              // OK.
  TP_TYPE_WITH_SUFFIX(SysTyp) * ptr5;           // OK.
  int* TP_SYMBOL(ptr6);                         // OK.
  int* TP_SYMBOL_WITH_SUFFIX(ptr7);             // OK.
  int* ptr8 TP_EQ nullptr;                      // OK.
  int* ptr9 = TP_NULLPTR;                       // OK.
  int* TP_SYMBOL_WITH_SUFFIX(ptr10) = nullptr;  // OK.
};

// Same as for SysStructWithSysMacro.
struct SysStructWithManuallyIgnoredMacro {
  int* ptr0;                                    // OK.
  IG_INT* ptr1;                                 // OK.
  IG_INTP ptr2;                                 // OK.
  int* IG_CONST ptr3;                           // OK.
  int* IG_ATTR ptr4;                            // OK.
  IG_INTP_FIELD();                              // OK.
  IG_TYPE_WITH_SUFFIX(SysTyp) * ptr5;           // OK.
  int* IG_SYMBOL(ptr6);                         // OK.
  int* IG_SYMBOL_WITH_SUFFIX(ptr7);             // OK.
  int* ptr8 IG_EQ nullptr;                      // OK.
  int* ptr9 = IG_NULLPTR;                       // OK.
  int* IG_SYMBOL_WITH_SUFFIX(ptr10) = nullptr;  // OK.
};

// Same as for SysStructWithSysMacro.
struct SysStructWithGeneratedMacro {
  int* ptr0;                                     // OK.
  GEN_INT* ptr1;                                 // OK.
  GEN_INTP ptr2;                                 // OK.
  int* GEN_CONST ptr3;                           // OK.
  int* GEN_ATTR ptr4;                            // OK.
  GEN_INTP_FIELD();                              // OK.
  GEN_TYPE_WITH_SUFFIX(SysTyp) * ptr5;           // OK.
  int* GEN_SYMBOL(ptr6);                         // OK.
  int* GEN_SYMBOL_WITH_SUFFIX(ptr7);             // OK.
  int* ptr8 GEN_EQ nullptr;                      // OK.
  int* ptr9 = GEN_NULLPTR;                       // OK.
  int* GEN_SYMBOL_WITH_SUFFIX(ptr10) = nullptr;  // OK.
};

#endif  // TOOLS_CLANG_RAW_PTR_PLUGIN_TESTS_SYSTEM_RAW_PTR_SYSTEM_TEST_H_