xref: /freebsd-src/contrib/llvm-project/clang/lib/AST/ExprConstShared.h (revision 5f757f3ff9144b609b3c433dfd370cc6bdc191ad)
1*5f757f3fSDimitry Andric //===--- ExprConstShared.h - Shared consetxpr functionality ----*- C++ -*-===//
2*5f757f3fSDimitry Andric //
3*5f757f3fSDimitry Andric // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4*5f757f3fSDimitry Andric // See https://llvm.org/LICENSE.txt for license information.
5*5f757f3fSDimitry Andric // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6*5f757f3fSDimitry Andric //
7*5f757f3fSDimitry Andric //===----------------------------------------------------------------------===//
8*5f757f3fSDimitry Andric //
9*5f757f3fSDimitry Andric // Shared functionality between the new constant expression
10*5f757f3fSDimitry Andric // interpreter (AST/Interp/) and the current one (ExprConstant.cpp).
11*5f757f3fSDimitry Andric //
12*5f757f3fSDimitry Andric //===----------------------------------------------------------------------===//
13*5f757f3fSDimitry Andric 
14*5f757f3fSDimitry Andric #ifndef LLVM_CLANG_LIB_AST_EXPRCONSTSHARED_H
15*5f757f3fSDimitry Andric #define LLVM_CLANG_LIB_AST_EXPRCONSTSHARED_H
16*5f757f3fSDimitry Andric 
17*5f757f3fSDimitry Andric namespace clang {
18*5f757f3fSDimitry Andric class QualType;
19*5f757f3fSDimitry Andric class LangOptions;
20*5f757f3fSDimitry Andric } // namespace clang
21*5f757f3fSDimitry Andric using namespace clang;
22*5f757f3fSDimitry Andric /// Values returned by __builtin_classify_type, chosen to match the values
23*5f757f3fSDimitry Andric /// produced by GCC's builtin.
24*5f757f3fSDimitry Andric enum class GCCTypeClass {
25*5f757f3fSDimitry Andric   None = -1,
26*5f757f3fSDimitry Andric   Void = 0,
27*5f757f3fSDimitry Andric   Integer = 1,
28*5f757f3fSDimitry Andric   // GCC reserves 2 for character types, but instead classifies them as
29*5f757f3fSDimitry Andric   // integers.
30*5f757f3fSDimitry Andric   Enum = 3,
31*5f757f3fSDimitry Andric   Bool = 4,
32*5f757f3fSDimitry Andric   Pointer = 5,
33*5f757f3fSDimitry Andric   // GCC reserves 6 for references, but appears to never use it (because
34*5f757f3fSDimitry Andric   // expressions never have reference type, presumably).
35*5f757f3fSDimitry Andric   PointerToDataMember = 7,
36*5f757f3fSDimitry Andric   RealFloat = 8,
37*5f757f3fSDimitry Andric   Complex = 9,
38*5f757f3fSDimitry Andric   // GCC reserves 10 for functions, but does not use it since GCC version 6 due
39*5f757f3fSDimitry Andric   // to decay to pointer. (Prior to version 6 it was only used in C++ mode).
40*5f757f3fSDimitry Andric   // GCC claims to reserve 11 for pointers to member functions, but *actually*
41*5f757f3fSDimitry Andric   // uses 12 for that purpose, same as for a class or struct. Maybe it
42*5f757f3fSDimitry Andric   // internally implements a pointer to member as a struct?  Who knows.
43*5f757f3fSDimitry Andric   PointerToMemberFunction = 12, // Not a bug, see above.
44*5f757f3fSDimitry Andric   ClassOrStruct = 12,
45*5f757f3fSDimitry Andric   Union = 13,
46*5f757f3fSDimitry Andric   // GCC reserves 14 for arrays, but does not use it since GCC version 6 due to
47*5f757f3fSDimitry Andric   // decay to pointer. (Prior to version 6 it was only used in C++ mode).
48*5f757f3fSDimitry Andric   // GCC reserves 15 for strings, but actually uses 5 (pointer) for string
49*5f757f3fSDimitry Andric   // literals.
50*5f757f3fSDimitry Andric   // Lang = 16,
51*5f757f3fSDimitry Andric   // OpaqueType = 17,
52*5f757f3fSDimitry Andric   BitInt = 18,
53*5f757f3fSDimitry Andric   Vector = 19
54*5f757f3fSDimitry Andric };
55*5f757f3fSDimitry Andric 
56*5f757f3fSDimitry Andric GCCTypeClass EvaluateBuiltinClassifyType(QualType T,
57*5f757f3fSDimitry Andric                                          const LangOptions &LangOpts);
58*5f757f3fSDimitry Andric 
59*5f757f3fSDimitry Andric #endif
60