aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/AST/ExprConstant.cpp
diff options
context:
space:
mode:
authorTimm Baeder <tbaeder@redhat.com>2023-11-17 16:13:23 +0100
committerGitHub <noreply@github.com>2023-11-17 16:13:23 +0100
commit965d301dff1837e2a7a0671c549bcf7ddb350486 (patch)
tree66886215431b0bab853977bb3b684b03c31929e7 /clang/lib/AST/ExprConstant.cpp
parent8f81c605f5f450c4b4b641f805935a85b9409d98 (diff)
downloadllvm-965d301dff1837e2a7a0671c549bcf7ddb350486.zip
llvm-965d301dff1837e2a7a0671c549bcf7ddb350486.tar.gz
llvm-965d301dff1837e2a7a0671c549bcf7ddb350486.tar.bz2
[clang][Interp] Implement __builtin_classify_type (#71972)
This adds some infrastructure for unevaluated builtin calls, and uses the implementation from ExprConstant.cpp
Diffstat (limited to 'clang/lib/AST/ExprConstant.cpp')
-rw-r--r--clang/lib/AST/ExprConstant.cpp38
1 files changed, 3 insertions, 35 deletions
diff --git a/clang/lib/AST/ExprConstant.cpp b/clang/lib/AST/ExprConstant.cpp
index 4fb444e..3a41e97 100644
--- a/clang/lib/AST/ExprConstant.cpp
+++ b/clang/lib/AST/ExprConstant.cpp
@@ -32,6 +32,7 @@
//
//===----------------------------------------------------------------------===//
+#include "ExprConstShared.h"
#include "Interp/Context.h"
#include "Interp/Frame.h"
#include "Interp/State.h"
@@ -11492,43 +11493,10 @@ bool IntExprEvaluator::CheckReferencedDecl(const Expr* E, const Decl* D) {
return false;
}
-/// Values returned by __builtin_classify_type, chosen to match the values
-/// produced by GCC's builtin.
-enum class GCCTypeClass {
- None = -1,
- Void = 0,
- Integer = 1,
- // GCC reserves 2 for character types, but instead classifies them as
- // integers.
- Enum = 3,
- Bool = 4,
- Pointer = 5,
- // GCC reserves 6 for references, but appears to never use it (because
- // expressions never have reference type, presumably).
- PointerToDataMember = 7,
- RealFloat = 8,
- Complex = 9,
- // GCC reserves 10 for functions, but does not use it since GCC version 6 due
- // to decay to pointer. (Prior to version 6 it was only used in C++ mode).
- // GCC claims to reserve 11 for pointers to member functions, but *actually*
- // uses 12 for that purpose, same as for a class or struct. Maybe it
- // internally implements a pointer to member as a struct? Who knows.
- PointerToMemberFunction = 12, // Not a bug, see above.
- ClassOrStruct = 12,
- Union = 13,
- // GCC reserves 14 for arrays, but does not use it since GCC version 6 due to
- // decay to pointer. (Prior to version 6 it was only used in C++ mode).
- // GCC reserves 15 for strings, but actually uses 5 (pointer) for string
- // literals.
- // Lang = 16,
- // OpaqueType = 17,
- BitInt = 18
-};
-
/// EvaluateBuiltinClassifyType - Evaluate __builtin_classify_type the same way
/// as GCC.
-static GCCTypeClass
-EvaluateBuiltinClassifyType(QualType T, const LangOptions &LangOpts) {
+GCCTypeClass EvaluateBuiltinClassifyType(QualType T,
+ const LangOptions &LangOpts) {
assert(!T->isDependentType() && "unexpected dependent type");
QualType CanTy = T.getCanonicalType();