[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 02:40:27 PDT 2024


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

>From 480be809832360293036b88b0fc46dad5838e88a Mon Sep 17 00:00:00 2001
From: Austin <zhenhangwang at huawei.com>
Date: Fri, 30 Aug 2024 15:21:12 +0800
Subject: [PATCH] fix kcfi doesn't take effect when callee function has no
 input parameter

---
 clang/lib/CodeGen/CodeGenFunction.cpp | 5 +++++
 1 file changed, 5 insertions(+)

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(



More information about the cfe-commits mailing list