From 4722f1921ae4620d23c0531935d7488eaed5e9a8 Mon Sep 17 00:00:00 2001 From: Matthias Gehre Date: Tue, 17 Nov 2015 23:35:39 +0000 Subject: Fix bug 25362 "cppcoreguidelines-pro-bounds-array-to-pointer-decay does not consider const" Summary: The current matcher is implicitCastExpr(unless(hasParent(explicitCastExpr()))) but the AST in the bug is `-CXXStaticCastExpr 0x2bb64f8 'void *const *' static_cast `-ImplicitCastExpr 0x2bb64e0 'void *const *' `-ImplicitCastExpr 0x2bb64c8 'void **' `-DeclRefExpr 0x2bb6458 'void *[2]' lvalue Var 0x2bb59d0 'addrlist' 'void *[2]' i.e. an ImplicitCastExpr (const cast) between decay and explicit cast. Reviewers: alexfh, sbenza, bkramer, aaron.ballman Subscribers: cfe-commits Differential Revision: http://reviews.llvm.org/D14517 llvm-svn: 253399 --- .../cppcoreguidelines-pro-bounds-array-to-pointer-decay.cpp | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'clang-tools-extra/test/clang-tidy/cppcoreguidelines-pro-bounds-array-to-pointer-decay.cpp') diff --git a/clang-tools-extra/test/clang-tidy/cppcoreguidelines-pro-bounds-array-to-pointer-decay.cpp b/clang-tools-extra/test/clang-tidy/cppcoreguidelines-pro-bounds-array-to-pointer-decay.cpp index 13fd8a22142..ce192805dda 100644 --- a/clang-tools-extra/test/clang-tidy/cppcoreguidelines-pro-bounds-array-to-pointer-decay.cpp +++ b/clang-tools-extra/test/clang-tidy/cppcoreguidelines-pro-bounds-array-to-pointer-decay.cpp @@ -39,3 +39,9 @@ void f() { const char *g() { return "clang"; // OK, decay string literal to pointer } + +void f2(void *const *); +void bug25362() { + void *a[2]; + f2(static_cast(a)); // OK, explicit cast +} -- cgit v1.2.3