[clang] [Safe Buffers] Fix a small bug recently found (PR #102953)

2024-08-13 Thread Ziqing Luo via cfe-commits
@@ -404,7 +404,7 @@ AST_MATCHER(CXXConstructExpr, isSafeSpanTwoParamConstruct) { if (Arg0Ty->isConstantArrayType()) { const APSInt ConstArrSize = -APSInt(cast(Arg0Ty)->getSize()); +APSInt(cast(Arg0Ty.getCanonicalType())->getSize()); ziqin

[clang] [Safe Buffers] Fix a small bug recently found (PR #102953)

2024-08-13 Thread Ziqing Luo via cfe-commits
https://github.com/ziqingluo-90 updated https://github.com/llvm/llvm-project/pull/102953 >From d6c860de3facc37f27b17a26a01e48bc02b4659b Mon Sep 17 00:00:00 2001 From: ziqingluo-90 Date: Mon, 12 Aug 2024 11:57:17 -0700 Subject: [PATCH] [-Wunsafe-buffer-usage] Fix a bug in the ASTMatcher for span

[clang] [Safe Buffers] Fix a small bug recently found (PR #102953)

2024-08-13 Thread Artem Dergachev via cfe-commits
@@ -404,7 +404,7 @@ AST_MATCHER(CXXConstructExpr, isSafeSpanTwoParamConstruct) { if (Arg0Ty->isConstantArrayType()) { const APSInt ConstArrSize = -APSInt(cast(Arg0Ty)->getSize()); +APSInt(cast(Arg0Ty.getCanonicalType())->getSize()); haoNo

[clang] [Safe Buffers] Fix a small bug recently found (PR #102953)

2024-08-13 Thread Artem Dergachev via cfe-commits
haoNoQ wrote: Ah classic! Forgotten `.getCanonicalType()`s always get me. https://github.com/llvm/llvm-project/pull/102953 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [Safe Buffers] Fix a small bug recently found (PR #102953)

2024-08-12 Thread via cfe-commits
llvmbot wrote: @llvm/pr-subscribers-clang-analysis Author: Ziqing Luo (ziqingluo-90) Changes `QualType::isConstantArrayType()` checks canonical type. So a following cast should be applied to canonical type as well: ``` if (Ty->isConstantArrayType()) cast(Ty.getCanoni

[clang] [Safe Buffers] Fix a small bug recently found (PR #102953)

2024-08-12 Thread Ziqing Luo via cfe-commits
https://github.com/ziqingluo-90 created https://github.com/llvm/llvm-project/pull/102953 `QualType::isConstantArrayType()` checks canonical type. So a following cast should be applied to canonical type as well: ``` if (Ty->isConstantArrayType()) cast(Ty.getCanonicalType()); // cast(Ty) is