usama54321 updated this revision to Diff 548723. usama54321 added a comment.
Fix commit message and description, and added comment explaining the test. 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,4 @@ +// RUN: %clang_cc1 -emit-llvm -triple x86_64 -std=c17 -fsanitize=function %s -o /dev/null + +//Make sure compiler does not crash inside getUBSanFunctionTypeHash while compiling this +long __attribute__((ms_abi)) f() {} Index: clang/lib/CodeGen/CodeGenFunction.cpp =================================================================== --- clang/lib/CodeGen/CodeGenFunction.cpp +++ clang/lib/CodeGen/CodeGenFunction.cpp @@ -570,6 +570,9 @@ llvm::ConstantInt * CodeGenFunction::getUBSanFunctionTypeHash(QualType Ty) const { + if (isa<AttributedType>(Ty)) + Ty = Ty.getDesugaredType(getContext()); + // Remove any (C++17) exception specifications, to allow calling e.g. a // noexcept function through a non-noexcept pointer. if (!isa<FunctionNoProtoType>(Ty))
Index: clang/test/CodeGen/ubsan-function-attributed.c =================================================================== --- /dev/null +++ clang/test/CodeGen/ubsan-function-attributed.c @@ -0,0 +1,4 @@ +// RUN: %clang_cc1 -emit-llvm -triple x86_64 -std=c17 -fsanitize=function %s -o /dev/null + +//Make sure compiler does not crash inside getUBSanFunctionTypeHash while compiling this +long __attribute__((ms_abi)) f() {} Index: clang/lib/CodeGen/CodeGenFunction.cpp =================================================================== --- clang/lib/CodeGen/CodeGenFunction.cpp +++ clang/lib/CodeGen/CodeGenFunction.cpp @@ -570,6 +570,9 @@ llvm::ConstantInt * CodeGenFunction::getUBSanFunctionTypeHash(QualType Ty) const { + if (isa<AttributedType>(Ty)) + Ty = Ty.getDesugaredType(getContext()); + // Remove any (C++17) exception specifications, to allow calling e.g. a // noexcept function through a non-noexcept pointer. if (!isa<FunctionNoProtoType>(Ty))
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits