[PATCH] D13311: [clang-tidy] Add check cppcoreguidelines-pro-bounds-pointer-arithmetic

Aaron Ballman via cfe-commits cfe-commits at lists.llvm.org
Tue Oct 6 06:45:42 PDT 2015


aaron.ballman added inline comments.

================
Comment at: test/clang-tidy/cppcoreguidelines-pro-bounds-pointer-arithmetic.cpp:37
@@ +36,3 @@
+  q -= i;
+  // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: do not use pointer arithmetic
+  q -= ENUM_LITERAL;
----------------
I don't think this comment is "done" yet. I still don't know how this check is intended to handle code like that. Does it currently diagnose? Does it not diagnose? Should it diagnose?

================
Comment at: test/clang-tidy/cppcoreguidelines-pro-bounds-pointer-arithmetic.cpp:51
@@ +50,3 @@
+
+  i = p[1];
+  // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: do not use pointer arithmetic
----------------
How well does this handle code like:
```
void f(int i[], size_t s) {
  i[s - 1] = 0;
}
```
Does it diagnose, and should it?


http://reviews.llvm.org/D13311





More information about the cfe-commits mailing list