aboutsummaryrefslogtreecommitdiffstats
path: root/build/plugins/suppressions.py
blob: a661e8a621f42697bdd1f836275cdca3902fa183 (plain) (blame)
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
def onsuppressions(unit, *args):
    """
    SUPPRESSIONS() - allows to specify files with suppression notation which will be used by
    address, leak or thread sanitizer runtime by default.
    Use asan.supp filename for address sanitizer, lsan.supp for leak sanitizer,
    ubsan.supp for undefined behavior sanitizer and tsan.supp for thread sanitizer
    suppressions respectively.
    See https://clang.llvm.org/docs/AddressSanitizer.html#suppressing-memory-leaks
    for details.
    """
    import os

    valid = ("asan.supp", "tsan.supp", "lsan.supp", "ubsan.supp")

    if unit.get("SANITIZER_TYPE") in ("leak", "address", "thread", "undefined"):
        for x in args:
            if os.path.basename(x) not in valid:
                unit.message(
                    [
                        'error',
                        "Invalid suppression filename: {} (any of the following is expected: {})".format(x, valid),
                    ]
                )
                return
        unit.onsrcs(["GLOBAL"] + list(args))