[PATCH] D135025: [clang][Interp] Support base class constructors

Timm Bäder via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Oct 4 08:36:39 PDT 2022


tbaeder marked an inline comment as done.
tbaeder added inline comments.


================
Comment at: clang/lib/AST/Interp/ByteCodeExprGen.h:263
+    QualType T = E->getType();
+    if (const auto *PT = dyn_cast<PointerType>(T))
+      T = PT->getPointeeType();
----------------
erichkeane wrote:
> We are de-pointering here, why not de-referencing? 
> 
> If we are OK with that, we can do this as:
> 
> ``` if (const auto *RD = T->getPointeeCXXRecordDecl()) 
>       return RD;
>     return T->getAsCXXRecordDecl();
> ```
> and most of the work is done for you.
> 
No reason, as usual I just didn't know this was a thing. Thanks!


================
Comment at: clang/test/AST/Interp/records.cpp:165
+
+class A : public Base {
+public:
----------------
erichkeane wrote:
> shafik wrote:
> > How about also testing `private` and `virtual` as well as multiple bases.
> I like the idea of testing virtual bases as well.
How would that work in a constexpr context? I get:

```
array.cpp:48:15: error: constexpr constructor not allowed in class with virtual base class
    constexpr D() : A(17) {}
              ^
array.cpp:45:13: note: virtual base class declared here
  class B : public virtual A {};
            ^~~~~~~~~~~~~~~~
1 error generated.
```



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

https://reviews.llvm.org/D135025



More information about the cfe-commits mailing list