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

Justin Stitt via cfe-commits cfe-commits at lists.llvm.org
Wed Oct 30 21:26:15 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 =
----------------
JustinStitt wrote:

We can't exactly drop the `no_sanitize` entirely as the `containsType()` check without a category specified will not match against types with the category `no_sanitize`. So if we removed the check from `isTypeIgnoredBySanitizer()` we would also have to remove `=no_sanitize` feature all together and just implicitly have this information from the lack of a category.

In short, let's keep the `no_sanitize` check and perhaps I could add some sort of caching system for these type checks? Keep in mind these only run when sanitizers are enabled and after a bunch of other checks too. The runtime hit should be minimal

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


More information about the cfe-commits mailing list