[PATCH] D40841: [analyzer] Fix a crash on C++17 AST for non-trivial construction into a trivial brace initializer.

Artem Dergachev via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Dec 5 15:09:20 PST 2017


NoQ updated this revision to Diff 125629.
NoQ added a comment.



> Note that there is no constructor call here. This is aggregate initialization. And there's not really any part of this that's new, except that a class with base classes is now an a aggregate. You'll see the same kind of AST formed in all C++ language modes with a slightly modified example:
> 
>   struct A {
>     A();
>   };
>   
>   struct B {
>     A a;
>     int x;
>   };
>   
>   void foo() {
>     B b = {};
>   }                                                        
> 
> 
> The analyzer should presumably treat the new example the exact same way it treats that case.

Thank you Richard! This sheds light on what situations do we need to cover.

For now it seems that with the patch we'd indeed be treating the base class case the exact same way as the field case: //by bailing out//. So both cases would need to be fixed. And the field case is very important because it's not C++17-specific.

I guess i'd finish the `operator new` adventure first, but this issue is definitely on the list of important-to-fix C++ stuff. And for now I guess i'd just stick something in there so that it didn't crash.

Updated comments to explain the situation.


https://reviews.llvm.org/D40841

Files:
  lib/StaticAnalyzer/Checkers/DynamicTypePropagation.cpp
  lib/StaticAnalyzer/Core/ExprEngineCXX.cpp
  test/Analysis/initializer.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D40841.125629.patch
Type: text/x-patch
Size: 4481 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20171205/918d9a2d/attachment-0001.bin>


More information about the cfe-commits mailing list