[clang] [Clang] Implement labelled type filtering for overflow/truncation sanitizers w/ SSCLs (PR #107332)

Vitaly Buka via cfe-commits cfe-commits at lists.llvm.org
Thu Oct 31 00:18:10 PDT 2024


================
@@ -831,6 +831,28 @@ ASTContext::getCanonicalTemplateTemplateParmDecl(
   return CanonTTP;
 }
 
+/// Check if a type can have its sanitizer instrumentation elided.
+/// Determine this by its presence in a SCL alongside its specified categories.
+/// For example:
+/// ignorelist.txt>
+/// [{unsigned-integer-overflow,signed-integer-overflow}]
+/// type:*=no_sanitize
+/// type:size_t=sanitize
+/// <ignorelist.txt
+/// Supplying the above ignorelist.txt will disable overflow sanitizer
+/// instrumentation for all types except "size_t".
+bool ASTContext::isTypeIgnoredBySanitizer(const SanitizerMask &Mask,
+                                          const QualType &Ty) const {
+  bool sanitizeType =
+      NoSanitizeL->containsType(Mask, Ty.getAsString(), "sanitize");
+
+  bool noSanitizeType =
----------------
vitalybuka wrote:

> Out of curiosity: What is a printing policy?

Not sure, but other users of containsType use policy.

> We do not want the canonical type, we should support typedefs.

Can you add a test to control that? with current patch canonical works.

Actually I was inspired by the patch to add -fsanitize=enum type ignore list, and 
without canonical `void f(enum MyEnum e)` is matched as `enum MyEnum`.


https://github.com/llvm/llvm-project/pull/107332


More information about the cfe-commits mailing list