[llvm-branch-commits] [clang] [NFC][Clang][CFI] Pass SourceLocation to EmitVTableTypeCheckedLoad (PR #241637)
Vitaly Buka via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Wed Nov 11 19:05:16 PST 2026
https://github.com/vitalybuka created https://github.com/llvm/llvm-project/pull/241637
Thread call-site `SourceLocation` into `EmitVTableTypeCheckedLoad` so
non-trapping `cfi-vcall` checks can emit diagnostic source locations.
Assisted-by: Gemini
>From b7ec2136822c8e662d66fda29dea7d0e84992521 Mon Sep 17 00:00:00 2001
From: Vitaly Buka <vitalybuka at google.com>
Date: Wed, 11 Nov 2026 19:05:04 -0800
Subject: [PATCH] [spr] update
Created using spr 2.0.0-beta.2
---
clang/lib/CodeGen/CGClass.cpp | 2 +-
clang/lib/CodeGen/CodeGenFunction.h | 3 ++-
clang/lib/CodeGen/ItaniumCXXABI.cpp | 2 +-
clang/lib/CodeGen/MicrosoftCXXABI.cpp | 3 ++-
4 files changed, 6 insertions(+), 4 deletions(-)
diff --git a/clang/lib/CodeGen/CGClass.cpp b/clang/lib/CodeGen/CGClass.cpp
index 95e050fc9b6188..8bba99f0548aa3 100644
--- a/clang/lib/CodeGen/CGClass.cpp
+++ b/clang/lib/CodeGen/CGClass.cpp
@@ -2993,7 +2993,7 @@ bool CodeGenFunction::ShouldEmitVTableTypeCheckedLoad(const CXXRecordDecl *RD) {
llvm::Value *CodeGenFunction::EmitVTableTypeCheckedLoad(
const CXXRecordDecl *RD, llvm::Value *VTable, llvm::Type *VTableTy,
- uint64_t VTableByteOffset) {
+ uint64_t VTableByteOffset, SourceLocation /*Loc*/) {
auto CheckOrdinal = SanitizerKind::SO_CFIVCall;
auto CheckHandler = SanitizerHandler::CFICheckFail;
SanitizerDebugLocation SanScope(this, {CheckOrdinal}, CheckHandler);
diff --git a/clang/lib/CodeGen/CodeGenFunction.h b/clang/lib/CodeGen/CodeGenFunction.h
index 79ddc79ff6c347..f3c3ef3b94da0a 100644
--- a/clang/lib/CodeGen/CodeGenFunction.h
+++ b/clang/lib/CodeGen/CodeGenFunction.h
@@ -2660,7 +2660,8 @@ class CodeGenFunction : public CodeGenTypeCache {
llvm::Value *EmitVTableTypeCheckedLoad(const CXXRecordDecl *RD,
llvm::Value *VTable,
llvm::Type *VTableTy,
- uint64_t VTableByteOffset);
+ uint64_t VTableByteOffset,
+ SourceLocation Loc);
/// EnterDtorCleanups - Enter the cleanups necessary to complete the
/// given phase of destruction for a destructor. The end result
diff --git a/clang/lib/CodeGen/ItaniumCXXABI.cpp b/clang/lib/CodeGen/ItaniumCXXABI.cpp
index 5bbb742a7b1efa..3fbee4dc6bb031 100644
--- a/clang/lib/CodeGen/ItaniumCXXABI.cpp
+++ b/clang/lib/CodeGen/ItaniumCXXABI.cpp
@@ -2264,7 +2264,7 @@ CGCallee ItaniumCXXABI::getVirtualFunctionPointer(CodeGenFunction &CGF,
if (!Schema && CGF.ShouldEmitVTableTypeCheckedLoad(MethodDecl->getParent())) {
VFunc = CGF.EmitVTableTypeCheckedLoad(MethodDecl->getParent(), VTable,
- PtrTy, ByteOffset);
+ PtrTy, ByteOffset, Loc);
} else {
CGF.EmitTypeMetadataCodeForVCall(MethodDecl->getParent(), VTable, Loc);
diff --git a/clang/lib/CodeGen/MicrosoftCXXABI.cpp b/clang/lib/CodeGen/MicrosoftCXXABI.cpp
index 89447f4f97a03d..7a95ca2f50fdd6 100644
--- a/clang/lib/CodeGen/MicrosoftCXXABI.cpp
+++ b/clang/lib/CodeGen/MicrosoftCXXABI.cpp
@@ -2049,7 +2049,8 @@ CGCallee MicrosoftCXXABI::getVirtualFunctionPointer(CodeGenFunction &CGF,
getObjectWithVPtr(), VTable, Ty,
ML.Index *
CGM.getContext().getTargetInfo().getPointerWidth(LangAS::Default) /
- 8);
+ 8,
+ Loc);
} else {
if (CGM.getCodeGenOpts().PrepareForLTO)
CGF.EmitTypeMetadataCodeForVCall(getObjectWithVPtr(), VTable, Loc);
More information about the llvm-branch-commits
mailing list