llvmorg-github-actions[bot] wrote:

<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-clang-driver

Author: Jinseok Kim (JawsKim)

<details>
<summary>Changes</summary>

`-fsanitize-kcfi-arity` was still processed after KCFI had been disabled with 
`-fno-sanitize=kcfi`.

This change only processes `-fsanitize-kcfi-arity` when KCFI remains enabled in 
the final sanitizer set, avoiding both the unsupported target diagnostic and 
forwarding the option to cc1.

Adds a regression test for this case.

---
Full diff: https://github.com/llvm/llvm-project/pull/211749.diff


2 Files Affected:

- (modified) clang/lib/Driver/SanitizerArgs.cpp (+1-1) 
- (modified) clang/test/Driver/fsanitize-cfi.c (+4) 


``````````diff
diff --git a/clang/lib/Driver/SanitizerArgs.cpp 
b/clang/lib/Driver/SanitizerArgs.cpp
index c77ba78122a81..7bbb3c985b185 100644
--- a/clang/lib/Driver/SanitizerArgs.cpp
+++ b/clang/lib/Driver/SanitizerArgs.cpp
@@ -1565,7 +1565,7 @@ void SanitizerArgs::addArgs(const ToolChain &TC, const 
llvm::opt::ArgList &Args,
   if (CfiICallNormalizeIntegers)
     CmdArgs.push_back("-fsanitize-cfi-icall-experimental-normalize-integers");
 
-  if (KcfiArity) {
+  if (KcfiArity && Sanitizers.has(SanitizerKind::KCFI)) {
     if (!TC.getTriple().isOSLinux() || !TC.getTriple().isArch64Bit()) {
       TC.getDriver().Diag(clang::diag::err_drv_kcfi_arity_unsupported_target)
           << TC.getTriple().str();
diff --git a/clang/test/Driver/fsanitize-cfi.c 
b/clang/test/Driver/fsanitize-cfi.c
index c58ad3b8c2f1c..a9d7809bb524a 100644
--- a/clang/test/Driver/fsanitize-cfi.c
+++ b/clang/test/Driver/fsanitize-cfi.c
@@ -96,3 +96,7 @@
 
 // RUN: not %clang --target=x86_64-linux-gnu -fsanitize=kcfi,function %s -### 
2>&1 | FileCheck %s --check-prefix=CHECK-KCFI-FUNCTION
 // CHECK-KCFI-FUNCTION: error: invalid argument '-fsanitize=kcfi' not allowed 
with '-fsanitize=function'
+
+// RUN: %clang --target=i386-linux-gnu -c %s -### -fsanitize=address,kcfi 
-fno-sanitize=kcfi -fsanitize-kcfi-arity 2>&1 | FileCheck %s 
--check-prefix=CHECK-KCFI-ARITY-DISABLED --implicit-check-not=error: 
--implicit-check-not=-fsanitize-kcfi-arity
+
+// CHECK-KCFI-ARITY-DISABLED: "-cc1"{{.*}}"-fsanitize=address"

``````````

</details>


https://github.com/llvm/llvm-project/pull/211749
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to