[clang] [CIR] Add support for initializing classes with multiple vtables (PR #155275)
Erich Keane via cfe-commits
cfe-commits at lists.llvm.org
Mon Aug 25 11:05:31 PDT 2025
================
@@ -126,6 +127,32 @@ static bool isInitializerOfDynamicClass(const CXXCtorInitializer *baseInit) {
return baseClassDecl->isDynamicClass();
}
+namespace {
+/// A visitor which checks whether an initializer uses 'this' in a
+/// way which requires the vtable to be properly set.
+struct DynamicThisUseChecker
+ : ConstEvaluatedExprVisitor<DynamicThisUseChecker> {
+ using super = ConstEvaluatedExprVisitor<DynamicThisUseChecker>;
+
+ bool usesThis;
+
+ DynamicThisUseChecker(const ASTContext &c) : super(c), usesThis(false) {}
+
+ // Black-list all explicit and implicit references to 'this'.
+ //
+ // Do we need to worry about external references to 'this' derived
+ // from arbitrary code? If so, then anything which runs arbitrary
+ // external code might potentially access the vtable.
+ void VisitCXXThisExpr(const CXXThisExpr *e) { usesThis = true; }
----------------
erichkeane wrote:
This is strange and seems insufficient... but I see it is from classic codegen, so *shrug* guess this is good enough.
https://github.com/llvm/llvm-project/pull/155275
More information about the cfe-commits
mailing list