[all-commits] [llvm/llvm-project] 0d5a62: [sanitizer] Add "mainfile" prefix to sanitizer spe...

Fangrui Song via All-commits all-commits at lists.llvm.org
Fri Jul 15 10:39:39 PDT 2022


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 0d5a62faca5924c5a197faa946b5b78b3d80a0b2
      https://github.com/llvm/llvm-project/commit/0d5a62faca5924c5a197faa946b5b78b3d80a0b2
  Author: Fangrui Song <i at maskray.me>
  Date:   2022-07-15 (Fri, 15 Jul 2022)

  Changed paths:
    M clang/docs/SanitizerSpecialCaseList.rst
    M clang/include/clang/Basic/NoSanitizeList.h
    M clang/lib/Basic/NoSanitizeList.cpp
    M clang/lib/CodeGen/CodeGenModule.cpp
    A clang/test/CodeGen/sanitize-ignorelist-mainfile.c
    M llvm/include/llvm/Support/SpecialCaseList.h

  Log Message:
  -----------
  [sanitizer] Add "mainfile" prefix to sanitizer special case list

When an issue exists in the main file (caller) instead of an included file
(callee), using a `src` pattern applying to the included file may be
inappropriate if it's the caller's responsibility. Add `mainfile` prefix to check
the main filename.

For the example below, the issue may reside in a.c (foo should not be called
with a misaligned pointer or foo should switch to an unaligned load), but with
`src` we can only apply to the innocent callee a.h. With this patch we can use
the more appropriate `mainfile:a.c`.
```
//--- a.h
// internal linkage
static inline int load(int *x) { return *x; }

//--- a.c, -fsanitize=alignment
#include "a.h"
int foo(void *x) { return load(x); }
```

See the updated clang/docs/SanitizerSpecialCaseList.rst for a caveat due
to C++ vague linkage functions.

Reviewed By: #sanitizers, kstoimenov, vitalybuka

Differential Revision: https://reviews.llvm.org/D129832




More information about the All-commits mailing list