@@ -15,8 +15,9 @@ file at compile-time.
15
15
Goal and usage
16
16
==============
17
17
18
- Users of sanitizer tools, such as :doc: `AddressSanitizer `, :doc: `ThreadSanitizer `
19
- or :doc: `MemorySanitizer ` may want to disable or alter some checks for
18
+ Users of sanitizer tools, such as :doc: `AddressSanitizer `,
19
+ :doc: `ThreadSanitizer `, :doc: `MemorySanitizer ` or :doc:
20
+ `UndefinedBehaviorSanitizer ` may want to disable or alter some checks for
20
21
certain source-level entities to:
21
22
22
23
* speedup hot function, which is known to be correct;
@@ -48,6 +49,63 @@ Example
48
49
$ clang -fsanitize=address -fsanitize-ignorelist=ignorelist.txt foo.c ; ./a.out
49
50
# No error report here.
50
51
52
+ Usage with UndefinedBehaviorSanitizer
53
+ =====================================
54
+
55
+ The arithmetic overflow sanitizers ``unsigned-integer-overflow `` and
56
+ ``signed-integer-overflow `` as well as the implicit integer truncation
57
+ sanitizers ``implicit-signed-integer-truncation `` and
58
+ ``implicit-unsigned-integer-truncation `` support the ability to adjust
59
+ instrumentation based on type.
60
+
61
+ .. code-block :: bash
62
+
63
+ $ cat foo.c
64
+ void foo () {
65
+ int a = 2147483647; // INT_MAX
66
+ ++a; // Normally, an overflow with -fsanitize=signed-integer-overflow
67
+ }
68
+ $ cat ignorelist.txt
69
+ [signed-integer-overflow]
70
+ type:int
71
+ $ clang -fsanitize=signed-integer-overflow -fsanitize-ignorelist=ignorelist.txt foo.c ; ./a.out
72
+ # no signed-integer-overflow error
73
+
74
+ Supplying ``ignorelist.txt `` with ``-fsanitize-ignorelist=ignorelist.txt ``
75
+ disables overflow sanitizer instrumentation for arithmetic operations
76
+ containing values of type ``int ``, for example. Custom types may be used.
77
+
78
+ The following SCL categories are supported: ``=allow ``, ``=skip `` and
79
+ ``=forbid ``. The ``allow `` category is the default for any entry and specifies
80
+ that the query, if matched, will have its sanitizer instrumentation ignored.
81
+ Conversely, both ``skip `` and ``forbid `` cause their queries, if matched, to be
82
+ left out of the ignorelist -- essentially ensuring sanitizer instrumentation
83
+ remains for those types. This is useful for whitelisting specific types.
84
+
85
+ With this, one may disable instrumentation for all types and specifically allow
86
+ instrumentation for one or many types.
87
+
88
+ .. code-block :: bash
89
+
90
+ $ cat ignorelist.txt
91
+ [implicit-signed-integer-truncation]
92
+ type:* =allow
93
+ type:T=skip
94
+ $ cat foo.c
95
+ typedef char T;
96
+ typedef char U;
97
+ void foo(int toobig) {
98
+ T a = toobig; // instrumented
99
+ U b = toobig; // not instrumented
100
+ char c = toobig; // also not instrumented
101
+ }
102
+
103
+ Note that ``skip `` and ``forbid `` operate exactly the same in this context and
104
+ both options exist simply for conformity with the `-fprofile-list
105
+ <https://clang.llvm.org/docs/UsersManual.html#instrumenting-only-selected-files-or-functions> `_
106
+ syntax for adjusting profile instrumentation. You do not need to specify any
107
+ `default:<type> ` for ``-fsanitize-ignorelist `` SSCLs, though.
108
+
51
109
Format
52
110
======
53
111
0 commit comments