[PATCH] D105421: [analyzer] Handle << operator for std::unique_ptr

Artem Dergachev via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Jul 7 12:26:41 PDT 2021


NoQ added a comment.

Yes, I think this totally works now!

Can you also add some tests?



================
Comment at: clang/lib/StaticAnalyzer/Checkers/SmartPtrModeling.cpp:85
+// Checks if RD has name in Names and is in std namespace
+bool hasStdClassWithName(const CXXRecordDecl *RD,
+                         const SmallVectorImpl<StringRef> &Names) {
----------------
This should be `static` right?


================
Comment at: clang/lib/StaticAnalyzer/Checkers/SmartPtrModeling.cpp:98
+
 // Define the inter-checker API.
 namespace clang {
----------------
I think the new functions that you've added aren't yet used in an inter-checker manner. Maybe keep them as `static` too until we have an actual use case?


================
Comment at: clang/lib/StaticAnalyzer/Checkers/SmartPtrModeling.cpp:221-222
+    const MemRegion *StreamThisRegion = StreamVal.getAsRegion();
+    assert(StreamThisRegion &&
+           "expected to retrieve this pointer of basic_ostream");
+    State =
----------------
Might also be an `UnknownVal` which doesn't have a region. It's hard to test because there doesn't exist a test in which `UnknownVal` appears for a good reason (they only appear for bad reasons) but I'd still rather bail out.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105421



More information about the cfe-commits mailing list