[PATCH] D95877: [analyzer] Fix static_cast on pointer-to-member handling

Deep Majumder via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Feb 5 10:00:00 PST 2021


RedDocMD added inline comments.


================
Comment at: clang/lib/StaticAnalyzer/Core/BasicValueFactory.cpp:184
+  llvm::SmallPtrSet<QualType, 16> BaseSpecSeen;
+  for (const auto &BaseSpec : BaseSpecList) {
+    auto BaseType = BaseSpec->getType();
----------------
vsavchenko wrote:
> vsavchenko wrote:
> > LLVM Coding Style calls for very limited use of `auto`, so here and the next line would be better with actual types.
> Let's also reiterate on using functional-style predicates and reimplement it in terms of `llvm::all_of` or `llvm::none_of`.
I couldn't do this since calling llvm::all_of (or std::all_of) on an ImmutableList causes a compile error saying that the function std::__iterator_category cannot be found for its iterator.


================
Comment at: clang/test/Analysis/pointer-to-member.cpp:314-333
+// namespace testReinterpretCasting {
+// struct Base {
+//   int field;
+// };
+//
+// struct Derived : public Base {};
+//
----------------
vsavchenko wrote:
> RedDocMD wrote:
> > vsavchenko wrote:
> > > Uncomment it, and expect the actual current result.  This is where `TODO` will come in handy.
> > > Uncomment it, and expect the actual current result.  This is where `TODO` will come in handy.
> > Will do it.
> > Just one clarification: the static analyzer tests only serve to check whether the Static Analyzer crashes or hits an assertion error, or is it something more?
> > 
> Mostly they check for reported results, you can see special comments like `// expect-warning{...}` in almost every test.
So right now we have a failing test for this, I guess its my job in the next commit to make it pass. :)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95877



More information about the cfe-commits mailing list