clang
24.0.0git
include
clang
CodeGenUtils
ExprUtils.h
Go to the documentation of this file.
1
//===--- ExprUtils.h - Shared expression 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 expressions that both classic CodeGen
10
// and CIR CodeGen need while emitting scalar, aggregate and lvalue
11
// expressions.
12
//
13
//===----------------------------------------------------------------------===//
14
15
#ifndef LLVM_CLANG_CODEGENUTILS_EXPRUTILS_H
16
#define LLVM_CLANG_CODEGENUTILS_EXPRUTILS_H
17
18
#include "
clang/AST/ASTContext.h
"
19
20
namespace
clang::CodeGenUtils
{
21
22
/// Strip off the variably-modified array types wrapping \p VLA and return the
23
/// first element type that has a fixed size.
24
QualType
getFixedSizeElementType
(
const
ASTContext &Ctx,
25
const
VariableArrayType *VLA);
26
27
/// Check whether the value of \p E is possibly a reference to or into a
28
/// __block variable.
29
bool
isBlockVarRef
(
const
Expr *E);
30
31
/// Check whether \p E is cheap enough and side-effect-free enough to evaluate
32
/// unconditionally instead of conditionally. This is used to convert control
33
/// flow into selects in some cases.
34
bool
isCheapEnoughToEvaluateUnconditionally
(
const
Expr *E,
35
const
ASTContext &Ctx);
36
37
/// Check whether \p E is a trivial array filler, that is, one that is
38
/// equivalent to zero-initialization.
39
bool
isTrivialFiller
(
const
Expr *E);
40
41
/// Detect the unusual situation where an inline version of a builtin is
42
/// shadowed by a non-inline version. In that case we should pick the external
43
/// one everywhere. That's GCC behavior too.
44
bool
onlyHasInlineBuiltinDeclaration
(
const
FunctionDecl *FD);
45
46
/// Given an object of the canonical type \p Type, can we safely copy a value
47
/// out of it based on its initializer?
48
///
49
/// FIXME: Overly conservative: rejects all arrays, and requires C++ records
50
/// to be trivial rather than just trivially copyable.
51
bool
isConstantEmittableObjectType
(QualType
Type
);
52
53
/// How a reference to a variable can be emitted as a constant.
54
enum
ConstantEmissionKind
{
55
CEK_None
,
56
CEK_AsReferenceOnly
,
57
CEK_AsValueOrReference
,
58
CEK_AsValueOnly
59
};
60
61
/// Can we constant-emit a load of a reference to a variable of the given
62
/// type? This is different from predicates like
63
/// Decl::mightBeUsableInConstantExpressions because we do want it to apply
64
/// in situations that don't necessarily satisfy the language's rules
65
/// for this (e.g. C++'s ODR-use rules). For example, we want to be able
66
/// to do this with const float variables even if those variables
67
/// aren't marked 'constexpr'.
68
///
69
/// FIXME: For references, checks the pointee type, not the bound object's.
70
ConstantEmissionKind
checkVarTypeForConstantEmission
(
QualType
Type
);
71
72
}
// namespace clang::CodeGenUtils
73
74
#endif
// LLVM_CLANG_CODEGENUTILS_EXPRUTILS_H
ASTContext.h
Defines the clang::ASTContext interface.
clang::QualType
A (possibly-)qualified type.
Definition
TypeBase.h:938
clang::Type
The base class of the type hierarchy.
Definition
TypeBase.h:1879
clang::CodeGenUtils
Definition
CallUtils.h:26
clang::CodeGenUtils::getFixedSizeElementType
QualType getFixedSizeElementType(const ASTContext &Ctx, const VariableArrayType *VLA)
Strip off the variably-modified array types wrapping VLA and return the first element type that has a...
Definition
ExprUtils.cpp:15
clang::CodeGenUtils::isTrivialFiller
bool isTrivialFiller(const Expr *E)
Check whether E is a trivial array filler, that is, one that is equivalent to zero-initialization.
Definition
ExprUtils.cpp:100
clang::CodeGenUtils::isCheapEnoughToEvaluateUnconditionally
bool isCheapEnoughToEvaluateUnconditionally(const Expr *E, const ASTContext &Ctx)
Check whether E is cheap enough and side-effect-free enough to evaluate unconditionally instead of co...
Definition
ExprUtils.cpp:87
clang::CodeGenUtils::isBlockVarRef
bool isBlockVarRef(const Expr *E)
Check whether the value of E is possibly a reference to or into a __block variable.
Definition
ExprUtils.cpp:24
clang::CodeGenUtils::onlyHasInlineBuiltinDeclaration
bool onlyHasInlineBuiltinDeclaration(const FunctionDecl *FD)
Detect the unusual situation where an inline version of a builtin is shadowed by a non-inline version...
Definition
ExprUtils.cpp:121
clang::CodeGenUtils::checkVarTypeForConstantEmission
ConstantEmissionKind checkVarTypeForConstantEmission(QualType Type)
Can we constant-emit a load of a reference to a variable of the given type?
Definition
ExprUtils.cpp:149
clang::CodeGenUtils::isConstantEmittableObjectType
bool isConstantEmittableObjectType(QualType Type)
Given an object of the canonical type Type, can we safely copy a value out of it based on its initial...
Definition
ExprUtils.cpp:128
clang::CodeGenUtils::ConstantEmissionKind
ConstantEmissionKind
How a reference to a variable can be emitted as a constant.
Definition
ExprUtils.h:54
clang::CodeGenUtils::CEK_AsValueOnly
@ CEK_AsValueOnly
Definition
ExprUtils.h:58
clang::CodeGenUtils::CEK_None
@ CEK_None
Definition
ExprUtils.h:55
clang::CodeGenUtils::CEK_AsReferenceOnly
@ CEK_AsReferenceOnly
Definition
ExprUtils.h:56
clang::CodeGenUtils::CEK_AsValueOrReference
@ CEK_AsValueOrReference
Definition
ExprUtils.h:57
clang::ReflectionKind::Type
@ Type
Definition
Reflection.h:22
Generated on
for clang by
1.14.0