[PATCH] D61816: [CFG] [analyzer] pr41300: Add a branch to skip virtual base initializers when they are handled by the superclass.
Kristóf Umann via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Wed May 15 06:47:40 PDT 2019
Szelethus added a comment.
Exquisite detective work as always! I read a bit of the standard, your summary, the bugreport and the new test cases, and I feel confident that I have a good understanding of the problem and your solution, though I didn't dig through the details just yet. At a first glance this looks great, and I'll be sure to revisit this patch and accept it formally.
> The //expression-list// or //braced-init-list// in a //mem-initializer// is used to initialize the designated subobject (or, in the case of a delegating constructor, the complete class object) according to the initialization rules of 11.6 for direct-initialization. [ //Example://
>
> struct B1 { B1(int) ; /* . . . */ };
> struct B2 { B2(int) ; /* . . . */ };
> struct D : B1, B2 {
> D(int) ;
> B1 b;
> const int c;
> };
> D: : D(int a) : B2(a+1) , B1(a+2) , c(a+3) , b(a+4) { /* . . . */ }
> D d(10) ;
>
> //— end example// ] [ //Note:// The initialization performed by each //mem-initializer// constitutes a full-expression (4.6) . Any expression in a //mem-initializer// is evaluated as part of the full-expression that performs the initialization. //— end note// ] **A //mem-initializer// where the //mem-initializer-id// denotes a virtual base class is ignored during execution of a constructor of any class that is not the most derived class.**
I think this part of the standard isn't well known (due mostly the the scarcity of virtual bases), and I'd like to see it referenced, maybe even quoted.
================
Comment at: clang/include/clang/Analysis/CFG.h:567
+/// &&, || | expression that uses result of && or ||, RHS
+/// vbase inits | handled by superclass; not handled by superclass
///
----------------
In the context of this patch, I understand what you mean, but without that, this might not be a good description for a class this important.
How about
```
/// vbase inits | initialization handled by superclass;
/// | initialization not handled by superclass
```
?
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D61816/new/
https://reviews.llvm.org/D61816
More information about the cfe-commits
mailing list