aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/CodeGen/CodeGenFunction.cpp
diff options
context:
space:
mode:
authorusama hameed <u_hameed@apple.com>2023-08-08 14:49:48 -0700
committerusama hameed <u_hameed@apple.com>2023-08-16 14:47:49 -0700
commit9afc57dcb2e5cd36ca1ddf0fee3efa958bfd4c2a (patch)
treee91763d40f31150ddcf87873d8297a712644a8f5 /clang/lib/CodeGen/CodeGenFunction.cpp
parent6f11750319719c46771ca32a0c7d8fbed9a24a93 (diff)
downloadllvm-9afc57dcb2e5cd36ca1ddf0fee3efa958bfd4c2a.zip
llvm-9afc57dcb2e5cd36ca1ddf0fee3efa958bfd4c2a.tar.gz
llvm-9afc57dcb2e5cd36ca1ddf0fee3efa958bfd4c2a.tar.bz2
[CodeGen][UBSan] Handle sugared QualTypes correctly in
getUBSanFunctionTypeHash. getUBSanFunctionTypeHash checks if a Type is a FunctionNoPrototype by calling isa<FunctionNoProtoType>(). This does not work correctly when the Type is wrapped in a sugar type such as an AttributedType. This patch fixes this by using isFunctionNoProtoType() function which removes sugar and returns the expected result. The added test is a sanity check that the compiler no longer crashes during compilation. It also compares the hash with and without the function attribute for both FunctionNoProtoType and FunctionProtoType. The hash remains the same for FunctionNoProtoType even with the addition of an attribute. rdar://113144087 Differential Revision: https://reviews.llvm.org/D157445
Diffstat (limited to 'clang/lib/CodeGen/CodeGenFunction.cpp')
-rw-r--r--clang/lib/CodeGen/CodeGenFunction.cpp2
1 files changed, 1 insertions, 1 deletions
diff --git a/clang/lib/CodeGen/CodeGenFunction.cpp b/clang/lib/CodeGen/CodeGenFunction.cpp
index 2000c4c..89138dd 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<FunctionNoProtoType>(Ty))
+ if (!Ty->isFunctionNoProtoType())
Ty = getContext().getFunctionTypeWithExceptionSpec(Ty, EST_None);
std::string Mangled;
llvm::raw_string_ostream Out(Mangled);