[clang] [clang][kCFI] Warn on unsanitized unprototyped indirect calls (PR #243285)
Eli Friedman via cfe-commits
cfe-commits at lists.llvm.org
Mon Nov 16 17:01:58 PST 2026
================
@@ -6427,8 +6404,15 @@ RValue CodeGenFunction::EmitCall(const CGFunctionInfo &CallInfo,
getBundlesForFunclet(CalleePtr);
if (SanOpts.has(SanitizerKind::KCFI) &&
- !isa_and_nonnull<FunctionDecl>(TargetDecl))
+ !isa_and_nonnull<FunctionDecl>(TargetDecl)) {
EmitKCFIOperandBundle(ConcreteCallee, BundleList);
+ // An indirect call through a function type without a prototype (e.g.
+ // pre-C23 `int (*)()`) isn't checked.
+ if (isa_and_nonnull<FunctionNoProtoType>(
+ ConcreteCallee.getAbstractInfo().getCalleeFunctionType()) &&
+ !isa<llvm::Constant>(CalleePtr->stripPointerCasts()))
----------------
efriedma-quic wrote:
Is stripPointerCasts doing anything useful here?
https://github.com/llvm/llvm-project/pull/243285
More information about the cfe-commits
mailing list