steakhal added a comment.

Consider adding a test case demonstrating if the checker recognizes and 
suppresses the check if there are multiple variables referring to the memory 
being reallocated.
If the check does not handle that case, we should probably state this 
limitation explicitly. And marking the corresponding test case with a FIXME.

I was thinking about something like this:

  void escape(void *);
  void foo(void *p) {
    void *q = p;
    p = realloc(p, 10); // no-warning
    escape(q);
  }
  void bar(void *p) {
    p = realloc(p, 10); // warn: ...
    void *q = p;
    escape(q);
  }

The `MallocOverflowCheck` does something similar. It uses 
`isBeforeInTranslationUnit()`.



================
Comment at: 
clang-tools-extra/clang-tidy/bugprone/SuspiciousReallocUsageCheck.cpp:20-21
+namespace {
+class IsSamePtrExpr : public clang::StmtVisitor<IsSamePtrExpr, bool> /*,
+                         public clang::DeclVisitor<IsSamePtrExpr, bool>*/
+{
----------------
Commented code?


================
Comment at: 
clang-tools-extra/clang-tidy/bugprone/SuspiciousReallocUsageCheck.cpp:23
+{
+  /// The other expression to compare with.
+  /// This variable is used to pass the data from a \c check function to any of
----------------
against


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D133119/new/

https://reviews.llvm.org/D133119

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

Reply via email to