clang 24.0.0git
ModuleUtils.h
Go to the documentation of this file.
1//===--- ModuleUtils.h - Shared module 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 that both classic CodeGen and CIR CodeGen
10// need while deciding how a declaration is emitted at module scope, such as
11// its linkage and whether it belongs in a COMDAT group.
12//
13//===----------------------------------------------------------------------===//
14
15#ifndef LLVM_CLANG_CODEGENUTILS_MODULEUTILS_H
16#define LLVM_CLANG_CODEGENUTILS_MODULEUTILS_H
17
19#include "clang/Basic/Module.h"
20#include "llvm/ADT/ArrayRef.h"
21#include "llvm/ADT/SmallVector.h"
22
23namespace clang::CodeGenUtils {
24
25/// Determines whether the language options require us to model
26/// unwind exceptions. We treat -fexceptions as mandating this
27/// except under the fragile ObjC ABI with only ObjC exceptions
28/// enabled. This means, for example, that C with -fexceptions
29/// enables this.
30/// Return the AST address space of constant literal, which is used to emit
31/// the constant literal as global variable in LLVM IR.
32/// Note: This is not necessarily the address space of the constant literal
33/// in AST. For address space agnostic language, e.g. C++, constant literal
34/// in AST is always in default address space.
35LangAS getGlobalConstantAddressSpace(const LangOptions &LangOpts,
36 const TargetInfo &Target);
37
38bool hasUnwindExceptions(const LangOptions &LangOpts);
39
40/// Check whether \p D is a strong definition, and thus must not be given
41/// common linkage. \p NoCommon reflects -fno-common.
42bool isVarDeclStrongDefinition(const ASTContext &Ctx, const VarDecl *D,
43 bool NoCommon);
44
45/// Check whether \p D should be emitted into a COMDAT group.
46bool shouldBeInCOMDAT(const ASTContext &Ctx, const Decl &D);
47
48/// The C++20 named modules whose Itanium initializer function the global init
49/// function of a translation unit calls before the unit's own initializers,
50/// in call order. For a module interface or partition unit \p Primary these
51/// are the modules it exports, imports, or imports in its global or private
52/// module fragment; for any other unit the modules in \p Imported, its import
53/// declarations in order. A header-like module has no initializer function,
54/// and a named module that needs none is skipped.
55llvm::SmallVector<Module *, 8>
56importedModulesToInitialize(Module *Primary, llvm::ArrayRef<Module *> Imported);
57
58} // namespace clang::CodeGenUtils
59
60#endif // LLVM_CLANG_CODEGENUTILS_MODULEUTILS_H
Defines the clang::ASTContext interface.
Defines the clang::Module class, which describes a module in the source code.
LangAS getGlobalConstantAddressSpace(const LangOptions &LangOpts, const TargetInfo &Target)
Determines whether the language options require us to model unwind exceptions.
bool isVarDeclStrongDefinition(const ASTContext &Ctx, const VarDecl *D, bool NoCommon)
Check whether D is a strong definition, and thus must not be given common linkage.
llvm::SmallVector< Module *, 8 > importedModulesToInitialize(Module *Primary, llvm::ArrayRef< Module * > Imported)
The C++20 named modules whose Itanium initializer function the global init function of a translation ...
bool hasUnwindExceptions(const LangOptions &LangOpts)
bool shouldBeInCOMDAT(const ASTContext &Ctx, const Decl &D)
Check whether D should be emitted into a COMDAT group.
@ Module
Module linkage, which indicates that the entity can be referred to from other translation units withi...
Definition Linkage.h:54
LangAS
Defines the address space values used by the address space qualifier of QualType.