Szelethus added inline comments.

================
Comment at: lib/StaticAnalyzer/Checkers/PointerSortingChecker.cpp:91-100
+  const QualType IterTy = CE->getArg(0)->getType();
+  const RecordDecl *RD =
+    IterTy->getUnqualifiedDesugaredType()->getAsCXXRecordDecl();
+
+  if (RD->field_empty())
+    return;
+
----------------
NoQ wrote:
> This heuristic ("the argument of `std::sort` is //a class whose first field 
> is of pointer type//") is quite wonky, do you have a plan on how to make it 
> more precise?
```
template< class RandomIt >
void sort( RandomIt first, RandomIt last );
```
Since `RandomIt` must satisfy [[ 
https://en.cppreference.com/w/cpp/named_req/RandomAccessIterator | 
RandomAccesIterator ]], maybe you could obtain the value type with 
`std::iterator_traits<It>::value_type`, and check whether it's a pointer type.


Repository:
  rC Clang

https://reviews.llvm.org/D50488



_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to