aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/CodeGen/CodeGenFunction.cpp
diff options
context:
space:
mode:
authorMatheus Izvekov <mizvekov@gmail.com>2023-10-02 19:09:39 +0200
committerGitHub <noreply@github.com>2023-10-02 19:09:39 +0200
commit9c89b29555a7ccfc3942340f558c3bbea8d10532 (patch)
treed295a8d382b584c7a0d0bc2833c348c743231953 /clang/lib/CodeGen/CodeGenFunction.cpp
parentf776e0b6df611d973db1778256dfcd1dc37128c5 (diff)
downloadllvm-9c89b29555a7ccfc3942340f558c3bbea8d10532.zip
llvm-9c89b29555a7ccfc3942340f558c3bbea8d10532.tar.gz
llvm-9c89b29555a7ccfc3942340f558c3bbea8d10532.tar.bz2
-fsanitize=function: fix MSVC hashing to sugared type (#66816)
Hashing the sugared type instead of the canonical type meant that a simple example like this would always fail under MSVC: ``` static auto l() {} int main() { auto a = l; a(); } ``` `clang --target=x86_64-pc-windows-msvc -fno-exceptions -fsanitize=function -g -O0 -fuse-ld=lld -o test.exe test.cc` produces: ``` test.cc:4:3: runtime error: call to function l through pointer to incorrect function type 'void (*)()' ```
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 3eb4cb8..9b21f42 100644
--- a/clang/lib/CodeGen/CodeGenFunction.cpp
+++ b/clang/lib/CodeGen/CodeGenFunction.cpp
@@ -576,7 +576,7 @@ CodeGenFunction::getUBSanFunctionTypeHash(QualType Ty) const {
Ty = getContext().getFunctionTypeWithExceptionSpec(Ty, EST_None);
std::string Mangled;
llvm::raw_string_ostream Out(Mangled);
- CGM.getCXXABI().getMangleContext().mangleTypeName(Ty, Out, false);
+ CGM.getCXXABI().getMangleContext().mangleCanonicalTypeName(Ty, Out, false);
return llvm::ConstantInt::get(
CGM.Int32Ty, static_cast<uint32_t>(llvm::xxh3_64bits(Mangled)));
}