[PATCH] D22729: MPIBufferDerefCheck for Clang-Tidy

Alexander Droste via cfe-commits cfe-commits at lists.llvm.org
Mon Aug 1 05:03:17 PDT 2016


Alexander_Droste added a comment.

Hi, thanks for having a look!


================
Comment at: clang-tidy/mpi/BufferDerefCheck.cpp:63
@@ +62,3 @@
+    if (FuncClassifier.isReduceType(Identifier)) {
+      addBuffer(0);
+      addBuffer(1);
----------------
hokein wrote:
> Could you add some comments to describe what these statements do? It's confused when reading the magic number parameter. The same below.
Sure, I'll extend the comment.

================
Comment at: clang-tidy/mpi/BufferDerefCheck.cpp:109
@@ +108,3 @@
+      std::string IndirectionDesc;
+      for (int i = Indirections.size() - 1; i >= 0; --i) {
+        if (Indirections[i] == IndirectionType::Pointer) {
----------------
hokein wrote:
> size_t
Hmm, this loop iterates the indirections in reverse order and exits the loop if `i` gets smaller than 0. `size_t` would therefore not work. I think it's safe to assume that the number of indirections will not exceed `INT_MAX`. How about an explicit cast? I can't use `rbegin` and `rend`, as the current index is needed for:

```
if (i > 0) {
  IndirectionDesc += "->";
}
```


https://reviews.llvm.org/D22729





More information about the cfe-commits mailing list