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,
/// 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.
QualType GetBuiltinType(unsigned ID, GetBuiltinTypeError &Error);
private:
- QualType getFromTargetType(unsigned Type) const;
+ CanQualType getFromTargetType(unsigned Type) const;
//===--------------------------------------------------------------------===//
// Type Predicates.
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,
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()); }
/// \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.
///
/// \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
}
-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);
}
/// 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;
}
assert(false && "Unhandled TargetInfo::IntType value");
- return QualType();
+ return CanQualType();
}
//===----------------------------------------------------------------------===//
// 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