[PATCH] D13640: [clang-tidy] Add new check cppcoreguidelines-pro-bounds-array-to-pointer-decay

Aaron Ballman via cfe-commits cfe-commits at lists.llvm.org
Tue Oct 20 17:52:41 PDT 2015


aaron.ballman added inline comments.

================
Comment at: test/clang-tidy/cppcoreguidelines-pro-bounds-array-to-pointer-decay.cpp:13
@@ +12,3 @@
+
+void pointerfun(int* p);
+void arrayfun(int p[]);
----------------
> Currently, the diag is
> ```
> diag(MatchedCast->getExprLoc(), "do not (implicitly) convert an array to a pointer");
> ```
> should I make the parenthesis conditional?

The core guideline only says to diagnose for implicit decay, so I think we should not diagnose in this case.

Perhaps the wording could be, "do not implicitly decay an array into a pointer; consider using gsl::array_view or an explicit decay instead"?

================
Comment at: test/clang-tidy/cppcoreguidelines-pro-bounds-array-to-pointer-decay.cpp:18
@@ +17,3 @@
+
+void f()
+{
----------------
Formatting

================
Comment at: test/clang-tidy/cppcoreguidelines-pro-bounds-array-to-pointer-decay.cpp:41
@@ +40,3 @@
+
+const char* g()
+{
----------------
Formatting (may want to just run clang-format over the file).


http://reviews.llvm.org/D13640





More information about the cfe-commits mailing list