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

Aaron Ballman via cfe-commits cfe-commits at lists.llvm.org
Fri Oct 2 09:11:24 PDT 2015


aaron.ballman added inline comments.

================
Comment at: clang-tidy/cppcoreguidelines/ProBoundsPointerArithmeticCheck.cpp:48
@@ +47,3 @@
+  diag(MatchedExpr->getExprLoc(),
+       "do not use pointer arithmetic (C++ Core Guidelines, rule Bounds.1)");
+}
----------------
Can elide the parenthetical.

================
Comment at: clang-tidy/cppcoreguidelines/ProBoundsPointerArithmeticCheck.h:18
@@ +17,3 @@
+
+/// Flags all kinds of pointer arithmetic
+///
----------------
This could be a bit more usefully descriptive. ;-)

================
Comment at: test/clang-tidy/cppcoreguidelines-pro-bounds-pointer-arithmetic.cpp:36
@@ +35,3 @@
+  // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: do not use pointer arithmetic (C++ Core Guidelines, rule Bounds.1) [cppcoreguidelines-pro-bounds-pointer-arithmetic]
+}
+
----------------
How does this check handle code like:
```
struct S {
  operator int() const;  
};

void f(S &s) {
  int *i;
  i = i + s;
}
```

================
Comment at: test/clang-tidy/cppcoreguidelines-pro-bounds-pointer-arithmetic.cpp:38
@@ +37,3 @@
+
+void okey() {
+  int a[3];
----------------
s/okey/okay

;-)


http://reviews.llvm.org/D13311





More information about the cfe-commits mailing list