[PATCH] D129832: [sanitizer] Add "mainsrc" prefix to sanitizer special case list

Fangrui Song via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Jul 14 21:48:29 PDT 2022


MaskRay created this revision.
MaskRay added reviewers: Sanitizers, hctim, kstoimenov, vitalybuka.
Herald added a subscriber: StephenFan.
Herald added a project: All.
MaskRay requested review of this revision.
Herald added projects: clang, LLVM.
Herald added subscribers: llvm-commits, cfe-commits.

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 "mainsrc" 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 `mainsrc:a.c`.

  //--- a.h
  static inline int load(int *x) { return *x; }
  
  //--- a.c
  #include "a.h"
  int foo(void *x) { return load(x); }


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D129832

Files:
  clang/docs/SanitizerSpecialCaseList.rst
  clang/include/clang/Basic/NoSanitizeList.h
  clang/lib/Basic/NoSanitizeList.cpp
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/test/CodeGen/sanitize-ignorelist-mainsrc.c
  llvm/include/llvm/Support/SpecialCaseList.h

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D129832.444875.patch
Type: text/x-patch
Size: 6385 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20220715/f2fd1182/attachment.bin>


More information about the cfe-commits mailing list