[PATCH] D106296: [analyzer] Fix for faulty namespace test in SmartPtrModelling

Deep Majumder via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Jul 21 05:57:25 PDT 2021


RedDocMD added inline comments.


================
Comment at: clang/lib/StaticAnalyzer/Checkers/SmartPtrModeling.cpp:291
   // we can try this function
-  if (Call.getNumArgs() == 2 &&
-      Call.getDecl()->getDeclContext()->isStdNamespace())
-    if (smartptr::isStdSmartPtr(Call.getArgExpr(0)) ||
-        smartptr::isStdSmartPtr(Call.getArgExpr(1)))
-      if (handleComparisionOp(Call, C))
-        return true;
-
-  if (isStdOstreamOperatorCall(Call))
+  if (ModelSmartPtrDereference && isPotentiallyComparisionOpCall(Call))
+    if (handleComparisionOp(Call, C))
----------------
xazax.hun wrote:
> RedDocMD wrote:
> > xazax.hun wrote:
> > > I'd prefer not repeating the `ModelSmartPtrDereference` check.
> > I don't think we can do that, since the `isBoolConversion()` check has a branch which is executed when `ModelSmartPtrDereference` is false.
> That function is way below. I was just thinking about merging the first two check. 
Looks like I missed this. Sorry!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D106296



More information about the cfe-commits mailing list