[PATCH] D12761: MPI-Checker patch for Clang Static Analyzer

Alexander Droste via cfe-commits cfe-commits at lists.llvm.org
Sat Sep 12 05:10:04 PDT 2015


Alexander_Droste added inline comments.

================
Comment at: tools/clang/lib/StaticAnalyzer/Checkers/MPI-Checker/Container.hpp:10-11
@@ +9,4 @@
+///
+/// \file
+/// This file defines convenience templates for C++ container class usage.
+///
----------------
gribozavr wrote:
> This file re-invents a lot of APIs that are currently under review by the C++ committee under the Ranges effort.  I think most of the wrappers are more or less trivial and should use STL directly, or the wrappers should match exactly the currently proposed STL APIs.
Ok, I'll try to mimic the API of the proposal. Can I keep the `cont::` namespace?

================
Comment at: tools/clang/lib/StaticAnalyzer/Checkers/MPI-Checker/Container.hpp:88-109
@@ +87,24 @@
+
+/// \brief Deletes element at given index.
+///
+/// \param container
+/// \param index
+template <typename T> void eraseIndex(T &container, size_t idx) {
+  container.erase(container.begin() + idx);
+}
+
+/// \brief Sort with default criterion.
+///
+/// \param container
+template <typename T> void sort(T &container) {
+  std::sort(container.begin(), container.end());
+}
+
+/// \brief Sort by given predicate.
+///
+/// \param container
+/// \param predicate
+template <typename T, typename P> void sortPred(T &container, P predicate) {
+  std::sort(container.begin(), container.end(), predicate);
+}
+
----------------
gribozavr wrote:
> I question the value of such trivial wrappers.
I like to use them because they make things a little bit more compact. 
`sort(container.begin(), container.end(), predicate)`
vs.
`sortPred(container, predicate)`


http://reviews.llvm.org/D12761





More information about the cfe-commits mailing list