clang 24.0.0git
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
19
20namespace 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.
24QualType 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.
29bool 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.
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.
39bool 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.
44bool 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.
52
53/// How a reference to a variable can be emitted as a constant.
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.
71
72} // namespace clang::CodeGenUtils
73
74#endif // LLVM_CLANG_CODEGENUTILS_EXPRUTILS_H
Defines the clang::ASTContext interface.
A (possibly-)qualified type.
Definition TypeBase.h:938
The base class of the type hierarchy.
Definition TypeBase.h:1879
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
bool isTrivialFiller(const Expr *E)
Check whether E is a trivial array filler, that is, one that is equivalent to zero-initialization.
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
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
bool onlyHasInlineBuiltinDeclaration(const FunctionDecl *FD)
Detect the unusual situation where an inline version of a builtin is shadowed by a non-inline version...
ConstantEmissionKind checkVarTypeForConstantEmission(QualType Type)
Can we constant-emit a load of a reference to a variable of the given type?
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...
ConstantEmissionKind
How a reference to a variable can be emitted as a constant.
Definition ExprUtils.h:54