clang 24.0.0git
ClassUtils.h
Go to the documentation of this file.
1//===--- ClassUtils.h - Shared C++ class emission queries -------*- C++ -*-===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8//
9// This file holds the AST queries about C++ class construction and destruction
10// that both classic CodeGen and CIR CodeGen need, chiefly to decide when a
11// vtable pointer has to be established before running member initializers or
12// a destructor body.
13//
14//===----------------------------------------------------------------------===//
15
16#ifndef LLVM_CLANG_CODEGENUTILS_CLASSUTILS_H
17#define LLVM_CLANG_CODEGENUTILS_CLASSUTILS_H
18
20
21namespace clang::CodeGenUtils {
22
23/// Check whether \p Init uses 'this' in a way which requires the vtable to be
24/// properly set.
25bool baseInitializerUsesThis(ASTContext &Ctx, const Expr *Init);
26
27/// Check whether we need to initialize any vtable pointers before calling this
28/// destructor.
29bool canSkipVTablePointerInitialization(ASTContext &Ctx,
30 const CXXDestructorDecl *Dtor);
31
32/// Check whether destructing \p Field has no observable behaviors, and thus can
33/// be skipped when creating a destructor body. So non-record types, anonymous
34/// structs/unions, or record types where the destructor doesnt DO anything are
35/// considered as this version of 'trivial'.
36/// Note: This is a more liberal definition of trivial destruction than the C++
37/// Standard's version, and thus cannot be used as a substitute for C++ Standard
38/// requirements.
39bool fieldHasTrivialDestructorBody(ASTContext &Ctx, const FieldDecl *Field);
40
41/// Return whether \p BaseInit initializes a base class that is dynamic, that
42/// is, one whose vtable pointer must be set before the initializer runs.
43bool isInitializerOfDynamicClass(const CXXCtorInitializer *BaseInit);
44
45} // namespace clang::CodeGenUtils
46
47#endif // LLVM_CLANG_CODEGENUTILS_CLASSUTILS_H
Defines the clang::ASTContext interface.
bool isInitializerOfDynamicClass(const CXXCtorInitializer *BaseInit)
Return whether BaseInit initializes a base class that is dynamic, that is, one whose vtable pointer m...
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.