[clang] [CodeGen] -fsanitize=alignment: add cl::opt sanitize-alignment-builtin to disable memcpy instrumentation (PR #69240)

Fangrui Song via cfe-commits cfe-commits at lists.llvm.org
Wed Oct 18 17:22:38 PDT 2023


================
@@ -66,6 +66,11 @@ using namespace clang;
 using namespace CodeGen;
 using namespace llvm;
 
+static llvm::cl::opt<bool> ClSanitizeAlignmentBuiltin(
+    "sanitize-alignment-builtin", llvm::cl::Hidden,
+    llvm::cl::desc("Instrument builtin functions for -fsanitize=alignment"),
+    llvm::cl::init(true));
+
----------------
MaskRay wrote:

I acknowledge that `cl::opt` is discouraged (`clang/lib` has very few of them). This is a temporary workaround (so that our users can perform cleanups) and should not be here for a too-long time. I'll revert this after ~two months, assuming that rolling update users (like us) have caught up on the change. Given how large our code base is and how few (relatively) problems identified, I reasonably expect that we don't really need a driver option or cc1 option.

I modeled this after `cl::opt<bool> ClSanitizeOnOptimizerEarlyEP` in `clang/lib/CodeGen/BackendUtil.cpp` and thought that cl::opt might look more experimental than a cc1 option...

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


More information about the cfe-commits mailing list