brintos

brintos / llvm-project-archived public Read only

0
0
Text · 2.8 KiB · 401ae62 Raw
78 lines · c
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-exception6//7//===----------------------------------------------------------------------===//8//9// Shared functionality between the new constant expression10// interpreter (AST/ByteCode/) and the current one (ExprConstant.cpp).11//12//===----------------------------------------------------------------------===//13 14#ifndef LLVM_CLANG_LIB_AST_EXPRCONSTSHARED_H15#define LLVM_CLANG_LIB_AST_EXPRCONSTSHARED_H16 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 clang29using namespace clang;30/// Values returned by __builtin_classify_type, chosen to match the values31/// 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 as37  // integers.38  Enum = 3,39  Bool = 4,40  Pointer = 5,41  // GCC reserves 6 for references, but appears to never use it (because42  // 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 due47  // 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 it50  // 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 to55  // 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 string57  // literals.58  // Lang = 16,59  // OpaqueType = 17,60  BitInt = 18,61  Vector = 1962};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#endif78