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
17#include "clang/Basic/TypeTraits.h"
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).
43 PointerToDataMember = 7,
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
64GCCTypeClass EvaluateBuiltinClassifyType(QualType T,
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
78

Provided by KDAB

Privacy Policy
Update your C++ knowledge – Modern C++11/14/17 Training
Find out more

source code of clang/lib/AST/ExprConstShared.h