1 | //=- UnsafeBufferUsageGadgets.def - List of ways to use a buffer --*- C++ -*-=// |
2 | // |
3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
4 | // See https://llvm.org/LICENSE.txt for license information. |
5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
6 | // |
7 | //===----------------------------------------------------------------------===// |
8 | |
9 | /// A gadget is an individual operation in the code that may be of interest to |
10 | /// the UnsafeBufferUsage analysis. |
11 | #ifndef GADGET |
12 | #define GADGET(name) |
13 | #endif |
14 | |
15 | /// Unsafe gadgets correspond to unsafe code patterns that warrant |
16 | /// an immediate warning. |
17 | #ifndef WARNING_GADGET |
18 | #define WARNING_GADGET(name) GADGET(name) |
19 | #endif |
20 | |
21 | /// A `WARNING_GADGET` subset, where the code pattern of each gadget |
22 | /// corresponds uses of a (possibly hardened) contatiner (e.g., `std::span`). |
23 | #ifndef WARNING_CONTAINER_GADGET |
24 | #define WARNING_CONTAINER_GADGET(name) WARNING_GADGET(name) |
25 | #endif |
26 | |
27 | /// Safe gadgets correspond to code patterns that aren't unsafe but need to be |
28 | /// properly recognized in order to emit correct warnings and fixes over unsafe |
29 | /// gadgets. |
30 | #ifndef FIXABLE_GADGET |
31 | #define FIXABLE_GADGET(name) GADGET(name) |
32 | #endif |
33 | |
34 | WARNING_GADGET(Increment) |
35 | WARNING_GADGET(Decrement) |
36 | WARNING_GADGET(ArraySubscript) |
37 | WARNING_GADGET(PointerArithmetic) |
38 | WARNING_GADGET(UnsafeBufferUsageAttr) |
39 | WARNING_GADGET(DataInvocation) |
40 | WARNING_CONTAINER_GADGET(SpanTwoParamConstructor) // Uses of `std::span(arg0, arg1)` |
41 | FIXABLE_GADGET(ULCArraySubscript) // `DRE[any]` in an Unspecified Lvalue Context |
42 | FIXABLE_GADGET(DerefSimplePtrArithFixable) |
43 | FIXABLE_GADGET(PointerDereference) |
44 | FIXABLE_GADGET(UPCAddressofArraySubscript) // '&DRE[any]' in an Unspecified Pointer Context |
45 | FIXABLE_GADGET(UPCStandalonePointer) |
46 | FIXABLE_GADGET(UPCPreIncrement) // '++Ptr' in an Unspecified Pointer Context |
47 | FIXABLE_GADGET(UUCAddAssign) // 'Ptr += n' in an Unspecified Untyped Context |
48 | FIXABLE_GADGET(PtrToPtrAssignment) |
49 | FIXABLE_GADGET(CArrayToPtrAssignment) |
50 | FIXABLE_GADGET(PointerInit) |
51 | |
52 | #undef FIXABLE_GADGET |
53 | #undef WARNING_GADGET |
54 | #undef WARNING_CONTAINER_GADGET |
55 | #undef GADGET |
56 | |