forked from OSchip/llvm-project
Store the builtin types as CanQualTypes. Expand a bit on the CanQual API,
but also remove some methods that cause ambiguities, and generally make CanQual<blah> more analogous to QualType. llvm-svn: 84976
This commit is contained in:
parent
d0fc8f809a
commit
48f2d5860d
|
@ -301,22 +301,22 @@ public:
|
|||
const char *getCommentForDecl(const Decl *D);
|
||||
|
||||
// Builtin Types.
|
||||
QualType VoidTy;
|
||||
QualType BoolTy;
|
||||
QualType CharTy;
|
||||
QualType WCharTy; // [C++ 3.9.1p5], integer type in C99.
|
||||
QualType Char16Ty; // [C++0x 3.9.1p5], integer type in C99.
|
||||
QualType Char32Ty; // [C++0x 3.9.1p5], integer type in C99.
|
||||
QualType SignedCharTy, ShortTy, IntTy, LongTy, LongLongTy, Int128Ty;
|
||||
QualType UnsignedCharTy, UnsignedShortTy, UnsignedIntTy, UnsignedLongTy;
|
||||
QualType UnsignedLongLongTy, UnsignedInt128Ty;
|
||||
QualType FloatTy, DoubleTy, LongDoubleTy;
|
||||
QualType FloatComplexTy, DoubleComplexTy, LongDoubleComplexTy;
|
||||
QualType VoidPtrTy, NullPtrTy;
|
||||
QualType OverloadTy;
|
||||
QualType DependentTy;
|
||||
QualType UndeducedAutoTy;
|
||||
QualType ObjCBuiltinIdTy, ObjCBuiltinClassTy;
|
||||
CanQualType VoidTy;
|
||||
CanQualType BoolTy;
|
||||
CanQualType CharTy;
|
||||
CanQualType WCharTy; // [C++ 3.9.1p5], integer type in C99.
|
||||
CanQualType Char16Ty; // [C++0x 3.9.1p5], integer type in C99.
|
||||
CanQualType Char32Ty; // [C++0x 3.9.1p5], integer type in C99.
|
||||
CanQualType SignedCharTy, ShortTy, IntTy, LongTy, LongLongTy, Int128Ty;
|
||||
CanQualType UnsignedCharTy, UnsignedShortTy, UnsignedIntTy, UnsignedLongTy;
|
||||
CanQualType UnsignedLongLongTy, UnsignedInt128Ty;
|
||||
CanQualType FloatTy, DoubleTy, LongDoubleTy;
|
||||
CanQualType FloatComplexTy, DoubleComplexTy, LongDoubleComplexTy;
|
||||
CanQualType VoidPtrTy, NullPtrTy;
|
||||
CanQualType OverloadTy;
|
||||
CanQualType DependentTy;
|
||||
CanQualType UndeducedAutoTy;
|
||||
CanQualType ObjCBuiltinIdTy, ObjCBuiltinClassTy;
|
||||
|
||||
ASTContext(const LangOptions& LOpts, SourceManager &SM, TargetInfo &t,
|
||||
IdentifierTable &idents, SelectorTable &sels,
|
||||
|
@ -387,10 +387,16 @@ public:
|
|||
/// getComplexType - Return the uniqued reference to the type for a complex
|
||||
/// number with the specified element type.
|
||||
QualType getComplexType(QualType T);
|
||||
CanQualType getComplexType(CanQualType T) {
|
||||
return CanQualType::CreateUnsafe(getComplexType((QualType) T));
|
||||
}
|
||||
|
||||
/// getPointerType - Return the uniqued reference to the type for a pointer to
|
||||
/// the specified type.
|
||||
QualType getPointerType(QualType T);
|
||||
CanQualType getPointerType(CanQualType T) {
|
||||
return CanQualType::CreateUnsafe(getPointerType((QualType) T));
|
||||
}
|
||||
|
||||
/// getBlockPointerType - Return the uniqued reference to the type for a block
|
||||
/// of the specified type.
|
||||
|
@ -739,7 +745,7 @@ public:
|
|||
QualType GetBuiltinType(unsigned ID, GetBuiltinTypeError &Error);
|
||||
|
||||
private:
|
||||
QualType getFromTargetType(unsigned Type) const;
|
||||
CanQualType getFromTargetType(unsigned Type) const;
|
||||
|
||||
//===--------------------------------------------------------------------===//
|
||||
// Type Predicates.
|
||||
|
@ -1096,7 +1102,7 @@ private:
|
|||
void operator=(const ASTContext&); // DO NOT IMPLEMENT
|
||||
|
||||
void InitBuiltinTypes();
|
||||
void InitBuiltinType(QualType &R, BuiltinType::Kind K);
|
||||
void InitBuiltinType(CanQualType &R, BuiltinType::Kind K);
|
||||
|
||||
// Return the ObjC type encoding for a given type.
|
||||
void getObjCEncodingForTypeImpl(QualType t, std::string &S,
|
||||
|
|
|
@ -64,15 +64,6 @@ public:
|
|||
CanQual(const CanQual<U>& Other,
|
||||
typename llvm::enable_if<llvm::is_base_of<T, U>, int>::type = 0);
|
||||
|
||||
/// \brief Implicit conversion to the underlying pointer.
|
||||
///
|
||||
/// Also provides the ability to use canonical types in a boolean context,
|
||||
/// e.g.,
|
||||
/// @code
|
||||
/// if (CanQual<PointerType> Ptr = T->getAs<PointerType>()) { ... }
|
||||
/// @endcode
|
||||
operator const T*() const { return getTypePtr(); }
|
||||
|
||||
/// \brief Retrieve the underlying type pointer, which refers to a
|
||||
/// canonical type.
|
||||
T *getTypePtr() const { return cast_or_null<T>(Stored.getTypePtr()); }
|
||||
|
@ -80,6 +71,10 @@ public:
|
|||
/// \brief Implicit conversion to a qualified type.
|
||||
operator QualType() const { return Stored; }
|
||||
|
||||
bool isNull() const {
|
||||
return Stored.isNull();
|
||||
}
|
||||
|
||||
/// \brief Retrieve a canonical type pointer with a different static type,
|
||||
/// upcasting or downcasting as needed.
|
||||
///
|
||||
|
@ -125,8 +120,10 @@ public:
|
|||
/// \brief Retrieve the unqualified form of this type.
|
||||
CanQual<T> getUnqualifiedType() const;
|
||||
|
||||
CanQual<T> getQualifiedType(unsigned TQs) const {
|
||||
return CanQual<T>::CreateUnsafe(QualType(getTypePtr(), TQs));
|
||||
/// \brief Retrieves a version of this type with const applied.
|
||||
/// Note that this does not always yield a canonical type.
|
||||
QualType withConst() const {
|
||||
return Stored.withConst();
|
||||
}
|
||||
|
||||
/// \brief Determines whether this canonical type is more qualified than
|
||||
|
|
|
@ -138,9 +138,9 @@ void ASTContext::PrintStats() const {
|
|||
}
|
||||
|
||||
|
||||
void ASTContext::InitBuiltinType(QualType &R, BuiltinType::Kind K) {
|
||||
void ASTContext::InitBuiltinType(CanQualType &R, BuiltinType::Kind K) {
|
||||
BuiltinType *Ty = new (*this, TypeAlignment) BuiltinType(K);
|
||||
R = QualType(Ty, 0);
|
||||
R = CanQualType::CreateUnsafe(QualType(Ty, 0));
|
||||
Types.push_back(Ty);
|
||||
}
|
||||
|
||||
|
@ -3600,9 +3600,9 @@ TemplateName ASTContext::getDependentTemplateName(NestedNameSpecifier *NNS,
|
|||
/// getFromTargetType - Given one of the integer types provided by
|
||||
/// TargetInfo, produce the corresponding type. The unsigned @p Type
|
||||
/// is actually a value of type @c TargetInfo::IntType.
|
||||
QualType ASTContext::getFromTargetType(unsigned Type) const {
|
||||
CanQualType ASTContext::getFromTargetType(unsigned Type) const {
|
||||
switch (Type) {
|
||||
case TargetInfo::NoInt: return QualType();
|
||||
case TargetInfo::NoInt: return CanQualType();
|
||||
case TargetInfo::SignedShort: return ShortTy;
|
||||
case TargetInfo::UnsignedShort: return UnsignedShortTy;
|
||||
case TargetInfo::SignedInt: return IntTy;
|
||||
|
@ -3614,7 +3614,7 @@ QualType ASTContext::getFromTargetType(unsigned Type) const {
|
|||
}
|
||||
|
||||
assert(false && "Unhandled TargetInfo::IntType value");
|
||||
return QualType();
|
||||
return CanQualType();
|
||||
}
|
||||
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
|
|
@ -180,7 +180,7 @@ static const llvm::Type* getTypeForFormat(llvm::LLVMContext &VMContext,
|
|||
}
|
||||
|
||||
const llvm::Type *CodeGenTypes::ConvertNewType(QualType T) {
|
||||
const clang::Type &Ty = *Context.getCanonicalType(T);
|
||||
const clang::Type &Ty = *Context.getCanonicalType(T).getTypePtr();
|
||||
|
||||
switch (Ty.getTypeClass()) {
|
||||
#define TYPE(Class, Base)
|
||||
|
|
|
@ -1643,15 +1643,15 @@ DeduceTemplateArgumentsDuringPartialOrdering(ASTContext &Context,
|
|||
// performed on the types used for partial ordering:
|
||||
// - If P is a reference type, P is replaced by the type referred to.
|
||||
CanQual<ReferenceType> ParamRef = Param->getAs<ReferenceType>();
|
||||
if (ParamRef)
|
||||
if (!ParamRef.isNull())
|
||||
Param = ParamRef->getPointeeType();
|
||||
|
||||
// - If A is a reference type, A is replaced by the type referred to.
|
||||
CanQual<ReferenceType> ArgRef = Arg->getAs<ReferenceType>();
|
||||
if (ArgRef)
|
||||
if (!ArgRef.isNull())
|
||||
Arg = ArgRef->getPointeeType();
|
||||
|
||||
if (QualifierComparisons && ParamRef && ArgRef) {
|
||||
if (QualifierComparisons && !ParamRef.isNull() && !ArgRef.isNull()) {
|
||||
// C++0x [temp.deduct.partial]p6:
|
||||
// If both P and A were reference types (before being replaced with the
|
||||
// type referred to above), determine which of the two types (if any) is
|
||||
|
|
Loading…
Reference in New Issue