[PATCH] D141497: [clang][Interp] Record initialization via conditional operator

Timm Bäder via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Mar 27 05:56:56 PDT 2023


tbaeder added inline comments.


================
Comment at: clang/lib/AST/Interp/ByteCodeExprGen.h:182-183
 
+  template <typename VisitFn>
+  bool visitConditional(const AbstractConditionalOperator *E, VisitFn V);
+
----------------
erichkeane wrote:
> tbaeder wrote:
> > aaron.ballman wrote:
> > > The template definition isn't available within the header file, so this is fragile (impossible to instantiate from anything but ByteCodeExprGen.cpp).
> > What's the alternative? If I make it a static function in `ByteCodeExprGen.cpp`, I'd have to make a lot of members of `ByteCodeEmitter` etc. public which  is not a very clean solution. Moving the definition into the header file isn't very nice either, all the others are in the source file.
> What about making it a static template in `ByteCodeExprGen.cpp`, but make it a 'friend' here?  I think that would work, wouldn't it?  Something like: https://godbolt.org/z/ofYbGvfYa
> 
> You unfortunately cannot make it static, but as it is a template, at least it is inline.  WDYT?
I tried that but I keep running into linker problems:

```
mold: error: undefined symbol: lib/libclangAST.a(ByteCodeExprGen.cpp.o): bool clang::interp::visitConditional<clang::interp::ByteCodeExprGen<clang::interp::ByteCodeEmitter>::VisitAbstractConditionalOperator(clang::AbstractConditionalOperator const*)::{lambda(clang::Expr const*)#1}>(clang::interp::ByteCodeExprGen<clang::interp::ByteCodeEmitter>*, clang::AbstractConditionalOperator const*, clang::interp::ByteCodeExprGen<clang::interp::ByteCodeEmitter>::VisitAbstractConditionalOperator(clang::AbstractConditionalOperator const*)::{lambda(clang::Expr const*)#1})
```
(and another one for `EvalEmitter`). But I can't investigate more before Wednesday.


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

https://reviews.llvm.org/D141497



More information about the cfe-commits mailing list