Skip to content

Commit 6efbd7b

Browse files
committed
add docs
Signed-off-by: Justin Stitt <[email protected]>
1 parent 548efc6 commit 6efbd7b

File tree

2 files changed

+68
-2
lines changed

2 files changed

+68
-2
lines changed

clang/docs/ReleaseNotes.rst

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -635,6 +635,14 @@ Sanitizers
635635
This new flag should allow those projects to enable integer sanitizers with
636636
less noise.
637637

638+
- Arithmetic overflow sanitizers ``-fsanitize=signed-integer-overflow`` and
639+
``-fsanitize=unsigned-integer-overflow`` as well as the implicit integer
640+
truncation sanitizers ``-fsanitize=implicit-signed-integer-truncation`` and
641+
``-fsanitize=implicit-unsigned-integer-truncation`` now properly support the
642+
"type" prefix within `Sanitizer Special Case Lists (SSCL)
643+
<https://clang.llvm.org/docs/SanitizerSpecialCaseList.html>`_. See that link
644+
for examples.
645+
638646
Python Binding Changes
639647
----------------------
640648
- Fixed an issue that led to crashes when calling ``Type.get_exception_specification_kind``.

clang/docs/SanitizerSpecialCaseList.rst

Lines changed: 60 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,9 @@ file at compile-time.
1515
Goal and usage
1616
==============
1717

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
2021
certain source-level entities to:
2122

2223
* speedup hot function, which is known to be correct;
@@ -48,6 +49,63 @@ Example
4849
$ clang -fsanitize=address -fsanitize-ignorelist=ignorelist.txt foo.c ; ./a.out
4950
# No error report here.
5051
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+
51109
Format
52110
======
53111

0 commit comments

Comments
 (0)