[clang] fix kcfi doesn't take effect when callee function has no input parameter (PR #106677)

via cfe-commits cfe-commits at lists.llvm.org
Fri Aug 30 00:24:11 PDT 2024


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-clang

@llvm/pr-subscribers-clang-codegen

Author: Austin (Zhenhang1213)

<details>
<summary>Changes</summary>

fix #<!-- -->106344

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


1 Files Affected:

- (modified) clang/lib/CodeGen/CodeGenFunction.cpp (+5) 


``````````diff
diff --git a/clang/lib/CodeGen/CodeGenFunction.cpp b/clang/lib/CodeGen/CodeGenFunction.cpp
index c89eaa0f4e3bfc..4d3fb780243022 100644
--- a/clang/lib/CodeGen/CodeGenFunction.cpp
+++ b/clang/lib/CodeGen/CodeGenFunction.cpp
@@ -2813,6 +2813,11 @@ void CodeGenFunction::EmitKCFIOperandBundle(
       Callee.getAbstractInfo().getCalleeFunctionProtoType();
   if (FP)
     Bundles.emplace_back("kcfi", CGM.CreateKCFITypeId(FP->desugar()));
+  else {
+    ASTContext &context = this->getContext();
+    QualType voidType = context.VoidTy;
+    Bundles.emplace_back("kcfi", CGM.CreateKCFITypeId(voidType));
+  }
 }
 
 llvm::Value *CodeGenFunction::FormAArch64ResolverCondition(

``````````

</details>


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


More information about the cfe-commits mailing list