clang 24.0.0git
CodeGenUtils.h
Go to the documentation of this file.
1//===--- CodeGenUtils.h - Shared Classic CodeGen/CIR CodeGen Utils--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#ifndef LLVM_CLANG_CODEGENUTILS_CODEGENUTILS_H
10#define LLVM_CLANG_CODEGENUTILS_CODEGENUTILS_H
11
14
15namespace clang {
16class CallExpr;
18class FunctionDecl;
19class LangOptions;
20} // namespace clang
21
22namespace clang::CodeGenUtils {
23/// Check whether we need to initialize any vtable pointers before calling this
24/// destructor.
25bool canSkipVTablePointerInitialization(ASTContext &Ctx,
26 const CXXDestructorDecl *Dtor);
27
28/// Check whether destructing \p Field has no observable behaviors, and thus can
29/// be skipped when creating a destructor body. So non-record types, anonymous
30/// structs/unions, or record types where the destructor doesnt DO anything are
31/// considered as this version of 'trivial'.
32/// Note: This is a more liberal definition of trivial destruction than the C++
33/// Standard's version, and thus cannot be used as a substitute for C++ Standard
34/// requirements.
35bool fieldHasTrivialDestructorBody(ASTContext &Context, const FieldDecl *Field);
36
37/// Determines whether the language options require us to model
38/// unwind exceptions. We treat -fexceptions as mandating this
39/// except under the fragile ObjC ABI with only ObjC exceptions
40/// enabled. This means, for example, that C with -fexceptions
41/// enables this.
42bool hasUnwindExceptions(const LangOptions &LangOpts);
43
44/// Helper method to check if the underlying ABI is AAPCS
45bool isAAPCS(const TargetInfo &TargetInfo);
46
47bool isInitializerOfDynamicClass(const CXXCtorInitializer *BaseInit);
48
49/// Check that a call to a target-specific builtin has the required target
50/// features enabled in the caller, emitting an error diagnostic if not.
51/// \p caller is the FunctionDecl of the enclosing function (may be null).
52void checkTargetFeatures(ASTContext &Ctx, DiagnosticsEngine &Diags,
53 const LangOptions &LangOpts, const CallExpr *E,
54 const FunctionDecl *Caller,
55 const FunctionDecl *TargetDecl);
56
57/// Overload taking a raw source location instead of a CallExpr.
58void checkTargetFeatures(ASTContext &Ctx, DiagnosticsEngine &Diags,
59 const LangOptions &LangOpts, SourceLocation Loc,
60 const FunctionDecl *Caller,
61 const FunctionDecl *TargetDecl);
62
63} // namespace clang::CodeGenUtils
64
65#endif // LLVM_CLANG_CODEGENUTILS_CODEGENUTILS_H
Defines the clang::ASTContext interface.
Defines the clang::SourceLocation class and associated facilities.
CallExpr - Represents a function call (C99 6.5.2.2, C++ [expr.call]).
Definition Expr.h:2987
Concrete class used by the front-end to report problems and issues.
Definition Diagnostic.h:232
Represents a function declaration or definition.
Definition Decl.h:2059
Keeps track of the various options that can be enabled, which controls the dialect of C or C++ that i...
bool isAAPCS(const TargetInfo &TargetInfo)
Helper method to check if the underlying ABI is AAPCS.
bool isInitializerOfDynamicClass(const CXXCtorInitializer *BaseInit)
bool canSkipVTablePointerInitialization(ASTContext &Ctx, const CXXDestructorDecl *Dtor)
Check whether we need to initialize any vtable pointers before calling this destructor.
bool fieldHasTrivialDestructorBody(ASTContext &Context, const FieldDecl *Field)
Check whether destructing Field has no observable behaviors, and thus can be skipped when creating a ...
bool hasUnwindExceptions(const LangOptions &LangOpts)
Determines whether the language options require us to model unwind exceptions.
void checkTargetFeatures(ASTContext &Ctx, DiagnosticsEngine &Diags, const LangOptions &LangOpts, const CallExpr *E, const FunctionDecl *Caller, const FunctionDecl *TargetDecl)
Check that a call to a target-specific builtin has the required target features enabled in the caller...
Top level wrappers for InstallAPI frontend operations.