[PATCH] D22729: MPIBufferDerefCheck for Clang-Tidy

Alexander Droste via cfe-commits cfe-commits at lists.llvm.org
Fri Aug 5 06:27:28 PDT 2016


Alexander_Droste marked 4 inline comments as done.

================
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()) {
----------------
hokein wrote:
> check whether `BufferType` is `nullptr`
Null pointer types are not added to the `BufferType` vector in `addBuffer`.
```
if (CE->getArg(BufferIdx)->isNullPointerConstant(
            *Result.Context, Expr::NPC_ValueDependentIsNull) ||
```

================
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) {
----------------
hokein wrote:
> 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";
>    }
> }
> ```
Good idea, that looks better.

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


https://reviews.llvm.org/D22729





More information about the cfe-commits mailing list