16struct DynamicThisUseChecker
17 : ConstEvaluatedExprVisitor<DynamicThisUseChecker> {
18 using super = ConstEvaluatedExprVisitor<DynamicThisUseChecker>;
20 bool UsesThis =
false;
22 DynamicThisUseChecker(
const ASTContext &
C) : super(
C) {}
29 void VisitCXXThisExpr(
const CXXThisExpr *E) { UsesThis =
true; }
34 DynamicThisUseChecker Checker(Ctx);
36 return Checker.UsesThis;
50 for (
const auto *Field : BaseClassDecl->
fields())
55 for (
const auto &I : BaseClassDecl->
bases()) {
64 if (BaseClassDecl == MostDerivedClassDecl) {
66 for (
const auto &I : BaseClassDecl->
vbases()) {
67 const auto *
VirtualBase = I.getType()->castAsCXXRecordDecl();
84 if (FieldClassDecl->isUnion() && FieldClassDecl->isAnonymousStructOrUnion())
101 if (!Dtor->hasTrivialBody())
105 for (
const auto *Field : ClassDecl->
fields())
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
QualType getBaseElementType(const ArrayType *VAT) const
Return the innermost element type of an array type.
Represents a C++ base or member initializer.
const Type * getBaseClass() const
If this is a base class initializer, returns the type of the base class.
Represents a C++ destructor within a class.
Represents a C++ struct/union/class.
bool isEffectivelyFinal() const
Determine whether it's impossible for a class to be derived from this class.
bool hasTrivialDestructor() const
Determine whether this class has a trivial destructor (C++ [class.dtor]p3)
base_class_range vbases()
bool isDynamicClass() const
CXXDestructorDecl * getDestructor() const
Returns the destructor decl for this class.
This represents one expression.
Represents a member of a struct/union/class.
bool hasTrivialBody() const
Returns whether the function has a trivial body that does not require any specific codegen.
A (possibly-)qualified type.
field_range fields() const
The base class of the type hierarchy.
CXXRecordDecl * getAsCXXRecordDecl() const
Retrieves the CXXRecordDecl that this type refers to, either because the type is a RecordType or beca...
CXXRecordDecl * castAsCXXRecordDecl() const
bool isInitializerOfDynamicClass(const CXXCtorInitializer *BaseInit)
Return whether BaseInit initializes a base class that is dynamic, that is, one whose vtable pointer m...
static bool hasTrivialDestructorBody(ASTContext &Ctx, const CXXRecordDecl *BaseClassDecl, const CXXRecordDecl *MostDerivedClassDecl)
bool canSkipVTablePointerInitialization(ASTContext &Ctx, const CXXDestructorDecl *Dtor)
Check whether we need to initialize any vtable pointers before calling this destructor.
bool fieldHasTrivialDestructorBody(ASTContext &Ctx, const FieldDecl *Field)
Check whether destructing Field has no observable behaviors, and thus can be skipped when creating a ...
bool baseInitializerUsesThis(ASTContext &Ctx, const Expr *Init)
Check whether Init uses 'this' in a way which requires the vtable to be properly set.