clang 20.0.0git
ExprConstShared.h
Go to the documentation of this file.
1//===--- ExprConstShared.h - Shared consetxpr functionality ----*- 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// Shared functionality between the new constant expression
10// interpreter (AST/ByteCode/) and the current one (ExprConstant.cpp).
11//
12//===----------------------------------------------------------------------===//
13
14#ifndef LLVM_CLANG_LIB_AST_EXPRCONSTSHARED_H
15#define LLVM_CLANG_LIB_AST_EXPRCONSTSHARED_H
16
18
19namespace llvm {
20class APFloat;
21}
22namespace clang {
23class QualType;
24class LangOptions;
25class ASTContext;
26class CharUnits;
27class Expr;
28} // namespace clang
29using namespace clang;
30/// Values returned by __builtin_classify_type, chosen to match the values
31/// produced by GCC's builtin.
32enum class GCCTypeClass {
33 None = -1,
34 Void = 0,
35 Integer = 1,
36 // GCC reserves 2 for character types, but instead classifies them as
37 // integers.
38 Enum = 3,
39 Bool = 4,
40 Pointer = 5,
41 // GCC reserves 6 for references, but appears to never use it (because
42 // expressions never have reference type, presumably).
44 RealFloat = 8,
45 Complex = 9,
46 // GCC reserves 10 for functions, but does not use it since GCC version 6 due
47 // to decay to pointer. (Prior to version 6 it was only used in C++ mode).
48 // GCC claims to reserve 11 for pointers to member functions, but *actually*
49 // uses 12 for that purpose, same as for a class or struct. Maybe it
50 // internally implements a pointer to member as a struct? Who knows.
51 PointerToMemberFunction = 12, // Not a bug, see above.
52 ClassOrStruct = 12,
53 Union = 13,
54 // GCC reserves 14 for arrays, but does not use it since GCC version 6 due to
55 // decay to pointer. (Prior to version 6 it was only used in C++ mode).
56 // GCC reserves 15 for strings, but actually uses 5 (pointer) for string
57 // literals.
58 // Lang = 16,
59 // OpaqueType = 17,
60 BitInt = 18,
61 Vector = 19
62};
63
65 const LangOptions &LangOpts);
66
67void HandleComplexComplexMul(llvm::APFloat A, llvm::APFloat B, llvm::APFloat C,
68 llvm::APFloat D, llvm::APFloat &ResR,
69 llvm::APFloat &ResI);
70void HandleComplexComplexDiv(llvm::APFloat A, llvm::APFloat B, llvm::APFloat C,
71 llvm::APFloat D, llvm::APFloat &ResR,
72 llvm::APFloat &ResI);
73
74CharUnits GetAlignOfExpr(const ASTContext &Ctx, const Expr *E,
75 UnaryExprOrTypeTrait ExprKind);
76
77#endif
const Decl * D
Expr * E
CharUnits GetAlignOfExpr(const ASTContext &Ctx, const Expr *E, UnaryExprOrTypeTrait ExprKind)
GCCTypeClass EvaluateBuiltinClassifyType(QualType T, const LangOptions &LangOpts)
EvaluateBuiltinClassifyType - Evaluate __builtin_classify_type the same way as GCC.
void HandleComplexComplexMul(llvm::APFloat A, llvm::APFloat B, llvm::APFloat C, llvm::APFloat D, llvm::APFloat &ResR, llvm::APFloat &ResI)
GCCTypeClass
Values returned by __builtin_classify_type, chosen to match the values produced by GCC's builtin.
@ PointerToMemberFunction
void HandleComplexComplexDiv(llvm::APFloat A, llvm::APFloat B, llvm::APFloat C, llvm::APFloat D, llvm::APFloat &ResR, llvm::APFloat &ResI)
Defines enumerations for the type traits support.
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
Definition: ASTContext.h:188
CharUnits - This is an opaque type for sizes expressed in character units.
Definition: CharUnits.h:38
This represents one expression.
Definition: Expr.h:110
Keeps track of the various options that can be enabled, which controls the dialect of C or C++ that i...
Definition: LangOptions.h:499
A (possibly-)qualified type.
Definition: Type.h:929
llvm::APFloat APFloat
Definition: Floating.h:23
The JSON file list parser is used to communicate input to InstallAPI.
UnaryExprOrTypeTrait
Names for the "expression or type" traits.
Definition: TypeTraits.h:51
const FunctionProtoType * T
Diagnostic wrappers for TextAPI types for error reporting.
Definition: Dominators.h:30