[PATCH] D21962: MPITypeMismatchCheck for Clang-Tidy

Alexander Kornienko via cfe-commits cfe-commits at lists.llvm.org
Tue Jul 19 18:07:12 PDT 2016


alexfh added inline comments.

================
Comment at: clang-tidy/misc/MpiTypeMismatchCheck.cpp:218
@@ +217,3 @@
+
+  StringRef TypedefToCompare = Typedef->getDecl()->getQualifiedNameAsString();
+  // Check if the typedef is known and not matching the MPI datatype.
----------------
Alexander_Droste wrote:
> alexfh wrote:
> > `getQualifiedNameAsString` returns a `std::string`, which will be destroyed at the end of this statement. `TypedefToCompare` will be a dangling reference then. Please change `StringRef` to `std::string` here.
> > 
> > Another question is whether you need `getQualifiedNameAsString`, which is rather expensive. Maybe you could use `getName` (it returns a `StringRef` and is relatively cheap) and additionally check that the name is in the global namespace?
> No, it seems I can also simply use `getName`. Why is it necessary to check if the name is in the global namespace? How would that check look like? 
Verifying that the name is in the global namespace would make the check stricter, but there might not be a realistic case, where it would prevent a false positive. We could try without it.


https://reviews.llvm.org/D21962





More information about the cfe-commits mailing list