[PATCH] D97183: [analyzer] Add NoteTag for smart-ptr get()

Artem Dergachev via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon May 3 13:55:42 PDT 2021


NoQ added inline comments.


================
Comment at: clang/lib/StaticAnalyzer/Checkers/SmartPtrModeling.cpp:177-179
+            const Environment &Env = State->getEnvironment();
+            EnvironmentEntry Entry(Sub, Node->getLocationContext());
+            const SVal ExprVal = Env.getSVal(Entry, Bldr);
----------------
`SVal ExprVal = State->getSVal(Sub, Node->getLocationContext());`.


================
Comment at: clang/lib/StaticAnalyzer/Checkers/SmartPtrModeling.cpp:197-201
+        if (const auto *BO = llvm::dyn_cast<BinaryOperator>(S)) {
+          if (BO->getOpcode() == BO_Assign) {
+            const Expr *LHS = BO->getLHS();
+
+            if (const auto *DeclRef = llvm::dyn_cast<DeclRefExpr>(LHS)) {
----------------
Your visitor doesn't need to track raw pointers through raw variables. `trackExpressionValue()` is fully capable of doing this. The problem only becomes checker-specific when the connection between smart pointers and raw pointers is involved. I meant assignments between two //smart// pointers.

Maybe even reduce the visitor to only the if-statement case and have it check //all interesting// smart pointers instead of a specific smart pointer. Propagation of interestingness across smart pointers can be handled by note tags for move/copy assignmnets and constructors.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D97183



More information about the cfe-commits mailing list