From f5f7d864f5067d1ea4bff7fcf41b53a43b7b48ba Mon Sep 17 00:00:00 2001 From: Anders Carlsson Date: Tue, 29 Dec 2009 07:07:36 +0000 Subject: [PATCH] Get rid of FixedWidthIntType, as suggested by Chris and Eli. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@92246 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/clang/AST/ASTContext.h | 5 ----- include/clang/AST/Type.h | 22 ---------------------- include/clang/AST/TypeLoc.h | 7 ------- include/clang/AST/TypeNodes.def | 2 -- include/clang/Frontend/PCHBitCodes.h | 2 -- include/clang/Frontend/TypeXML.def | 6 ------ lib/AST/ASTContext.cpp | 28 ---------------------------- lib/AST/Type.cpp | 22 ++-------------------- lib/AST/TypePrinter.cpp | 15 --------------- lib/CodeGen/CGDebugInfo.cpp | 9 ++++----- lib/CodeGen/CodeGenTypes.cpp | 3 --- lib/CodeGen/Mangle.cpp | 4 ---- lib/Frontend/PCHReader.cpp | 8 -------- lib/Frontend/PCHWriter.cpp | 10 ---------- lib/Sema/Sema.cpp | 9 +-------- lib/Sema/SemaDeclAttr.cpp | 5 ++++- lib/Sema/SemaTemplateDeduction.cpp | 1 - lib/Sema/TreeTransform.h | 10 ---------- 18 files changed, 11 insertions(+), 157 deletions(-) diff --git a/include/clang/AST/ASTContext.h b/include/clang/AST/ASTContext.h index e815c5edbe..2d4123eb17 100644 --- a/include/clang/AST/ASTContext.h +++ b/include/clang/AST/ASTContext.h @@ -115,9 +115,6 @@ class ASTContext { /// \brief Mapping from ObjCContainers to their ObjCImplementations. llvm::DenseMap ObjCImpls; - llvm::DenseMap SignedFixedWidthIntTypes; - llvm::DenseMap UnsignedFixedWidthIntTypes; - /// BuiltinVaListType - built-in va list type. /// This is initially null and set by Sema::LazilyCreateBuiltin when /// a builtin that takes a valist is encountered. @@ -725,8 +722,6 @@ public: void setBuiltinVaListType(QualType T); QualType getBuiltinVaListType() const { return BuiltinVaListType; } - QualType getFixedWidthIntType(unsigned Width, bool Signed); - /// getCVRQualifiedType - Returns a type with additional const, /// volatile, or restrict qualifiers. QualType getCVRQualifiedType(QualType T, unsigned CVR) { diff --git a/include/clang/AST/Type.h b/include/clang/AST/Type.h index d22a646ece..a27c4d7b05 100644 --- a/include/clang/AST/Type.h +++ b/include/clang/AST/Type.h @@ -1049,28 +1049,6 @@ public: static bool classof(const BuiltinType *) { return true; } }; -/// FixedWidthIntType - Used for arbitrary width types that we either don't -/// want to or can't map to named integer types. These always have a lower -/// integer rank than builtin types of the same width. -class FixedWidthIntType : public Type { -private: - unsigned Width; - bool Signed; -public: - FixedWidthIntType(unsigned W, bool S) : Type(FixedWidthInt, QualType(), false), - Width(W), Signed(S) {} - - unsigned getWidth() const { return Width; } - bool isSigned() const { return Signed; } - const char *getName() const; - - bool isSugared() const { return false; } - QualType desugar() const { return QualType(this, 0); } - - static bool classof(const Type *T) { return T->getTypeClass() == FixedWidthInt; } - static bool classof(const FixedWidthIntType *) { return true; } -}; - /// ComplexType - C99 6.2.5p11 - Complex values. This supports the C99 complex /// types (_Complex float etc) as well as the GCC integer complex extensions. /// diff --git a/include/clang/AST/TypeLoc.h b/include/clang/AST/TypeLoc.h index a9b7f7e943..3e74d07ff7 100644 --- a/include/clang/AST/TypeLoc.h +++ b/include/clang/AST/TypeLoc.h @@ -1023,13 +1023,6 @@ class DependentSizedExtVectorTypeLoc : DependentSizedExtVectorType> { }; -// FIXME: I'm not sure how you actually specify these; with attributes? -class FixedWidthIntTypeLoc : - public InheritingConcreteTypeLoc { -}; - // FIXME: location of the '_Complex' keyword. class ComplexTypeLoc : public InheritingConcreteTypeLoc(T)->getWidth(); - Width = std::max(llvm::NextPowerOf2(Width - 1), (uint64_t)8); - Align = Width; - break; case Type::ObjCObjectPointer: Width = Target.getPointerWidth(0); Align = Target.getPointerAlign(0); @@ -1274,15 +1267,6 @@ QualType ASTContext::getComplexType(QualType T) { return QualType(New, 0); } -QualType ASTContext::getFixedWidthIntType(unsigned Width, bool Signed) { - llvm::DenseMap &Map = Signed ? - SignedFixedWidthIntTypes : UnsignedFixedWidthIntTypes; - FixedWidthIntType *&Entry = Map[Width]; - if (!Entry) - Entry = new FixedWidthIntType(Width, Signed); - return QualType(Entry, 0); -} - /// getPointerType - Return the uniqued reference to the type for a pointer to /// the specified type. QualType ASTContext::getPointerType(QualType T) { @@ -2689,12 +2673,6 @@ unsigned ASTContext::getIntegerRank(Type *T) { if (T->isSpecificBuiltinType(BuiltinType::Char32)) T = getFromTargetType(Target.getChar32Type()).getTypePtr(); - // There are two things which impact the integer rank: the width, and - // the ordering of builtins. The builtin ordering is encoded in the - // bottom three bits; the width is encoded in the bits above that. - if (FixedWidthIntType* FWIT = dyn_cast(T)) - return FWIT->getWidth() << 3; - switch (cast(T)->getKind()) { default: assert(0 && "getIntegerRank(): not a built-in integer"); case BuiltinType::Bool: @@ -4507,9 +4485,6 @@ QualType ASTContext::mergeTypes(QualType LHS, QualType RHS) { return QualType(); } - case Type::FixedWidthInt: - // Distinct fixed-width integers are not compatible. - return QualType(); case Type::TemplateSpecialization: assert(false && "Dependent types have no size"); break; @@ -4525,9 +4500,6 @@ QualType ASTContext::mergeTypes(QualType LHS, QualType RHS) { unsigned ASTContext::getIntWidth(QualType T) { if (T->isBooleanType()) return 1; - if (FixedWidthIntType *FWIT = dyn_cast(T)) { - return FWIT->getWidth(); - } if (EnumType *ET = dyn_cast(T)) T = ET->getDecl()->getIntegerType(); // For builtin types, just use the standard type sizing method diff --git a/lib/AST/Type.cpp b/lib/AST/Type.cpp index bed7f9b6c7..e0055f1878 100644 --- a/lib/AST/Type.cpp +++ b/lib/AST/Type.cpp @@ -387,8 +387,6 @@ bool Type::isIntegerType() const { // FIXME: In C++, enum types are never integer types. if (TT->getDecl()->isEnum() && TT->getDecl()->isDefinition()) return true; - if (isa(CanonicalType)) - return true; if (const VectorType *VT = dyn_cast(CanonicalType)) return VT->getElementType()->isIntegerType(); return false; @@ -397,13 +395,11 @@ bool Type::isIntegerType() const { bool Type::isIntegralType() const { if (const BuiltinType *BT = dyn_cast(CanonicalType)) return BT->getKind() >= BuiltinType::Bool && - BT->getKind() <= BuiltinType::LongLong; + BT->getKind() <= BuiltinType::Int128; if (const TagType *TT = dyn_cast(CanonicalType)) if (TT->getDecl()->isEnum() && TT->getDecl()->isDefinition()) return true; // Complete enum types are integral. // FIXME: In C++, enum types are never integral. - if (isa(CanonicalType)) - return true; return false; } @@ -453,16 +449,12 @@ bool Type::isAnyCharacterType() const { bool Type::isSignedIntegerType() const { if (const BuiltinType *BT = dyn_cast(CanonicalType)) { return BT->getKind() >= BuiltinType::Char_S && - BT->getKind() <= BuiltinType::LongLong; + BT->getKind() <= BuiltinType::Int128; } if (const EnumType *ET = dyn_cast(CanonicalType)) return ET->getDecl()->getIntegerType()->isSignedIntegerType(); - if (const FixedWidthIntType *FWIT = - dyn_cast(CanonicalType)) - return FWIT->isSigned(); - if (const VectorType *VT = dyn_cast(CanonicalType)) return VT->getElementType()->isSignedIntegerType(); return false; @@ -481,10 +473,6 @@ bool Type::isUnsignedIntegerType() const { if (const EnumType *ET = dyn_cast(CanonicalType)) return ET->getDecl()->getIntegerType()->isUnsignedIntegerType(); - if (const FixedWidthIntType *FWIT = - dyn_cast(CanonicalType)) - return !FWIT->isSigned(); - if (const VectorType *VT = dyn_cast(CanonicalType)) return VT->getElementType()->isUnsignedIntegerType(); return false; @@ -515,8 +503,6 @@ bool Type::isRealType() const { BT->getKind() <= BuiltinType::LongDouble; if (const TagType *TT = dyn_cast(CanonicalType)) return TT->getDecl()->isEnum() && TT->getDecl()->isDefinition(); - if (isa(CanonicalType)) - return true; if (const VectorType *VT = dyn_cast(CanonicalType)) return VT->getElementType()->isRealType(); return false; @@ -530,8 +516,6 @@ bool Type::isArithmeticType() const { // GCC allows forward declaration of enum types (forbid by C99 6.7.2.3p2). // If a body isn't seen by the time we get here, return false. return ET->getDecl()->isDefinition(); - if (isa(CanonicalType)) - return true; return isa(CanonicalType) || isa(CanonicalType); } @@ -545,8 +529,6 @@ bool Type::isScalarType() const { return true; return false; } - if (isa(CanonicalType)) - return true; return isa(CanonicalType) || isa(CanonicalType) || isa(CanonicalType) || diff --git a/lib/AST/TypePrinter.cpp b/lib/AST/TypePrinter.cpp index 4a2b956172..818657c2a7 100644 --- a/lib/AST/TypePrinter.cpp +++ b/lib/AST/TypePrinter.cpp @@ -94,21 +94,6 @@ void TypePrinter::PrintBuiltin(const BuiltinType *T, std::string &S) { } } -void TypePrinter::PrintFixedWidthInt(const FixedWidthIntType *T, - std::string &S) { - // FIXME: Once we get bitwidth attribute, write as - // "int __attribute__((bitwidth(x)))". - std::string prefix = "__clang_fixedwidth"; - prefix += llvm::utostr_32(T->getWidth()); - prefix += (char)(T->isSigned() ? 'S' : 'U'); - if (S.empty()) { - S = prefix; - } else { - // Prefix the basic type, e.g. 'int X'. - S = prefix + S; - } -} - void TypePrinter::PrintComplex(const ComplexType *T, std::string &S) { Print(T->getElementType(), S); S = "_Complex " + S; diff --git a/lib/CodeGen/CGDebugInfo.cpp b/lib/CodeGen/CGDebugInfo.cpp index 5fa9da1089..19695c8781 100644 --- a/lib/CodeGen/CGDebugInfo.cpp +++ b/lib/CodeGen/CGDebugInfo.cpp @@ -917,7 +917,6 @@ llvm::DIType CGDebugInfo::CreateTypeNode(QualType Ty, // FIXME: Handle these. case Type::ExtVector: case Type::Vector: - case Type::FixedWidthInt: return llvm::DIType(); case Type::ObjCObjectPointer: @@ -1101,7 +1100,7 @@ void CGDebugInfo::EmitDeclare(const VarDecl *Decl, unsigned Tag, EltTys.push_back(FieldTy); FieldOffset += FieldSize; - FType = CGM.getContext().getFixedWidthIntType(32, true); // Int32Ty; + FType = CGM.getContext().IntTy; FieldTy = CGDebugInfo::getOrCreateType(FType, Unit); FieldSize = CGM.getContext().getTypeSize(FType); FieldAlign = CGM.getContext().getTypeAlign(FType); @@ -1112,7 +1111,7 @@ void CGDebugInfo::EmitDeclare(const VarDecl *Decl, unsigned Tag, EltTys.push_back(FieldTy); FieldOffset += FieldSize; - FType = CGM.getContext().getFixedWidthIntType(32, true); // Int32Ty; + FType = CGM.getContext().IntTy; FieldTy = CGDebugInfo::getOrCreateType(FType, Unit); FieldSize = CGM.getContext().getTypeSize(FType); FieldAlign = CGM.getContext().getTypeAlign(FType); @@ -1278,7 +1277,7 @@ void CGDebugInfo::EmitDeclare(const BlockDeclRefExpr *BDRE, unsigned Tag, EltTys.push_back(FieldTy); FieldOffset += FieldSize; - FType = CGM.getContext().getFixedWidthIntType(32, true); // Int32Ty; + FType = CGM.getContext().IntTy; FieldTy = CGDebugInfo::getOrCreateType(FType, Unit); FieldSize = CGM.getContext().getTypeSize(FType); FieldAlign = CGM.getContext().getTypeAlign(FType); @@ -1289,7 +1288,7 @@ void CGDebugInfo::EmitDeclare(const BlockDeclRefExpr *BDRE, unsigned Tag, EltTys.push_back(FieldTy); FieldOffset += FieldSize; - FType = CGM.getContext().getFixedWidthIntType(32, true); // Int32Ty; + FType = CGM.getContext().IntTy; FieldTy = CGDebugInfo::getOrCreateType(FType, Unit); FieldSize = CGM.getContext().getTypeSize(FType); FieldAlign = CGM.getContext().getTypeAlign(FType); diff --git a/lib/CodeGen/CodeGenTypes.cpp b/lib/CodeGen/CodeGenTypes.cpp index 6fa0ea9700..cd34e0c064 100644 --- a/lib/CodeGen/CodeGenTypes.cpp +++ b/lib/CodeGen/CodeGenTypes.cpp @@ -254,9 +254,6 @@ const llvm::Type *CodeGenTypes::ConvertNewType(QualType T) { assert(0 && "Unknown builtin type!"); break; } - case Type::FixedWidthInt: - return llvm::IntegerType::get(getLLVMContext(), - cast(T)->getWidth()); case Type::Complex: { const llvm::Type *EltTy = ConvertTypeRecursive(cast(Ty).getElementType()); diff --git a/lib/CodeGen/Mangle.cpp b/lib/CodeGen/Mangle.cpp index f4c6ffeeda..10fd1f57f6 100644 --- a/lib/CodeGen/Mangle.cpp +++ b/lib/CodeGen/Mangle.cpp @@ -994,10 +994,6 @@ void CXXNameMangler::mangleType(const BlockPointerType *T) { mangleType(T->getPointeeType()); } -void CXXNameMangler::mangleType(const FixedWidthIntType *T) { - assert(false && "can't mangle arbitary-precision integer type yet"); -} - void CXXNameMangler::mangleType(const TemplateSpecializationType *T) { TemplateDecl *TD = T->getTemplateName().getAsTemplateDecl(); assert(TD && "FIXME: Support dependent template names!"); diff --git a/lib/Frontend/PCHReader.cpp b/lib/Frontend/PCHReader.cpp index 2eabdc93f4..d8fd791b19 100644 --- a/lib/Frontend/PCHReader.cpp +++ b/lib/Frontend/PCHReader.cpp @@ -1761,11 +1761,6 @@ QualType PCHReader::ReadTypeRecord(uint64_t Offset) { return Context->getQualifiedType(Base, Quals); } - case pch::TYPE_FIXED_WIDTH_INT: { - assert(Record.size() == 2 && "Incorrect encoding of fixed-width int type"); - return Context->getFixedWidthIntType(Record[0], Record[1]); - } - case pch::TYPE_COMPLEX: { assert(Record.size() == 1 && "Incorrect encoding of complex type"); QualType ElemType = GetType(Record[0]); @@ -1987,9 +1982,6 @@ void TypeLocReader::VisitQualifiedTypeLoc(QualifiedTypeLoc TL) { void TypeLocReader::VisitBuiltinTypeLoc(BuiltinTypeLoc TL) { TL.setNameLoc(SourceLocation::getFromRawEncoding(Record[Idx++])); } -void TypeLocReader::VisitFixedWidthIntTypeLoc(FixedWidthIntTypeLoc TL) { - TL.setNameLoc(SourceLocation::getFromRawEncoding(Record[Idx++])); -} void TypeLocReader::VisitComplexTypeLoc(ComplexTypeLoc TL) { TL.setNameLoc(SourceLocation::getFromRawEncoding(Record[Idx++])); } diff --git a/lib/Frontend/PCHWriter.cpp b/lib/Frontend/PCHWriter.cpp index 124df63aad..2875f0930c 100644 --- a/lib/Frontend/PCHWriter.cpp +++ b/lib/Frontend/PCHWriter.cpp @@ -69,12 +69,6 @@ void PCHTypeWriter::VisitBuiltinType(const BuiltinType *T) { assert(false && "Built-in types are never serialized"); } -void PCHTypeWriter::VisitFixedWidthIntType(const FixedWidthIntType *T) { - Record.push_back(T->getWidth()); - Record.push_back(T->isSigned()); - Code = pch::TYPE_FIXED_WIDTH_INT; -} - void PCHTypeWriter::VisitComplexType(const ComplexType *T) { Writer.AddTypeRef(T->getElementType(), Record); Code = pch::TYPE_COMPLEX; @@ -283,9 +277,6 @@ void TypeLocWriter::VisitQualifiedTypeLoc(QualifiedTypeLoc TL) { void TypeLocWriter::VisitBuiltinTypeLoc(BuiltinTypeLoc TL) { Writer.AddSourceLocation(TL.getNameLoc(), Record); } -void TypeLocWriter::VisitFixedWidthIntTypeLoc(FixedWidthIntTypeLoc TL) { - Writer.AddSourceLocation(TL.getNameLoc(), Record); -} void TypeLocWriter::VisitComplexTypeLoc(ComplexTypeLoc TL) { Writer.AddSourceLocation(TL.getNameLoc(), Record); } @@ -559,7 +550,6 @@ void PCHWriter::WriteBlockInfoBlock() { // Decls and Types block. BLOCK(DECLTYPES_BLOCK); RECORD(TYPE_EXT_QUAL); - RECORD(TYPE_FIXED_WIDTH_INT); RECORD(TYPE_COMPLEX); RECORD(TYPE_POINTER); RECORD(TYPE_BLOCK_POINTER); diff --git a/lib/Sema/Sema.cpp b/lib/Sema/Sema.cpp index 6119b13b73..40ad90a129 100644 --- a/lib/Sema/Sema.cpp +++ b/lib/Sema/Sema.cpp @@ -389,12 +389,6 @@ static bool getIntProperties(ASTContext &C, const Type *T, return true; } - if (const FixedWidthIntType *FWIT = dyn_cast(T)) { - BitWidth = FWIT->getWidth(); - Signed = FWIT->isSigned(); - return true; - } - return false; } @@ -655,8 +649,7 @@ static void CheckImplicitConversion(Sema &S, Expr *E, QualType T) { } // If the target is integral, always warn. - if ((TargetBT && TargetBT->isInteger()) || - isa(Target)) + if ((TargetBT && TargetBT->isInteger())) // TODO: don't warn for integer values? return DiagnoseImpCast(S, E, T, diag::warn_impcast_float_integer); diff --git a/lib/Sema/SemaDeclAttr.cpp b/lib/Sema/SemaDeclAttr.cpp index e95f479bd8..094e5b56e5 100644 --- a/lib/Sema/SemaDeclAttr.cpp +++ b/lib/Sema/SemaDeclAttr.cpp @@ -1614,7 +1614,10 @@ static void HandleModeAttr(Decl *D, const AttributeList &Attr, Sema &S) { S.Diag(Attr.getLoc(), diag::err_unsupported_machine_mode) << Name; return; } - NewTy = S.Context.getFixedWidthIntType(128, OldTy->isSignedIntegerType()); + if (OldTy->isSignedIntegerType()) + NewTy = S.Context.Int128Ty; + else + NewTy = S.Context.UnsignedInt128Ty; break; } diff --git a/lib/Sema/SemaTemplateDeduction.cpp b/lib/Sema/SemaTemplateDeduction.cpp index 11798c468a..590a75174b 100644 --- a/lib/Sema/SemaTemplateDeduction.cpp +++ b/lib/Sema/SemaTemplateDeduction.cpp @@ -2401,7 +2401,6 @@ MarkUsedTemplateParameters(Sema &SemaRef, QualType T, // None of these types have any template parameters in them. case Type::Builtin: - case Type::FixedWidthInt: case Type::VariableArray: case Type::FunctionNoProto: case Type::Record: diff --git a/lib/Sema/TreeTransform.h b/lib/Sema/TreeTransform.h index 7db723bdb9..208c8851e5 100644 --- a/lib/Sema/TreeTransform.h +++ b/lib/Sema/TreeTransform.h @@ -2133,13 +2133,6 @@ QualType TreeTransform::TransformBuiltinType(TypeLocBuilder &TLB, return TransformTypeSpecType(TLB, T); } -template -QualType -TreeTransform::TransformFixedWidthIntType(TypeLocBuilder &TLB, - FixedWidthIntTypeLoc T) { - return TransformTypeSpecType(TLB, T); -} - template QualType TreeTransform::TransformComplexType(TypeLocBuilder &TLB, ComplexTypeLoc T) { @@ -5255,9 +5248,6 @@ TreeTransform::RebuildArrayType(QualType ElementType, break; } - if (SizeType.isNull()) - SizeType = SemaRef.Context.getFixedWidthIntType(Size->getBitWidth(), false); - IntegerLiteral ArraySize(*Size, SizeType, /*FIXME*/BracketsRange.getBegin()); return SemaRef.BuildArrayType(ElementType, SizeMod, &ArraySize, IndexTypeQuals, BracketsRange, -- 2.40.0