[PATCH] D157445: [CodeGen][UBSan] Add support for handling attributed functions in getUBSanFunctionTypeHash.
Usama Hameed via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Tue Aug 15 14:14:27 PDT 2023
usama54321 updated this revision to Diff 550475.
usama54321 retitled this revision from " [CodeGen][UBSan] Add support for handling attributed functions in getUBSanFunctionTypeHash." to "[CodeGen][UBSan] Add support for handling attributed functions in getUBSanFunctionTypeHash.".
usama54321 added a comment.
Updated PR according to feedback
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D157445/new/
https://reviews.llvm.org/D157445
Files:
clang/lib/CodeGen/CodeGenFunction.cpp
clang/test/CodeGen/ubsan-function-attributed.c
Index: clang/test/CodeGen/ubsan-function-attributed.c
===================================================================
--- /dev/null
+++ clang/test/CodeGen/ubsan-function-attributed.c
@@ -0,0 +1,13 @@
+// RUN: %clang_cc1 -S -triple x86_64 -std=c17 -fsanitize=function %s -o - | FileCheck %s --check-prefixes=CHECK
+
+// CHECK: .long 248076293
+void __attribute__((ms_abi)) f(void) {}
+
+// CHECK: .long 905068220
+void g(void) {}
+
+// CHECK: .long 1717976574
+void __attribute__((ms_abi)) f_no_prototype() {}
+
+// CHECK: .long 1717976574
+void g_no_prototype() {}
Index: clang/lib/CodeGen/CodeGenFunction.cpp
===================================================================
--- clang/lib/CodeGen/CodeGenFunction.cpp
+++ clang/lib/CodeGen/CodeGenFunction.cpp
@@ -572,7 +572,7 @@
CodeGenFunction::getUBSanFunctionTypeHash(QualType Ty) const {
// Remove any (C++17) exception specifications, to allow calling e.g. a
// noexcept function through a non-noexcept pointer.
- if (!isa<FunctionNoProtoType>(Ty))
+ if (!Ty->isFunctionNoProtoType())
Ty = getContext().getFunctionTypeWithExceptionSpec(Ty, EST_None);
std::string Mangled;
llvm::raw_string_ostream Out(Mangled);
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D157445.550475.patch
Type: text/x-patch
Size: 1193 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20230815/7e34a3ab/attachment-0001.bin>
More information about the cfe-commits
mailing list