diff options
author | John McCall <rjmccall@apple.com> | 2011-10-18 21:02:43 +0000 |
---|---|---|
committer | John McCall <rjmccall@apple.com> | 2011-10-18 21:02:43 +0000 |
commit | e0a22d06888c13989b3f72db319f1d498bf69153 (patch) | |
tree | b32f178c32688b4c8cadabfac0d387f21f235e3d /lib | |
parent | ebaf0e6ab743394dda086a01b457838cb6e589a8 (diff) |
Macro metaprogramming for builtin types.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@142420 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r-- | lib/AST/ASTImporter.cpp | 63 | ||||
-rw-r--r-- | lib/AST/Expr.cpp | 2 | ||||
-rw-r--r-- | lib/AST/ExprClassification.cpp | 6 | ||||
-rw-r--r-- | lib/AST/ItaniumMangle.cpp | 8 | ||||
-rw-r--r-- | lib/AST/MicrosoftMangle.cpp | 14 | ||||
-rw-r--r-- | lib/CodeGen/CGDebugInfo.cpp | 14 | ||||
-rw-r--r-- | lib/Sema/SemaExpr.cpp | 35 |
7 files changed, 37 insertions, 105 deletions
diff --git a/lib/AST/ASTImporter.cpp b/lib/AST/ASTImporter.cpp index 7e252d1d16..068425e250 100644 --- a/lib/AST/ASTImporter.cpp +++ b/lib/AST/ASTImporter.cpp @@ -1324,9 +1324,17 @@ QualType ASTNodeImporter::VisitType(const Type *T) { QualType ASTNodeImporter::VisitBuiltinType(const BuiltinType *T) { switch (T->getKind()) { - case BuiltinType::Void: return Importer.getToContext().VoidTy; - case BuiltinType::Bool: return Importer.getToContext().BoolTy; - +#define SHARED_SINGLETON_TYPE(Expansion) +#define BUILTIN_TYPE(Id, SingletonId) \ + case BuiltinType::Id: return Importer.getToContext().SingletonId; +#include "clang/AST/BuiltinTypes.def" + + // FIXME: for Char16, Char32, and NullPtr, make sure that the "to" + // context supports C++. + + // FIXME: for ObjCId, ObjCClass, and ObjCSel, make sure that the "to" + // context supports ObjC. + case BuiltinType::Char_U: // The context we're importing from has an unsigned 'char'. If we're // importing into a context with a signed 'char', translate to @@ -1336,23 +1344,6 @@ QualType ASTNodeImporter::VisitBuiltinType(const BuiltinType *T) { return Importer.getToContext().CharTy; - case BuiltinType::UChar: return Importer.getToContext().UnsignedCharTy; - - case BuiltinType::Char16: - // FIXME: Make sure that the "to" context supports C++! - return Importer.getToContext().Char16Ty; - - case BuiltinType::Char32: - // FIXME: Make sure that the "to" context supports C++! - return Importer.getToContext().Char32Ty; - - case BuiltinType::UShort: return Importer.getToContext().UnsignedShortTy; - case BuiltinType::UInt: return Importer.getToContext().UnsignedIntTy; - case BuiltinType::ULong: return Importer.getToContext().UnsignedLongTy; - case BuiltinType::ULongLong: - return Importer.getToContext().UnsignedLongLongTy; - case BuiltinType::UInt128: return Importer.getToContext().UnsignedInt128Ty; - case BuiltinType::Char_S: // The context we're importing from has an unsigned 'char'. If we're // importing into a context with a signed 'char', translate to @@ -1362,43 +1353,11 @@ QualType ASTNodeImporter::VisitBuiltinType(const BuiltinType *T) { return Importer.getToContext().CharTy; - case BuiltinType::SChar: return Importer.getToContext().SignedCharTy; case BuiltinType::WChar_S: case BuiltinType::WChar_U: // FIXME: If not in C++, shall we translate to the C equivalent of // wchar_t? return Importer.getToContext().WCharTy; - - case BuiltinType::Short : return Importer.getToContext().ShortTy; - case BuiltinType::Int : return Importer.getToContext().IntTy; - case BuiltinType::Long : return Importer.getToContext().LongTy; - case BuiltinType::LongLong : return Importer.getToContext().LongLongTy; - case BuiltinType::Int128 : return Importer.getToContext().Int128Ty; - case BuiltinType::Half: return Importer.getToContext().HalfTy; - case BuiltinType::Float: return Importer.getToContext().FloatTy; - case BuiltinType::Double: return Importer.getToContext().DoubleTy; - case BuiltinType::LongDouble: return Importer.getToContext().LongDoubleTy; - - case BuiltinType::NullPtr: - // FIXME: Make sure that the "to" context supports C++0x! - return Importer.getToContext().NullPtrTy; - - case BuiltinType::Overload: return Importer.getToContext().OverloadTy; - case BuiltinType::Dependent: return Importer.getToContext().DependentTy; - case BuiltinType::UnknownAny: return Importer.getToContext().UnknownAnyTy; - case BuiltinType::BoundMember: return Importer.getToContext().BoundMemberTy; - case BuiltinType::ARCUnbridgedCast: - return Importer.getToContext().ARCUnbridgedCastTy; - - case BuiltinType::ObjCId: - // FIXME: Make sure that the "to" context supports Objective-C! - return Importer.getToContext().ObjCBuiltinIdTy; - - case BuiltinType::ObjCClass: - return Importer.getToContext().ObjCBuiltinClassTy; - - case BuiltinType::ObjCSel: - return Importer.getToContext().ObjCBuiltinSelTy; } return QualType(); diff --git a/lib/AST/Expr.cpp b/lib/AST/Expr.cpp index b0bcfe09f6..427c331ed0 100644 --- a/lib/AST/Expr.cpp +++ b/lib/AST/Expr.cpp @@ -1766,7 +1766,7 @@ bool Expr::isBoundMemberFunction(ASTContext &Ctx) const { } QualType Expr::findBoundMemberType(const Expr *expr) { - assert(expr->getType()->isSpecificPlaceholderType(BuiltinType::BoundMember)); + assert(expr->hasPlaceholderType(BuiltinType::BoundMember)); // Bound member expressions are always one of these possibilities: // x->m x.m x->*y x.*y diff --git a/lib/AST/ExprClassification.cpp b/lib/AST/ExprClassification.cpp index 49c68213aa..594ae69ec4 100644 --- a/lib/AST/ExprClassification.cpp +++ b/lib/AST/ExprClassification.cpp @@ -480,14 +480,16 @@ static Cl::Kinds ClassifyBinaryOp(ASTContext &Ctx, const BinaryOperator *E) { // is a pointer to a data member is of the same value category as its first // operand. if (E->getOpcode() == BO_PtrMemD) - return (E->getType()->isFunctionType() || E->getType() == Ctx.BoundMemberTy) + return (E->getType()->isFunctionType() || + E->hasPlaceholderType(BuiltinType::BoundMember)) ? Cl::CL_MemberFunction : ClassifyInternal(Ctx, E->getLHS()); // C++ [expr.mptr.oper]p6: The result of an ->* expression is an lvalue if its // second operand is a pointer to data member and a prvalue otherwise. if (E->getOpcode() == BO_PtrMemI) - return (E->getType()->isFunctionType() || E->getType() == Ctx.BoundMemberTy) + return (E->getType()->isFunctionType() || + E->hasPlaceholderType(BuiltinType::BoundMember)) ? Cl::CL_MemberFunction : Cl::CL_LValue; diff --git a/lib/AST/ItaniumMangle.cpp b/lib/AST/ItaniumMangle.cpp index f7af57ef66..889cf513bb 100644 --- a/lib/AST/ItaniumMangle.cpp +++ b/lib/AST/ItaniumMangle.cpp @@ -1735,11 +1735,11 @@ void CXXNameMangler::mangleType(const BuiltinType *T) { case BuiltinType::LongDouble: Out << 'e'; break; case BuiltinType::NullPtr: Out << "Dn"; break; - case BuiltinType::Overload: +#define BUILTIN_TYPE(Id, SingletonId) +#define PLACEHOLDER_TYPE(Id, SingletonId) \ + case BuiltinType::Id: +#include "clang/AST/BuiltinTypes.def" case BuiltinType::Dependent: - case BuiltinType::BoundMember: - case BuiltinType::UnknownAny: - case BuiltinType::ARCUnbridgedCast: llvm_unreachable("mangling a placeholder type"); break; case BuiltinType::ObjCId: Out << "11objc_object"; break; diff --git a/lib/AST/MicrosoftMangle.cpp b/lib/AST/MicrosoftMangle.cpp index 98fc2d52cb..1a18ef1dc0 100644 --- a/lib/AST/MicrosoftMangle.cpp +++ b/lib/AST/MicrosoftMangle.cpp @@ -701,13 +701,13 @@ void MicrosoftCXXNameMangler::mangleType(const BuiltinType *T) { case BuiltinType::WChar_S: case BuiltinType::WChar_U: Out << "_W"; break; - case BuiltinType::Overload: +#define BUILTIN_TYPE(Id, SingletonId) +#define PLACEHOLDER_TYPE(Id, SingletonId) \ + case BuiltinType::Id: +#include "clang/AST/BuiltinTypes.def" case BuiltinType::Dependent: - case BuiltinType::UnknownAny: - case BuiltinType::BoundMember: - case BuiltinType::ARCUnbridgedCast: - llvm_unreachable( - "Overloaded and dependent types shouldn't get to name mangling"); + llvm_unreachable("placeholder types shouldn't get to name mangling"); + case BuiltinType::ObjCId: Out << "PAUobjc_object@@"; break; case BuiltinType::ObjCClass: Out << "PAUobjc_class@@"; break; case BuiltinType::ObjCSel: Out << "PAUobjc_selector@@"; break; @@ -716,7 +716,7 @@ void MicrosoftCXXNameMangler::mangleType(const BuiltinType *T) { case BuiltinType::Char32: case BuiltinType::Half: case BuiltinType::NullPtr: - llvm_unreachable("Don't know how to mangle this type"); + assert(0 && "Don't know how to mangle this type yet"); } } diff --git a/lib/CodeGen/CGDebugInfo.cpp b/lib/CodeGen/CGDebugInfo.cpp index b894326bd8..d4b566bb20 100644 --- a/lib/CodeGen/CGDebugInfo.cpp +++ b/lib/CodeGen/CGDebugInfo.cpp @@ -321,16 +321,12 @@ llvm::DIType CGDebugInfo::CreateType(const BuiltinType *BT) { unsigned Encoding = 0; const char *BTName = NULL; switch (BT->getKind()) { +#define BUILTIN_TYPE(Id, SingletonId) +#define PLACEHOLDER_TYPE(Id, SingletonId) \ + case BuiltinType::Id: +#include "clang/AST/BuiltinTypes.def" case BuiltinType::Dependent: - llvm_unreachable("Unexpected builtin type Dependent"); - case BuiltinType::Overload: - llvm_unreachable("Unexpected builtin type Overload"); - case BuiltinType::BoundMember: - llvm_unreachable("Unexpected builtin type BoundMember"); - case BuiltinType::UnknownAny: - llvm_unreachable("Unexpected builtin type UnknownAny"); - case BuiltinType::ARCUnbridgedCast: - llvm_unreachable("Unexpected builtin type ARCUnbridgedCast"); + llvm_unreachable("Unexpected builtin type"); case BuiltinType::NullPtr: return DBuilder. createNullPtrType(BT->getName(CGM.getContext().getLangOptions())); diff --git a/lib/Sema/SemaExpr.cpp b/lib/Sema/SemaExpr.cpp index d3a8ff95d2..5fd7e4e22b 100644 --- a/lib/Sema/SemaExpr.cpp +++ b/lib/Sema/SemaExpr.cpp @@ -10092,36 +10092,11 @@ ExprResult Sema::CheckPlaceholderExpr(Expr *E) { case BuiltinType::UnknownAny: return diagnoseUnknownAnyExpr(*this, E); - // Everything else should be impossible. TODO: metaprogram this. - case BuiltinType::Void: - case BuiltinType::Bool: - case BuiltinType::Char_U: - case BuiltinType::UChar: - case BuiltinType::WChar_U: - case BuiltinType::Char16: - case BuiltinType::Char32: - case BuiltinType::UShort: - case BuiltinType::UInt: - case BuiltinType::ULong: - case BuiltinType::ULongLong: - case BuiltinType::UInt128: - case BuiltinType::Char_S: - case BuiltinType::SChar: - case BuiltinType::WChar_S: - case BuiltinType::Short: - case BuiltinType::Int: - case BuiltinType::Long: - case BuiltinType::LongLong: - case BuiltinType::Int128: - case BuiltinType::Half: - case BuiltinType::Float: - case BuiltinType::Double: - case BuiltinType::LongDouble: - case BuiltinType::NullPtr: - case BuiltinType::ObjCId: - case BuiltinType::ObjCClass: - case BuiltinType::ObjCSel: - case BuiltinType::Dependent: + // Everything else should be impossible. +#define BUILTIN_TYPE(Id, SingletonId) \ + case BuiltinType::Id: +#define PLACEHOLDER_TYPE(Id, SingletonId) +#include "clang/AST/BuiltinTypes.def" break; } |