diff --git a/clang/lib/CodeGen/CodeGenFunction.cpp b/clang/lib/CodeGen/CodeGenFunction.cpp index 2000c4ce02c95..89138ddbdc0bc 100644 --- a/clang/lib/CodeGen/CodeGenFunction.cpp +++ b/clang/lib/CodeGen/CodeGenFunction.cpp @@ -572,7 +572,7 @@ llvm::ConstantInt * 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(Ty)) + if (!Ty->isFunctionNoProtoType()) Ty = getContext().getFunctionTypeWithExceptionSpec(Ty, EST_None); std::string Mangled; llvm::raw_string_ostream Out(Mangled); diff --git a/clang/test/CodeGen/ubsan-function-attributed.c b/clang/test/CodeGen/ubsan-function-attributed.c new file mode 100644 index 0000000000000..c979f161fc922 --- /dev/null +++ b/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() {}