llvmorg-github-actions[bot] wrote:
<!--LLVM PR SUMMARY COMMENT--> @llvm/pr-subscribers-clang Author: Henrich Lauko (xlauko) <details> <summary>Changes</summary> Moves the last helpers out of `CodeGenUtils.h` into `ClassUtils.h`, `ModuleUtils.h`, `TargetUtils.h` and `FunctionUtils.h` (`checkTargetFeatures`, since it came from CodeGenFunction.cpp) and deletes the header. Only moves code already on main, so it can be dropped on its own. Assisted-by: Claude Code (Claude Fable 5.1). --- Patch is 36.86 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/223451.diff 22 Files Affected: - (modified) clang/include/clang/CodeGenUtils/ClassUtils.h (+18) - (removed) clang/include/clang/CodeGenUtils/CodeGenUtils.h (-73) - (modified) clang/include/clang/CodeGenUtils/FunctionUtils.h (+24-2) - (modified) clang/include/clang/CodeGenUtils/ModuleUtils.h (+15) - (modified) clang/include/clang/CodeGenUtils/TargetUtils.h (+4) - (modified) clang/lib/CIR/CodeGen/CIRGenBuiltin.cpp (+1-1) - (modified) clang/lib/CIR/CodeGen/CIRGenClass.cpp (-1) - (modified) clang/lib/CIR/CodeGen/CIRGenExpr.cpp (+1-1) - (modified) clang/lib/CIR/CodeGen/CIRGenFunction.cpp (+1-1) - (modified) clang/lib/CIR/CodeGen/CIRGenModule.cpp (-1) - (modified) clang/lib/CIR/CodeGen/CIRGenRecordLayoutBuilder.cpp (+1-1) - (modified) clang/lib/CodeGen/CGClass.cpp (-1) - (modified) clang/lib/CodeGen/CGExpr.cpp (+1-1) - (modified) clang/lib/CodeGen/CGRecordLayoutBuilder.cpp (+1-1) - (modified) clang/lib/CodeGen/CodeGenFunction.cpp (-1) - (modified) clang/lib/CodeGen/CodeGenModule.cpp (-1) - (modified) clang/lib/CodeGenUtils/CMakeLists.txt (-1) - (modified) clang/lib/CodeGenUtils/ClassUtils.cpp (+78) - (removed) clang/lib/CodeGenUtils/CodeGenUtils.cpp (-254) - (modified) clang/lib/CodeGenUtils/FunctionUtils.cpp (+120) - (modified) clang/lib/CodeGenUtils/ModuleUtils.cpp (+37) - (modified) clang/lib/CodeGenUtils/TargetUtils.cpp (+5) ``````````diff diff --git a/clang/include/clang/CodeGenUtils/ClassUtils.h b/clang/include/clang/CodeGenUtils/ClassUtils.h index 63664ed737933..570c67110e120 100644 --- a/clang/include/clang/CodeGenUtils/ClassUtils.h +++ b/clang/include/clang/CodeGenUtils/ClassUtils.h @@ -24,6 +24,24 @@ namespace clang::CodeGenUtils { /// properly set. bool baseInitializerUsesThis(ASTContext &Ctx, const Expr *Init); +/// Check whether we need to initialize any vtable pointers before calling this +/// destructor. +bool canSkipVTablePointerInitialization(ASTContext &Ctx, + const CXXDestructorDecl *Dtor); + +/// Check whether destructing \p Field has no observable behaviors, and thus can +/// be skipped when creating a destructor body. So non-record types, anonymous +/// structs/unions, or record types where the destructor doesnt DO anything are +/// considered as this version of 'trivial'. +/// Note: This is a more liberal definition of trivial destruction than the C++ +/// Standard's version, and thus cannot be used as a substitute for C++ Standard +/// requirements. +bool fieldHasTrivialDestructorBody(ASTContext &Ctx, const FieldDecl *Field); + +/// Return whether \p BaseInit initializes a base class that is dynamic, that +/// is, one whose vtable pointer must be set before the initializer runs. +bool isInitializerOfDynamicClass(const CXXCtorInitializer *BaseInit); + } // namespace clang::CodeGenUtils #endif // LLVM_CLANG_CODEGENUTILS_CLASSUTILS_H diff --git a/clang/include/clang/CodeGenUtils/CodeGenUtils.h b/clang/include/clang/CodeGenUtils/CodeGenUtils.h deleted file mode 100644 index b2cc416330eb3..0000000000000 --- a/clang/include/clang/CodeGenUtils/CodeGenUtils.h +++ /dev/null @@ -1,73 +0,0 @@ -//===--- CodeGenUtils.h - Shared Classic CodeGen/CIR CodeGen Utils--C++ -*-===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#ifndef LLVM_CLANG_CODEGENUTILS_CODEGENUTILS_H -#define LLVM_CLANG_CODEGENUTILS_CODEGENUTILS_H - -#include "clang/AST/ASTContext.h" -#include "clang/Basic/SourceLocation.h" - -namespace clang { -class CallExpr; -class DiagnosticsEngine; -class FunctionDecl; -class LangOptions; -} // namespace clang - -namespace clang::CodeGenUtils { -/// Check whether we need to initialize any vtable pointers before calling this -/// destructor. -bool canSkipVTablePointerInitialization(ASTContext &Ctx, - const CXXDestructorDecl *Dtor); - -/// Check whether destructing \p Field has no observable behaviors, and thus can -/// be skipped when creating a destructor body. So non-record types, anonymous -/// structs/unions, or record types where the destructor doesnt DO anything are -/// considered as this version of 'trivial'. -/// Note: This is a more liberal definition of trivial destruction than the C++ -/// Standard's version, and thus cannot be used as a substitute for C++ Standard -/// requirements. -bool fieldHasTrivialDestructorBody(ASTContext &Context, const FieldDecl *Field); - -/// Determines whether the language options require us to model -/// unwind exceptions. We treat -fexceptions as mandating this -/// except under the fragile ObjC ABI with only ObjC exceptions -/// enabled. This means, for example, that C with -fexceptions -/// enables this. -bool hasUnwindExceptions(const LangOptions &LangOpts); - -/// Helper method to check if the underlying ABI is AAPCS -bool isAAPCS(const TargetInfo &TargetInfo); - -/// Return the AST address space of constant literal, which is used to emit -/// the constant literal as global variable in LLVM IR. -/// Note: This is not necessarily the address space of the constant literal -/// in AST. For address space agnostic language, e.g. C++, constant literal -/// in AST is always in default address space. -LangAS getGlobalConstantAddressSpace(const LangOptions &LangOpts, - const TargetInfo &Target); - -bool isInitializerOfDynamicClass(const CXXCtorInitializer *BaseInit); - -/// Check that a call to a target-specific builtin has the required target -/// features enabled in the caller, emitting an error diagnostic if not. -/// \p caller is the FunctionDecl of the enclosing function (may be null). -void checkTargetFeatures(ASTContext &Ctx, DiagnosticsEngine &Diags, - const LangOptions &LangOpts, const CallExpr *E, - const FunctionDecl *Caller, - const FunctionDecl *TargetDecl); - -/// Overload taking a raw source location instead of a CallExpr. -void checkTargetFeatures(ASTContext &Ctx, DiagnosticsEngine &Diags, - const LangOptions &LangOpts, SourceLocation Loc, - const FunctionDecl *Caller, - const FunctionDecl *TargetDecl); - -} // namespace clang::CodeGenUtils - -#endif // LLVM_CLANG_CODEGENUTILS_CODEGENUTILS_H diff --git a/clang/include/clang/CodeGenUtils/FunctionUtils.h b/clang/include/clang/CodeGenUtils/FunctionUtils.h index f924874d829e0..4e500aa8d3c0b 100644 --- a/clang/include/clang/CodeGenUtils/FunctionUtils.h +++ b/clang/include/clang/CodeGenUtils/FunctionUtils.h @@ -6,8 +6,8 @@ // //===----------------------------------------------------------------------===// // -// This file holds the queries that both classic CodeGen and CIR CodeGen need -// while emitting a function body. +// This file holds the queries and checks that both classic CodeGen and CIR +// CodeGen need while emitting a function body. // //===----------------------------------------------------------------------===// @@ -16,6 +16,14 @@ #include "clang/Basic/CodeGenOptions.h" #include "clang/Basic/LangOptions.h" +#include "clang/Basic/SourceLocation.h" + +namespace clang { +class ASTContext; +class CallExpr; +class DiagnosticsEngine; +class FunctionDecl; +} // namespace clang namespace clang::CodeGenUtils { @@ -23,6 +31,20 @@ namespace clang::CodeGenUtils { bool shouldEmitLifetimeMarkers(const CodeGenOptions &CGOpts, const LangOptions &LangOpts); +/// Check that a call to a target-specific builtin has the required target +/// features enabled in the caller, emitting an error diagnostic if not. +/// \p Caller is the FunctionDecl of the enclosing function (may be null). +void checkTargetFeatures(ASTContext &Ctx, DiagnosticsEngine &Diags, + const LangOptions &LangOpts, const CallExpr *E, + const FunctionDecl *Caller, + const FunctionDecl *TargetDecl); + +/// Overload taking a raw source location instead of a CallExpr. +void checkTargetFeatures(ASTContext &Ctx, DiagnosticsEngine &Diags, + const LangOptions &LangOpts, SourceLocation Loc, + const FunctionDecl *Caller, + const FunctionDecl *TargetDecl); + } // namespace clang::CodeGenUtils #endif // LLVM_CLANG_CODEGENUTILS_FUNCTIONUTILS_H diff --git a/clang/include/clang/CodeGenUtils/ModuleUtils.h b/clang/include/clang/CodeGenUtils/ModuleUtils.h index 5c7423ad4fac5..10b39438567db 100644 --- a/clang/include/clang/CodeGenUtils/ModuleUtils.h +++ b/clang/include/clang/CodeGenUtils/ModuleUtils.h @@ -19,6 +19,21 @@ namespace clang::CodeGenUtils { +/// Determines whether the language options require us to model +/// unwind exceptions. We treat -fexceptions as mandating this +/// except under the fragile ObjC ABI with only ObjC exceptions +/// enabled. This means, for example, that C with -fexceptions +/// enables this. +/// Return the AST address space of constant literal, which is used to emit +/// the constant literal as global variable in LLVM IR. +/// Note: This is not necessarily the address space of the constant literal +/// in AST. For address space agnostic language, e.g. C++, constant literal +/// in AST is always in default address space. +LangAS getGlobalConstantAddressSpace(const LangOptions &LangOpts, + const TargetInfo &Target); + +bool hasUnwindExceptions(const LangOptions &LangOpts); + /// Check whether \p D is a strong definition, and thus must not be given /// common linkage. \p NoCommon reflects -fno-common. bool isVarDeclStrongDefinition(const ASTContext &Ctx, const VarDecl *D, diff --git a/clang/include/clang/CodeGenUtils/TargetUtils.h b/clang/include/clang/CodeGenUtils/TargetUtils.h index a44541c572590..2c812c6a2b617 100644 --- a/clang/include/clang/CodeGenUtils/TargetUtils.h +++ b/clang/include/clang/CodeGenUtils/TargetUtils.h @@ -21,6 +21,7 @@ namespace clang { class Decl; class FunctionDecl; +class TargetInfo; } // namespace clang namespace clang::CodeGenUtils { @@ -53,6 +54,9 @@ ArmSMEInlinability getArmSMEInlinability(const FunctionDecl *Caller, /// TODO: Make this return false for SISD builtins. bool hasExtraNeonArgument(unsigned BuiltinID); +/// Helper method to check if the underlying ABI is AAPCS +bool isAAPCS(const TargetInfo &TargetInfo); + /// Returns whether \p D must be given protected visibility on AMDGPU. /// \p HasHiddenVisibility is whether the emitted global currently has hidden /// visibility. diff --git a/clang/lib/CIR/CodeGen/CIRGenBuiltin.cpp b/clang/lib/CIR/CodeGen/CIRGenBuiltin.cpp index c47165ec153a7..834f583d1e38a 100644 --- a/clang/lib/CIR/CodeGen/CIRGenBuiltin.cpp +++ b/clang/lib/CIR/CodeGen/CIRGenBuiltin.cpp @@ -26,7 +26,7 @@ #include "clang/Basic/OperatorKinds.h" #include "clang/CIR/Dialect/IR/CIRTypes.h" #include "clang/CIR/MissingFeatures.h" -#include "clang/CodeGenUtils/CodeGenUtils.h" +#include "clang/CodeGenUtils/FunctionUtils.h" #include "llvm/ADT/STLExtras.h" #include "llvm/IR/Intrinsics.h" #include "llvm/Support/ErrorHandling.h" diff --git a/clang/lib/CIR/CodeGen/CIRGenClass.cpp b/clang/lib/CIR/CodeGen/CIRGenClass.cpp index 28db1763fd3cb..9633b915bd669 100644 --- a/clang/lib/CIR/CodeGen/CIRGenClass.cpp +++ b/clang/lib/CIR/CodeGen/CIRGenClass.cpp @@ -20,7 +20,6 @@ #include "clang/CIR/Dialect/IR/CIRDialect.h" #include "clang/CIR/MissingFeatures.h" #include "clang/CodeGenUtils/ClassUtils.h" -#include "clang/CodeGenUtils/CodeGenUtils.h" using namespace clang; using namespace clang::CIRGen; diff --git a/clang/lib/CIR/CodeGen/CIRGenExpr.cpp b/clang/lib/CIR/CodeGen/CIRGenExpr.cpp index 1f738f9737d31..0b0bda28d4c87 100644 --- a/clang/lib/CIR/CodeGen/CIRGenExpr.cpp +++ b/clang/lib/CIR/CodeGen/CIRGenExpr.cpp @@ -30,8 +30,8 @@ #include "clang/CIR/Dialect/IR/CIRDialect.h" #include "clang/CIR/Dialect/IR/CIRTypes.h" #include "clang/CIR/MissingFeatures.h" -#include "clang/CodeGenUtils/CodeGenUtils.h" #include "clang/CodeGenUtils/ExprUtils.h" +#include "clang/CodeGenUtils/TargetUtils.h" #include <optional> using namespace clang; diff --git a/clang/lib/CIR/CodeGen/CIRGenFunction.cpp b/clang/lib/CIR/CodeGen/CIRGenFunction.cpp index 382a0008113e2..c6f3fc22a776b 100644 --- a/clang/lib/CIR/CodeGen/CIRGenFunction.cpp +++ b/clang/lib/CIR/CodeGen/CIRGenFunction.cpp @@ -21,7 +21,7 @@ #include "clang/AST/GlobalDecl.h" #include "clang/CIR/Dialect/IR/CIRDialect.h" #include "clang/CIR/MissingFeatures.h" -#include "clang/CodeGenUtils/CodeGenUtils.h" +#include "clang/CodeGenUtils/ClassUtils.h" #include "clang/CodeGenUtils/FunctionUtils.h" #include "llvm/ADT/ScopeExit.h" #include "llvm/IR/FPEnv.h" diff --git a/clang/lib/CIR/CodeGen/CIRGenModule.cpp b/clang/lib/CIR/CodeGen/CIRGenModule.cpp index 5063b6a4cc779..b7b5ac77d0bc1 100644 --- a/clang/lib/CIR/CodeGen/CIRGenModule.cpp +++ b/clang/lib/CIR/CodeGen/CIRGenModule.cpp @@ -36,7 +36,6 @@ #include "clang/CIR/Dialect/IR/CIRTypes.h" #include "clang/CIR/Interfaces/CIROpInterfaces.h" #include "clang/CIR/MissingFeatures.h" -#include "clang/CodeGenUtils/CodeGenUtils.h" #include "clang/CodeGenUtils/ModuleUtils.h" #include "llvm/ADT/STLExtras.h" #include "llvm/ADT/StringExtras.h" diff --git a/clang/lib/CIR/CodeGen/CIRGenRecordLayoutBuilder.cpp b/clang/lib/CIR/CodeGen/CIRGenRecordLayoutBuilder.cpp index 63715e1f6e814..49651c08c76d2 100644 --- a/clang/lib/CIR/CodeGen/CIRGenRecordLayoutBuilder.cpp +++ b/clang/lib/CIR/CodeGen/CIRGenRecordLayoutBuilder.cpp @@ -22,8 +22,8 @@ #include "clang/CIR/Dialect/IR/CIRAttrs.h" #include "clang/CIR/Dialect/IR/CIRDataLayout.h" #include "clang/CIR/MissingFeatures.h" -#include "clang/CodeGenUtils/CodeGenUtils.h" #include "clang/CodeGenUtils/RecordLayoutUtils.h" +#include "clang/CodeGenUtils/TargetUtils.h" #include "llvm/Support/Casting.h" #include <memory> diff --git a/clang/lib/CodeGen/CGClass.cpp b/clang/lib/CodeGen/CGClass.cpp index 63f5d9ae13dbf..31965c98c75bb 100644 --- a/clang/lib/CodeGen/CGClass.cpp +++ b/clang/lib/CodeGen/CGClass.cpp @@ -26,7 +26,6 @@ #include "clang/Basic/CodeGenOptions.h" #include "clang/CodeGen/CGFunctionInfo.h" #include "clang/CodeGenUtils/ClassUtils.h" -#include "clang/CodeGenUtils/CodeGenUtils.h" #include "llvm/IR/Intrinsics.h" #include "llvm/IR/Metadata.h" #include "llvm/Support/SaveAndRestore.h" diff --git a/clang/lib/CodeGen/CGExpr.cpp b/clang/lib/CodeGen/CGExpr.cpp index 76bd781a709b6..aca123628cc44 100644 --- a/clang/lib/CodeGen/CGExpr.cpp +++ b/clang/lib/CodeGen/CGExpr.cpp @@ -39,8 +39,8 @@ #include "clang/Basic/CodeGenOptions.h" #include "clang/Basic/Module.h" #include "clang/Basic/SourceManager.h" -#include "clang/CodeGenUtils/CodeGenUtils.h" #include "clang/CodeGenUtils/ExprUtils.h" +#include "clang/CodeGenUtils/TargetUtils.h" #include "llvm/ADT/STLExtras.h" #include "llvm/ADT/ScopeExit.h" #include "llvm/ADT/StringExtras.h" diff --git a/clang/lib/CodeGen/CGRecordLayoutBuilder.cpp b/clang/lib/CodeGen/CGRecordLayoutBuilder.cpp index 905382f5ea939..dc6a7bfca35f6 100644 --- a/clang/lib/CodeGen/CGRecordLayoutBuilder.cpp +++ b/clang/lib/CodeGen/CGRecordLayoutBuilder.cpp @@ -21,8 +21,8 @@ #include "clang/AST/Expr.h" #include "clang/AST/RecordLayout.h" #include "clang/Basic/CodeGenOptions.h" -#include "clang/CodeGenUtils/CodeGenUtils.h" #include "clang/CodeGenUtils/RecordLayoutUtils.h" +#include "clang/CodeGenUtils/TargetUtils.h" #include "llvm/IR/DataLayout.h" #include "llvm/IR/DerivedTypes.h" #include "llvm/IR/Type.h" diff --git a/clang/lib/CodeGen/CodeGenFunction.cpp b/clang/lib/CodeGen/CodeGenFunction.cpp index 26d8d73e1eb2f..3eedb12e7d4bd 100644 --- a/clang/lib/CodeGen/CodeGenFunction.cpp +++ b/clang/lib/CodeGen/CodeGenFunction.cpp @@ -36,7 +36,6 @@ #include "clang/Basic/TargetBuiltins.h" #include "clang/Basic/TargetInfo.h" #include "clang/CodeGen/CGFunctionInfo.h" -#include "clang/CodeGenUtils/CodeGenUtils.h" #include "clang/CodeGenUtils/FunctionUtils.h" #include "llvm/ADT/ArrayRef.h" #include "llvm/ADT/ScopeExit.h" diff --git a/clang/lib/CodeGen/CodeGenModule.cpp b/clang/lib/CodeGen/CodeGenModule.cpp index b4ebc6b6abff0..fdac5cc858893 100644 --- a/clang/lib/CodeGen/CodeGenModule.cpp +++ b/clang/lib/CodeGen/CodeGenModule.cpp @@ -48,7 +48,6 @@ #include "clang/Basic/Version.h" #include "clang/CodeGen/BackendUtil.h" #include "clang/CodeGen/ConstantInitBuilder.h" -#include "clang/CodeGenUtils/CodeGenUtils.h" #include "clang/CodeGenUtils/ModuleUtils.h" #include "clang/Lex/Preprocessor.h" #include "llvm/ABI/IRTypeMapper.h" diff --git a/clang/lib/CodeGenUtils/CMakeLists.txt b/clang/lib/CodeGenUtils/CMakeLists.txt index 7fb94a994bfed..dc701f8dbc72f 100644 --- a/clang/lib/CodeGenUtils/CMakeLists.txt +++ b/clang/lib/CodeGenUtils/CMakeLists.txt @@ -9,7 +9,6 @@ add_clang_library(clangCodeGenUtils BackendDiagnosticHandler.cpp CallUtils.cpp ClassUtils.cpp - CodeGenUtils.cpp EHPersonality.cpp ExprUtils.cpp FunctionUtils.cpp diff --git a/clang/lib/CodeGenUtils/ClassUtils.cpp b/clang/lib/CodeGenUtils/ClassUtils.cpp index 90bab38280c30..5a504ca0b5beb 100644 --- a/clang/lib/CodeGenUtils/ClassUtils.cpp +++ b/clang/lib/CodeGenUtils/ClassUtils.cpp @@ -36,4 +36,82 @@ bool baseInitializerUsesThis(ASTContext &Ctx, const Expr *Init) { return Checker.UsesThis; } +static bool +hasTrivialDestructorBody(ASTContext &Ctx, const CXXRecordDecl *BaseClassDecl, + const CXXRecordDecl *MostDerivedClassDecl) { + // If the destructor is trivial we don't have to check anything else. + if (BaseClassDecl->hasTrivialDestructor()) + return true; + + if (!BaseClassDecl->getDestructor()->hasTrivialBody()) + return false; + + // Check fields. + for (const auto *Field : BaseClassDecl->fields()) + if (!fieldHasTrivialDestructorBody(Ctx, Field)) + return false; + + // Check non-virtual bases. + for (const auto &I : BaseClassDecl->bases()) { + if (I.isVirtual()) + continue; + + const auto *NonVirtualBase = I.getType()->castAsCXXRecordDecl(); + if (!hasTrivialDestructorBody(Ctx, NonVirtualBase, MostDerivedClassDecl)) + return false; + } + + if (BaseClassDecl == MostDerivedClassDecl) { + // Check virtual bases. + for (const auto &I : BaseClassDecl->vbases()) { + const auto *VirtualBase = I.getType()->castAsCXXRecordDecl(); + if (!hasTrivialDestructorBody(Ctx, VirtualBase, MostDerivedClassDecl)) + return false; + } + } + + return true; +} + +bool fieldHasTrivialDestructorBody(ASTContext &Ctx, const FieldDecl *Field) { + QualType FieldBaseElementType = Ctx.getBaseElementType(Field->getType()); + + auto *FieldClassDecl = FieldBaseElementType->getAsCXXRecordDecl(); + if (!FieldClassDecl) + return true; + + // The destructor for an implicit anonymous union member is never invoked. + if (FieldClassDecl->isUnion() && FieldClassDecl->isAnonymousStructOrUnion()) + return true; + + return hasTrivialDestructorBody(Ctx, FieldClassDecl, FieldClassDecl); +} + +bool canSkipVTablePointerInitialization(ASTContext &Ctx, + const CXXDestructorDecl *Dtor) { + const CXXRecordDecl *ClassDecl = Dtor->getParent(); + if (!ClassDecl->isDynamicClass()) + return true; + + // For a final class, the vtable pointer is known to already point to the + // class's vtable. + if (ClassDecl->isEffectivelyFinal()) + return true; + + if (!Dtor->hasTrivialBody()) + return false; + + // Check the fields. + for (const auto *Field : ClassDecl->fields()) + if (!fieldHasTrivialDestructorBody(Ctx, Field)) + return false; + + return true; +} + +bool isInitializerOfDynamicClass(const CXXCtorInitializer *BaseInit) { + const Type *BaseType = BaseInit->getBaseClass(); + return BaseType->castAsCXXRecordDecl()->isDynamicClass(); +} + } // namespace clang::CodeGenUtils diff --git a/clang/lib/CodeGenUtils/CodeGenUtils.cpp b/clang/lib/CodeGenUtils/CodeGenUtils.cpp deleted file mode 100644 index 11afe31ae89b0..0000000000000 --- a/clang/lib/CodeGenUtils/CodeGenUtils.cpp +++ /dev/null @@ -1,254 +0,0 @@ -//==--- CodeGenUtils.cpp - Shared Classic CodeGen/CIR CodeGen Utils--C++ -*-==// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#include "clang/CodeGenUtils/CodeGenUtils.h" -#include "clang/AST/Attr.h" -#include "clang/AST/Expr.h" -#include "clang/Basic/Builtins.h" -#include "clang/Basic/DiagnosticFrontend.h" -#include "clang/Basic/TargetBuiltins.h" -#include "clang/Basic/TargetInfo.h" -#include "llvm/ADT/StringMap.h" - -namespace clang::CodeGenUtils { -static bool -hasTrivialDestructorBody(ASTContext &Context, - const CXXRecordDecl *BaseClassDecl, - const CXXRecordDecl *MostDerivedClassDecl) { - // If the destructor is trivial we don't have to check anything else. - if (BaseClassDecl->hasTrivialDestructor()) - return true; - - if (!BaseClassDecl->getDestructor()->hasTrivialBody()) - return false; - - // Check fields. - for (const auto *Field : BaseClassDecl->fields()) - if (!fieldHasTrivialDestructorBody(Context, Field)) - return false; - - // Check non-virtual bases. - for (const auto &I : BaseClassDecl->bases()) { - if (I.isVirtual()) - continue; - - const auto *NonVirtualBase = I.getType()->castAsCXXRecordDecl(); - if (!hasTrivialDestructorBody(Context, NonVirtualBase, - ... [truncated] `````````` </details> https://github.com/llvm/llvm-project/pull/223451 _______________________________________________ llvm-branch-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
