[PATCH] D22729: MPIBufferDerefCheck for Clang-Tidy

Haojian Wu via cfe-commits cfe-commits at lists.llvm.org
Fri Aug 5 03:55:32 PDT 2016


hokein added inline comments.

================
Comment at: clang-tidy/mpi/BufferDerefCheck.cpp:87
@@ +86,3 @@
+    // Capture the depth and types of indirections for the passed buffer.
+    while (true) {
+      if (BufferType->isPointerType()) {
----------------
check whether `BufferType` is `nullptr`

================
Comment at: clang-tidy/mpi/BufferDerefCheck.cpp:110
@@ +109,3 @@
+      std::string IndirectionDesc;
+      for (int i = static_cast<int>(Indirections.size() - 1); i >= 0; --i) {
+        if (Indirections[i] == IndirectionType::Pointer) {
----------------
I think you can simplify the code as below:

```
for (auto Iter = Indirections.rbegin(); Iter != Indirections.rend(); ++Iter) {
   if (!IndirectionDesc.empty()) IndirectionDesc += "->";
   if (Indirections[i] == IndirectionType::Pointer) {
      IndirectionDesc += "pointer";
   } else {
      IndirectionDesc += "array";
   }
}
```

================
Comment at: docs/clang-tidy/checks/list.rst:113
@@ -112,2 +112,3 @@
    modernize-use-using
+   mpi-buffer-deref
    mpi-type-mismatch
----------------
Please also mention the check in `docs/ReleaseNotes.rst`. The same to `mpi-type-mismatch`.


https://reviews.llvm.org/D22729





More information about the cfe-commits mailing list