Change QualType::getTypePtr() to return a const pointer, then change a

thousand other things which were (generally inadvertantly) relying on that.

llvm-svn: 123814
This commit is contained in:
John McCall 2011-01-19 06:33:43 +00:00
parent 0c49533039
commit 424cec97bd
53 changed files with 243 additions and 236 deletions

View File

@ -1092,6 +1092,7 @@ public:
/// to be free of any of these, allowing two canonical types to be compared
/// for exact equality with a simple pointer comparison.
CanQualType getCanonicalType(QualType T) const;
const Type *getCanonicalType(const Type *T) const {
return T->getCanonicalTypeInternal().getTypePtr();
}
@ -1281,7 +1282,7 @@ public:
private:
// Helper for integer ordering
unsigned getIntegerRank(Type* T) const;
unsigned getIntegerRank(const Type *T) const;
public:

View File

@ -51,7 +51,7 @@ namespace clang {
/// \brief Mapping from the already-imported types in the "from" context
/// to the corresponding types in the "to" context.
llvm::DenseMap<Type *, Type *> ImportedTypes;
llvm::DenseMap<const Type *, const Type *> ImportedTypes;
/// \brief Mapping from the already-imported declarations in the "from"
/// context to the corresponding declarations in the "to" context.

View File

@ -68,12 +68,12 @@ public:
/// canonical type.
///
/// The underlying pointer must not be NULL.
T *getTypePtr() const { return cast<T>(Stored.getTypePtr()); }
const T *getTypePtr() const { return cast<T>(Stored.getTypePtr()); }
/// \brief Retrieve the underlying type pointer, which refers to a
/// canonical type, or NULL.
///
T *getTypePtrOrNull() const {
const T *getTypePtrOrNull() const {
return cast_or_null<T>(Stored.getTypePtrOrNull());
}
@ -87,6 +87,8 @@ public:
return Stored.isNull();
}
SplitQualType split() const { return Stored.split(); }
/// \brief Retrieve a canonical type pointer with a different static type,
/// upcasting or downcasting as needed.
///
@ -225,7 +227,7 @@ protected:
public:
/// \brief Retrieve the pointer to the underlying Type
T* getTypePtr() const { return Stored.getTypePtr(); }
const T *getTypePtr() const { return Stored.getTypePtr(); }
/// \brief Implicit conversion to the underlying pointer.
///
@ -345,7 +347,7 @@ namespace llvm {
/// to return smart pointer (proxies?).
template<typename T>
struct simplify_type<const ::clang::CanQual<T> > {
typedef T* SimpleType;
typedef const T *SimpleType;
static SimpleType getSimplifiedValue(const ::clang::CanQual<T> &Val) {
return Val.getTypePtr();
}

View File

@ -1850,7 +1850,7 @@ class TypeDecl : public NamedDecl {
/// this TypeDecl. It is a cache maintained by
/// ASTContext::getTypedefType, ASTContext::getTagDeclType, and
/// ASTContext::getTemplateTypeParmType, and TemplateTypeParmDecl.
mutable Type *TypeForDecl;
mutable const Type *TypeForDecl;
friend class ASTContext;
friend class DeclContext;
friend class TagDecl;
@ -1864,8 +1864,8 @@ protected:
public:
// Low-level accessor
Type *getTypeForDecl() const { return TypeForDecl; }
void setTypeForDecl(Type *TD) { TypeForDecl = TD; }
const Type *getTypeForDecl() const { return TypeForDecl; }
void setTypeForDecl(const Type *TD) { TypeForDecl = TD; }
// Implement isa/cast/dyncast/etc.
static bool classof(const Decl *D) { return classofKind(D->getKind()); }

View File

@ -1220,7 +1220,6 @@ public:
/// If this is a base class initializer, returns the type of the base class.
/// Otherwise, returns NULL.
const Type *getBaseClass() const;
Type *getBaseClass();
/// Returns whether the base is virtual or not.
bool isBaseVirtual() const {

View File

@ -437,7 +437,7 @@ public:
class ObjCInterfaceDecl : public ObjCContainerDecl {
/// TypeForDecl - This indicates the Type object that represents this
/// TypeDecl. It is a cache maintained by ASTContext::getObjCInterfaceType
mutable Type *TypeForDecl;
mutable const Type *TypeForDecl;
friend class ASTContext;
/// Class's super class.
@ -665,8 +665,8 @@ public:
bool RHSIsQualifiedID = false);
// Low-level accessor
Type *getTypeForDecl() const { return TypeForDecl; }
void setTypeForDecl(Type *TD) const { TypeForDecl = TD; }
const Type *getTypeForDecl() const { return TypeForDecl; }
void setTypeForDecl(const Type *TD) const { TypeForDecl = TD; }
static bool classof(const Decl *D) { return classofKind(D->getKind()); }
static bool classof(const ObjCInterfaceDecl *D) { return true; }

View File

@ -245,7 +245,7 @@ private:
/// the location of the 'super' keyword. When it's an interface,
/// this is that interface.
SourceLocation ReceiverLoc;
llvm::PointerUnion3<Stmt*, Type*, ObjCInterfaceDecl*> Receiver;
llvm::PointerUnion3<Stmt*, const Type*, ObjCInterfaceDecl*> Receiver;
public:
ObjCPropertyRefExpr(ObjCPropertyDecl *PD, QualType t,
@ -340,13 +340,13 @@ public:
SourceLocation getReceiverLocation() const { return ReceiverLoc; }
QualType getSuperReceiverType() const {
return QualType(Receiver.get<Type*>(), 0);
return QualType(Receiver.get<const Type*>(), 0);
}
ObjCInterfaceDecl *getClassReceiver() const {
return Receiver.get<ObjCInterfaceDecl*>();
}
bool isObjectReceiver() const { return Receiver.is<Stmt*>(); }
bool isSuperReceiver() const { return Receiver.is<Type*>(); }
bool isSuperReceiver() const { return Receiver.is<const Type*>(); }
bool isClassReceiver() const { return Receiver.is<ObjCInterfaceDecl*>(); }
virtual SourceRange getSourceRange() const {

View File

@ -111,7 +111,7 @@ public:
/// \brief Builds a nested name specifier that names a type.
static NestedNameSpecifier *Create(const ASTContext &Context,
NestedNameSpecifier *Prefix,
bool Template, Type *T);
bool Template, const Type *T);
/// \brief Builds a specifier that consists of just an identifier.
///
@ -161,10 +161,10 @@ public:
}
/// \brief Retrieve the type stored in this nested name specifier.
Type *getAsType() const {
const Type *getAsType() const {
if (Prefix.getInt() == TypeSpec ||
Prefix.getInt() == TypeSpecWithTemplate)
return (Type *)Specifier;
return (const Type *)Specifier;
return 0;
}

View File

@ -442,7 +442,8 @@ bool RecursiveASTVisitor<Derived>::TraverseType(QualType T) {
switch (T->getTypeClass()) {
#define ABSTRACT_TYPE(CLASS, BASE)
#define TYPE(CLASS, BASE) \
case Type::CLASS: DISPATCH(CLASS##Type, CLASS##Type, T.getTypePtr());
case Type::CLASS: DISPATCH(CLASS##Type, CLASS##Type, \
const_cast<Type*>(T.getTypePtr()));
#include "clang/AST/TypeNodes.def"
}
@ -781,7 +782,7 @@ DEF_TRAVERSE_TYPE(ObjCObjectPointerType, {
template<typename Derived> \
bool RecursiveASTVisitor<Derived>::Traverse##TYPE##Loc(TYPE##Loc TL) { \
if (getDerived().shouldWalkTypesOfTypeLocs()) \
TRY_TO(WalkUpFrom##TYPE(TL.getTypePtr())); \
TRY_TO(WalkUpFrom##TYPE(const_cast<TYPE*>(TL.getTypePtr()))); \
TRY_TO(WalkUpFrom##TYPE##Loc(TL)); \
{ CODE; } \
return true; \
@ -893,7 +894,7 @@ DEF_TRAVERSE_TYPELOC(FunctionNoProtoType, {
DEF_TRAVERSE_TYPELOC(FunctionProtoType, {
TRY_TO(TraverseTypeLoc(TL.getResultLoc()));
FunctionProtoType *T = TL.getTypePtr();
const FunctionProtoType *T = TL.getTypePtr();
for (unsigned I = 0, E = TL.getNumArgs(); I != E; ++I) {
TRY_TO(TraverseDecl(TL.getArg(I)));

View File

@ -51,11 +51,11 @@ protected:
return (RawVAPtr & Flags) == 0;
}
VariableArrayType* getVAPtr() const {
return reinterpret_cast<VariableArrayType*>(RawVAPtr & ~Flags);
const VariableArrayType *getVAPtr() const {
return reinterpret_cast<const VariableArrayType*>(RawVAPtr & ~Flags);
}
void setVAPtr(VariableArrayType* P) {
void setVAPtr(const VariableArrayType *P) {
assert (inDecl() || inDeclGroup() || inSizeOfTypeVA());
RawVAPtr = reinterpret_cast<uintptr_t>(P) | (RawVAPtr & Flags);
}
@ -68,7 +68,7 @@ protected:
StmtIteratorBase(Stmt **s) : stmt(s), decl(0), RawVAPtr(0) {}
StmtIteratorBase(Decl *d, Stmt **s);
StmtIteratorBase(VariableArrayType *t);
StmtIteratorBase(const VariableArrayType *t);
StmtIteratorBase(Decl **dgi, Decl **dge);
StmtIteratorBase() : stmt(0), decl(0), RawVAPtr(0) {}
};
@ -86,7 +86,7 @@ public:
StmtIteratorImpl(Stmt **s) : StmtIteratorBase(s) {}
StmtIteratorImpl(Decl **dgi, Decl **dge) : StmtIteratorBase(dgi, dge) {}
StmtIteratorImpl(Decl *d, Stmt **s) : StmtIteratorBase(d, s) {}
StmtIteratorImpl(VariableArrayType* t) : StmtIteratorBase(t) {}
StmtIteratorImpl(const VariableArrayType *t) : StmtIteratorBase(t) {}
DERIVED& operator++() {
if (inDecl() || inDeclGroup()) {
@ -130,7 +130,7 @@ struct StmtIterator : public StmtIteratorImpl<StmtIterator,Stmt*&> {
StmtIterator(Decl** dgi, Decl** dge)
: StmtIteratorImpl<StmtIterator,Stmt*&>(dgi, dge) {}
StmtIterator(VariableArrayType* t)
StmtIterator(const VariableArrayType *t)
: StmtIteratorImpl<StmtIterator,Stmt*&>(t) {}
StmtIterator(Decl* D, Stmt **s = 0)

View File

@ -479,7 +479,7 @@ public:
///
/// This function requires that the type not be NULL. If the type might be
/// NULL, use the (slightly less efficient) \c getTypePtrOrNull().
Type *getTypePtr() const {
const Type *getTypePtr() const {
assert(!isNull() && "Cannot retrieve a NULL type pointer");
uintptr_t CommonPtrVal
= reinterpret_cast<uintptr_t>(Value.getOpaqueValue());
@ -489,12 +489,12 @@ public:
return const_cast<Type *>(CommonPtr->BaseType);
}
Type *getTypePtrOrNull() const {
const Type *getTypePtrOrNull() const {
uintptr_t TypePtrPtrVal
= reinterpret_cast<uintptr_t>(Value.getOpaqueValue());
TypePtrPtrVal &= ~(uintptr_t)((1 << TypeAlignmentInBits) - 1);
Type **TypePtrPtr = reinterpret_cast<Type**>(TypePtrPtrVal);
return TypePtrPtr? *TypePtrPtr : 0;
return TypePtrPtr ? *TypePtrPtr : 0;
}
/// Divides a QualType into its unqualified type and a set of local
@ -511,17 +511,17 @@ public:
}
void *getAsOpaquePtr() const { return Value.getOpaqueValue(); }
static QualType getFromOpaquePtr(void *Ptr) {
static QualType getFromOpaquePtr(const void *Ptr) {
QualType T;
T.Value.setFromOpaqueValue(Ptr);
T.Value.setFromOpaqueValue(const_cast<void*>(Ptr));
return T;
}
Type &operator*() const {
const Type &operator*() const {
return *getTypePtr();
}
Type *operator->() const {
const Type *operator->() const {
return getTypePtr();
}
@ -805,7 +805,7 @@ namespace llvm {
/// Implement simplify_type for QualType, so that we can dyn_cast from QualType
/// to a specific Type class.
template<> struct simplify_type<const ::clang::QualType> {
typedef ::clang::Type* SimpleType;
typedef const ::clang::Type *SimpleType;
static SimpleType getSimplifiedValue(const ::clang::QualType &Val) {
return Val.getTypePtr();
}
@ -3830,8 +3830,8 @@ inline bool QualType::isCanonicalAsParam() const {
if ((*this)->isPointerType()) {
QualType BaseType = (*this)->getAs<PointerType>()->getPointeeType();
if (isa<VariableArrayType>(BaseType)) {
ArrayType *AT = dyn_cast<ArrayType>(BaseType);
VariableArrayType *VAT = cast<VariableArrayType>(AT);
const ArrayType *AT = dyn_cast<ArrayType>(BaseType);
const VariableArrayType *VAT = cast<VariableArrayType>(AT);
if (VAT->getSizeExpr())
T = BaseType.getTypePtr();
}

View File

@ -38,7 +38,7 @@ class TypeLoc {
protected:
// The correctness of this relies on the property that, for Type *Ty,
// QualType(Ty, 0).getAsOpaquePtr() == (void*) Ty
void *Ty;
const void *Ty;
void *Data;
public:
@ -56,7 +56,7 @@ public:
TypeLoc() : Ty(0), Data(0) { }
TypeLoc(QualType ty, void *opaqueData)
: Ty(ty.getAsOpaquePtr()), Data(opaqueData) { }
TypeLoc(Type *ty, void *opaqueData)
TypeLoc(const Type *ty, void *opaqueData)
: Ty(ty), Data(opaqueData) { }
TypeLocClass getTypeLocClass() const {
@ -76,7 +76,7 @@ public:
return QualType::getFromOpaquePtr(Ty);
}
Type *getTypePtr() const {
const Type *getTypePtr() const {
return QualType::getFromOpaquePtr(Ty).getTypePtr();
}
@ -174,10 +174,10 @@ inline TypeLoc TypeSourceInfo::getTypeLoc() const {
class UnqualTypeLoc : public TypeLoc {
public:
UnqualTypeLoc() {}
UnqualTypeLoc(Type *Ty, void *Data) : TypeLoc(Ty, Data) {}
UnqualTypeLoc(const Type *Ty, void *Data) : TypeLoc(Ty, Data) {}
Type *getTypePtr() const {
return reinterpret_cast<Type*>(Ty);
const Type *getTypePtr() const {
return reinterpret_cast<const Type*>(Ty);
}
TypeLocClass getTypeLocClass() const {
@ -306,7 +306,7 @@ public:
return getNextTypeLoc(asDerived()->getInnerType());
}
TypeClass *getTypePtr() const {
const TypeClass *getTypePtr() const {
return cast<TypeClass>(Base::getTypePtr());
}
@ -379,7 +379,7 @@ public:
return true;
}
TypeClass *getTypePtr() const {
const TypeClass *getTypePtr() const {
return cast<TypeClass>(Base::getTypePtr());
}
};

View File

@ -19,12 +19,13 @@
namespace clang {
#define DISPATCH(CLASS) \
return static_cast<ImplClass*>(this)->Visit ## CLASS(static_cast<CLASS*>(T))
return static_cast<ImplClass*>(this)-> \
Visit##CLASS(static_cast<const CLASS*>(T))
template<typename ImplClass, typename RetTy=void>
class TypeVisitor {
public:
RetTy Visit(Type *T) {
RetTy Visit(const Type *T) {
// Top switch stmt: dispatch to VisitFooType for each FooType.
switch (T->getTypeClass()) {
default: assert(0 && "Unknown type class!");
@ -36,13 +37,13 @@ public:
// If the implementation chooses not to implement a certain visit method, fall
// back on superclass.
#define TYPE(CLASS, PARENT) RetTy Visit##CLASS##Type(CLASS##Type *T) { \
#define TYPE(CLASS, PARENT) RetTy Visit##CLASS##Type(const CLASS##Type *T) { \
DISPATCH(PARENT); \
}
#include "clang/AST/TypeNodes.def"
// Base case, ignore it. :)
RetTy VisitType(Type*) { return RetTy(); }
RetTy VisitType(const Type*) { return RetTy(); }
};
#undef DISPATCH

View File

@ -1007,8 +1007,8 @@ public:
QualType& ConvertedType, bool &IncompatibleObjC);
bool isObjCPointerConversion(QualType FromType, QualType ToType,
QualType& ConvertedType, bool &IncompatibleObjC);
bool FunctionArgTypesAreEqual (FunctionProtoType* OldType,
FunctionProtoType* NewType);
bool FunctionArgTypesAreEqual(const FunctionProtoType *OldType,
const FunctionProtoType *NewType);
bool CheckPointerConversion(Expr *From, QualType ToType,
CastKind &Kind,

View File

@ -573,7 +573,7 @@ CharUnits ASTContext::getDeclAlign(const Decl *D, bool RefAsPointee) const {
unsigned ArrayAlign = Target.getLargeArrayAlign();
if (isa<VariableArrayType>(T) && MinWidth != 0)
Align = std::max(Align, ArrayAlign);
if (ConstantArrayType *CT = dyn_cast<ConstantArrayType>(T)) {
if (const ConstantArrayType *CT = dyn_cast<ConstantArrayType>(T)) {
unsigned Size = getTypeSize(CT);
if (MinWidth != 0 && MinWidth <= Size)
Align = std::max(Align, ArrayAlign);
@ -1661,7 +1661,7 @@ QualType ASTContext::getIncompleteArrayType(QualType EltTy,
/// the specified element type and size. VectorType must be a built-in type.
QualType ASTContext::getVectorType(QualType vecType, unsigned NumElts,
VectorType::VectorKind VecKind) const {
BuiltinType *BaseType;
const BuiltinType *BaseType;
BaseType = dyn_cast<BuiltinType>(getCanonicalType(vecType).getTypePtr());
assert(BaseType != 0 && "getVectorType(): Expecting a built-in type");
@ -1695,7 +1695,7 @@ QualType ASTContext::getVectorType(QualType vecType, unsigned NumElts,
/// the specified element type and size. VectorType must be a built-in type.
QualType
ASTContext::getExtVectorType(QualType vecType, unsigned NumElts) const {
BuiltinType *baseType;
const BuiltinType *baseType;
baseType = dyn_cast<BuiltinType>(getCanonicalType(vecType).getTypePtr());
assert(baseType != 0 && "getExtVectorType(): Expecting a built-in type");
@ -1893,9 +1893,10 @@ QualType ASTContext::getInjectedClassNameType(CXXRecordDecl *Decl,
Decl->TypeForDecl = PrevDecl->TypeForDecl;
assert(isa<InjectedClassNameType>(Decl->TypeForDecl));
} else {
Decl->TypeForDecl =
Type *newType =
new (*this, TypeAlignment) InjectedClassNameType(Decl, TST);
Types.push_back(Decl->TypeForDecl);
Decl->TypeForDecl = newType;
Types.push_back(newType);
}
return QualType(Decl->TypeForDecl, 0);
}
@ -1923,11 +1924,12 @@ QualType ASTContext::getTypeDeclTypeSlow(const TypeDecl *Decl) const {
return getEnumType(Enum);
} else if (const UnresolvedUsingTypenameDecl *Using =
dyn_cast<UnresolvedUsingTypenameDecl>(Decl)) {
Decl->TypeForDecl = new (*this, TypeAlignment) UnresolvedUsingType(Using);
Type *newType = new (*this, TypeAlignment) UnresolvedUsingType(Using);
Decl->TypeForDecl = newType;
Types.push_back(newType);
} else
llvm_unreachable("TypeDecl without a type?");
Types.push_back(Decl->TypeForDecl);
return QualType(Decl->TypeForDecl, 0);
}
@ -1939,10 +1941,11 @@ ASTContext::getTypedefType(const TypedefDecl *Decl, QualType Canonical) const {
if (Canonical.isNull())
Canonical = getCanonicalType(Decl->getUnderlyingType());
Decl->TypeForDecl = new(*this, TypeAlignment)
TypedefType *newType = new(*this, TypeAlignment)
TypedefType(Type::Typedef, Decl, Canonical);
Types.push_back(Decl->TypeForDecl);
return QualType(Decl->TypeForDecl, 0);
Decl->TypeForDecl = newType;
Types.push_back(newType);
return QualType(newType, 0);
}
QualType ASTContext::getRecordType(const RecordDecl *Decl) const {
@ -1952,9 +1955,10 @@ QualType ASTContext::getRecordType(const RecordDecl *Decl) const {
if (PrevDecl->TypeForDecl)
return QualType(Decl->TypeForDecl = PrevDecl->TypeForDecl, 0);
Decl->TypeForDecl = new (*this, TypeAlignment) RecordType(Decl);
Types.push_back(Decl->TypeForDecl);
return QualType(Decl->TypeForDecl, 0);
RecordType *newType = new (*this, TypeAlignment) RecordType(Decl);
Decl->TypeForDecl = newType;
Types.push_back(newType);
return QualType(newType, 0);
}
QualType ASTContext::getEnumType(const EnumDecl *Decl) const {
@ -1964,9 +1968,10 @@ QualType ASTContext::getEnumType(const EnumDecl *Decl) const {
if (PrevDecl->TypeForDecl)
return QualType(Decl->TypeForDecl = PrevDecl->TypeForDecl, 0);
Decl->TypeForDecl = new (*this, TypeAlignment) EnumType(Decl);
Types.push_back(Decl->TypeForDecl);
return QualType(Decl->TypeForDecl, 0);
EnumType *newType = new (*this, TypeAlignment) EnumType(Decl);
Decl->TypeForDecl = newType;
Types.push_back(newType);
return QualType(newType, 0);
}
QualType ASTContext::getAttributedType(AttributedType::Kind attrKind,
@ -2667,7 +2672,7 @@ CanQualType ASTContext::getCanonicalType(QualType T) const {
// If the type qualifiers are on an array type, get the canonical
// type of the array with the qualifiers applied to the element
// type.
ArrayType *AT = dyn_cast<ArrayType>(CanType);
const ArrayType *AT = dyn_cast<ArrayType>(CanType);
if (!AT)
return CanQualType::CreateUnsafe(getQualifiedType(CanType, Quals));
@ -2676,17 +2681,17 @@ CanQualType ASTContext::getCanonicalType(QualType T) const {
QualType NewEltTy = getQualifiedType(AT->getElementType(), Quals);
NewEltTy = getCanonicalType(NewEltTy);
if (ConstantArrayType *CAT = dyn_cast<ConstantArrayType>(AT))
if (const ConstantArrayType *CAT = dyn_cast<ConstantArrayType>(AT))
return CanQualType::CreateUnsafe(
getConstantArrayType(NewEltTy, CAT->getSize(),
CAT->getSizeModifier(),
CAT->getIndexTypeCVRQualifiers()));
if (IncompleteArrayType *IAT = dyn_cast<IncompleteArrayType>(AT))
if (const IncompleteArrayType *IAT = dyn_cast<IncompleteArrayType>(AT))
return CanQualType::CreateUnsafe(
getIncompleteArrayType(NewEltTy, IAT->getSizeModifier(),
IAT->getIndexTypeCVRQualifiers()));
if (DependentSizedArrayType *DSAT = dyn_cast<DependentSizedArrayType>(AT))
if (const DependentSizedArrayType *DSAT = dyn_cast<DependentSizedArrayType>(AT))
return CanQualType::CreateUnsafe(
getDependentSizedArrayType(NewEltTy,
DSAT->getSizeExpr(),
@ -2694,7 +2699,7 @@ CanQualType ASTContext::getCanonicalType(QualType T) const {
DSAT->getIndexTypeCVRQualifiers(),
DSAT->getBracketsRange())->getCanonicalTypeInternal());
VariableArrayType *VAT = cast<VariableArrayType>(AT);
const VariableArrayType *VAT = cast<VariableArrayType>(AT);
return CanQualType::CreateUnsafe(getVariableArrayType(NewEltTy,
VAT->getSizeExpr(),
VAT->getSizeModifier(),
@ -3134,9 +3139,9 @@ int ASTContext::getFloatingTypeOrder(QualType LHS, QualType RHS) const {
/// getIntegerRank - Return an integer conversion rank (C99 6.3.1.1p1). This
/// routine will assert if passed a built-in type that isn't an integer or enum,
/// or if it is not canonicalized.
unsigned ASTContext::getIntegerRank(Type *T) const {
unsigned ASTContext::getIntegerRank(const Type *T) const {
assert(T->isCanonicalUnqualified() && "T should be canonicalized");
if (EnumType* ET = dyn_cast<EnumType>(T))
if (const EnumType* ET = dyn_cast<EnumType>(T))
T = ET->getDecl()->getPromotionType().getTypePtr();
if (T->isSpecificBuiltinType(BuiltinType::WChar_S) ||
@ -3230,8 +3235,8 @@ QualType ASTContext::getPromotedIntegerType(QualType Promotable) const {
/// C99 6.3.1.8p1. If LHS > RHS, return 1. If LHS == RHS, return 0. If
/// LHS < RHS, return -1.
int ASTContext::getIntegerTypeOrder(QualType LHS, QualType RHS) const {
Type *LHSC = getCanonicalType(LHS).getTypePtr();
Type *RHSC = getCanonicalType(RHS).getTypePtr();
const Type *LHSC = getCanonicalType(LHS).getTypePtr();
const Type *RHSC = getCanonicalType(RHS).getTypePtr();
if (LHSC == RHSC) return 0;
bool LHSUnsigned = LHSC->isUnsignedIntegerType();
@ -4505,7 +4510,7 @@ CanQualType ASTContext::getFromTargetType(unsigned Type) const {
/// FIXME: Move to Type.
///
bool ASTContext::isObjCNSObjectType(QualType Ty) const {
if (TypedefType *TDT = dyn_cast<TypedefType>(Ty)) {
if (const TypedefType *TDT = dyn_cast<TypedefType>(Ty)) {
if (TypedefDecl *TD = TDT->getDecl())
if (TD->getAttr<ObjCNSObjectAttr>())
return true;
@ -5513,7 +5518,7 @@ QualType ASTContext::mergeObjCGCQualifiers(QualType LHS, QualType RHS) {
//===----------------------------------------------------------------------===//
unsigned ASTContext::getIntWidth(QualType T) const {
if (EnumType *ET = dyn_cast<EnumType>(T))
if (const EnumType *ET = dyn_cast<EnumType>(T))
T = ET->getDecl()->getIntegerType();
if (T->isBooleanType())
return 1;

View File

@ -41,41 +41,41 @@ namespace {
using StmtVisitor<ASTNodeImporter, Stmt *>::Visit;
// Importing types
QualType VisitType(Type *T);
QualType VisitBuiltinType(BuiltinType *T);
QualType VisitComplexType(ComplexType *T);
QualType VisitPointerType(PointerType *T);
QualType VisitBlockPointerType(BlockPointerType *T);
QualType VisitLValueReferenceType(LValueReferenceType *T);
QualType VisitRValueReferenceType(RValueReferenceType *T);
QualType VisitMemberPointerType(MemberPointerType *T);
QualType VisitConstantArrayType(ConstantArrayType *T);
QualType VisitIncompleteArrayType(IncompleteArrayType *T);
QualType VisitVariableArrayType(VariableArrayType *T);
QualType VisitType(const Type *T);
QualType VisitBuiltinType(const BuiltinType *T);
QualType VisitComplexType(const ComplexType *T);
QualType VisitPointerType(const PointerType *T);
QualType VisitBlockPointerType(const BlockPointerType *T);
QualType VisitLValueReferenceType(const LValueReferenceType *T);
QualType VisitRValueReferenceType(const RValueReferenceType *T);
QualType VisitMemberPointerType(const MemberPointerType *T);
QualType VisitConstantArrayType(const ConstantArrayType *T);
QualType VisitIncompleteArrayType(const IncompleteArrayType *T);
QualType VisitVariableArrayType(const VariableArrayType *T);
// FIXME: DependentSizedArrayType
// FIXME: DependentSizedExtVectorType
QualType VisitVectorType(VectorType *T);
QualType VisitExtVectorType(ExtVectorType *T);
QualType VisitFunctionNoProtoType(FunctionNoProtoType *T);
QualType VisitFunctionProtoType(FunctionProtoType *T);
QualType VisitVectorType(const VectorType *T);
QualType VisitExtVectorType(const ExtVectorType *T);
QualType VisitFunctionNoProtoType(const FunctionNoProtoType *T);
QualType VisitFunctionProtoType(const FunctionProtoType *T);
// FIXME: UnresolvedUsingType
QualType VisitTypedefType(TypedefType *T);
QualType VisitTypeOfExprType(TypeOfExprType *T);
QualType VisitTypedefType(const TypedefType *T);
QualType VisitTypeOfExprType(const TypeOfExprType *T);
// FIXME: DependentTypeOfExprType
QualType VisitTypeOfType(TypeOfType *T);
QualType VisitDecltypeType(DecltypeType *T);
QualType VisitTypeOfType(const TypeOfType *T);
QualType VisitDecltypeType(const DecltypeType *T);
// FIXME: DependentDecltypeType
QualType VisitRecordType(RecordType *T);
QualType VisitEnumType(EnumType *T);
QualType VisitRecordType(const RecordType *T);
QualType VisitEnumType(const EnumType *T);
// FIXME: TemplateTypeParmType
// FIXME: SubstTemplateTypeParmType
QualType VisitTemplateSpecializationType(TemplateSpecializationType *T);
QualType VisitElaboratedType(ElaboratedType *T);
QualType VisitTemplateSpecializationType(const TemplateSpecializationType *T);
QualType VisitElaboratedType(const ElaboratedType *T);
// FIXME: DependentNameType
// FIXME: DependentTemplateSpecializationType
QualType VisitObjCInterfaceType(ObjCInterfaceType *T);
QualType VisitObjCObjectType(ObjCObjectType *T);
QualType VisitObjCObjectPointerType(ObjCObjectPointerType *T);
QualType VisitObjCInterfaceType(const ObjCInterfaceType *T);
QualType VisitObjCObjectType(const ObjCObjectType *T);
QualType VisitObjCObjectPointerType(const ObjCObjectPointerType *T);
// Importing declarations
bool ImportDeclParts(NamedDecl *D, DeclContext *&DC,
@ -1279,13 +1279,13 @@ bool StructuralEquivalenceContext::Finish() {
// Import Types
//----------------------------------------------------------------------------
QualType ASTNodeImporter::VisitType(Type *T) {
QualType ASTNodeImporter::VisitType(const Type *T) {
Importer.FromDiag(SourceLocation(), diag::err_unsupported_ast_node)
<< T->getTypeClassName();
return QualType();
}
QualType ASTNodeImporter::VisitBuiltinType(BuiltinType *T) {
QualType ASTNodeImporter::VisitBuiltinType(const BuiltinType *T) {
switch (T->getKind()) {
case BuiltinType::Void: return Importer.getToContext().VoidTy;
case BuiltinType::Bool: return Importer.getToContext().BoolTy;
@ -1365,7 +1365,7 @@ QualType ASTNodeImporter::VisitBuiltinType(BuiltinType *T) {
return QualType();
}
QualType ASTNodeImporter::VisitComplexType(ComplexType *T) {
QualType ASTNodeImporter::VisitComplexType(const ComplexType *T) {
QualType ToElementType = Importer.Import(T->getElementType());
if (ToElementType.isNull())
return QualType();
@ -1373,7 +1373,7 @@ QualType ASTNodeImporter::VisitComplexType(ComplexType *T) {
return Importer.getToContext().getComplexType(ToElementType);
}
QualType ASTNodeImporter::VisitPointerType(PointerType *T) {
QualType ASTNodeImporter::VisitPointerType(const PointerType *T) {
QualType ToPointeeType = Importer.Import(T->getPointeeType());
if (ToPointeeType.isNull())
return QualType();
@ -1381,7 +1381,7 @@ QualType ASTNodeImporter::VisitPointerType(PointerType *T) {
return Importer.getToContext().getPointerType(ToPointeeType);
}
QualType ASTNodeImporter::VisitBlockPointerType(BlockPointerType *T) {
QualType ASTNodeImporter::VisitBlockPointerType(const BlockPointerType *T) {
// FIXME: Check for blocks support in "to" context.
QualType ToPointeeType = Importer.Import(T->getPointeeType());
if (ToPointeeType.isNull())
@ -1390,7 +1390,8 @@ QualType ASTNodeImporter::VisitBlockPointerType(BlockPointerType *T) {
return Importer.getToContext().getBlockPointerType(ToPointeeType);
}
QualType ASTNodeImporter::VisitLValueReferenceType(LValueReferenceType *T) {
QualType
ASTNodeImporter::VisitLValueReferenceType(const LValueReferenceType *T) {
// FIXME: Check for C++ support in "to" context.
QualType ToPointeeType = Importer.Import(T->getPointeeTypeAsWritten());
if (ToPointeeType.isNull())
@ -1399,7 +1400,8 @@ QualType ASTNodeImporter::VisitLValueReferenceType(LValueReferenceType *T) {
return Importer.getToContext().getLValueReferenceType(ToPointeeType);
}
QualType ASTNodeImporter::VisitRValueReferenceType(RValueReferenceType *T) {
QualType
ASTNodeImporter::VisitRValueReferenceType(const RValueReferenceType *T) {
// FIXME: Check for C++0x support in "to" context.
QualType ToPointeeType = Importer.Import(T->getPointeeTypeAsWritten());
if (ToPointeeType.isNull())
@ -1408,7 +1410,7 @@ QualType ASTNodeImporter::VisitRValueReferenceType(RValueReferenceType *T) {
return Importer.getToContext().getRValueReferenceType(ToPointeeType);
}
QualType ASTNodeImporter::VisitMemberPointerType(MemberPointerType *T) {
QualType ASTNodeImporter::VisitMemberPointerType(const MemberPointerType *T) {
// FIXME: Check for C++ support in "to" context.
QualType ToPointeeType = Importer.Import(T->getPointeeType());
if (ToPointeeType.isNull())
@ -1419,7 +1421,7 @@ QualType ASTNodeImporter::VisitMemberPointerType(MemberPointerType *T) {
ClassType.getTypePtr());
}
QualType ASTNodeImporter::VisitConstantArrayType(ConstantArrayType *T) {
QualType ASTNodeImporter::VisitConstantArrayType(const ConstantArrayType *T) {
QualType ToElementType = Importer.Import(T->getElementType());
if (ToElementType.isNull())
return QualType();
@ -1430,7 +1432,8 @@ QualType ASTNodeImporter::VisitConstantArrayType(ConstantArrayType *T) {
T->getIndexTypeCVRQualifiers());
}
QualType ASTNodeImporter::VisitIncompleteArrayType(IncompleteArrayType *T) {
QualType
ASTNodeImporter::VisitIncompleteArrayType(const IncompleteArrayType *T) {
QualType ToElementType = Importer.Import(T->getElementType());
if (ToElementType.isNull())
return QualType();
@ -1440,7 +1443,7 @@ QualType ASTNodeImporter::VisitIncompleteArrayType(IncompleteArrayType *T) {
T->getIndexTypeCVRQualifiers());
}
QualType ASTNodeImporter::VisitVariableArrayType(VariableArrayType *T) {
QualType ASTNodeImporter::VisitVariableArrayType(const VariableArrayType *T) {
QualType ToElementType = Importer.Import(T->getElementType());
if (ToElementType.isNull())
return QualType();
@ -1456,7 +1459,7 @@ QualType ASTNodeImporter::VisitVariableArrayType(VariableArrayType *T) {
Brackets);
}
QualType ASTNodeImporter::VisitVectorType(VectorType *T) {
QualType ASTNodeImporter::VisitVectorType(const VectorType *T) {
QualType ToElementType = Importer.Import(T->getElementType());
if (ToElementType.isNull())
return QualType();
@ -1466,7 +1469,7 @@ QualType ASTNodeImporter::VisitVectorType(VectorType *T) {
T->getVectorKind());
}
QualType ASTNodeImporter::VisitExtVectorType(ExtVectorType *T) {
QualType ASTNodeImporter::VisitExtVectorType(const ExtVectorType *T) {
QualType ToElementType = Importer.Import(T->getElementType());
if (ToElementType.isNull())
return QualType();
@ -1475,7 +1478,8 @@ QualType ASTNodeImporter::VisitExtVectorType(ExtVectorType *T) {
T->getNumElements());
}
QualType ASTNodeImporter::VisitFunctionNoProtoType(FunctionNoProtoType *T) {
QualType
ASTNodeImporter::VisitFunctionNoProtoType(const FunctionNoProtoType *T) {
// FIXME: What happens if we're importing a function without a prototype
// into C++? Should we make it variadic?
QualType ToResultType = Importer.Import(T->getResultType());
@ -1486,7 +1490,7 @@ QualType ASTNodeImporter::VisitFunctionNoProtoType(FunctionNoProtoType *T) {
T->getExtInfo());
}
QualType ASTNodeImporter::VisitFunctionProtoType(FunctionProtoType *T) {
QualType ASTNodeImporter::VisitFunctionProtoType(const FunctionProtoType *T) {
QualType ToResultType = Importer.Import(T->getResultType());
if (ToResultType.isNull())
return QualType();
@ -1520,7 +1524,7 @@ QualType ASTNodeImporter::VisitFunctionProtoType(FunctionProtoType *T) {
ArgTypes.size(), EPI);
}
QualType ASTNodeImporter::VisitTypedefType(TypedefType *T) {
QualType ASTNodeImporter::VisitTypedefType(const TypedefType *T) {
TypedefDecl *ToDecl
= dyn_cast_or_null<TypedefDecl>(Importer.Import(T->getDecl()));
if (!ToDecl)
@ -1529,7 +1533,7 @@ QualType ASTNodeImporter::VisitTypedefType(TypedefType *T) {
return Importer.getToContext().getTypeDeclType(ToDecl);
}
QualType ASTNodeImporter::VisitTypeOfExprType(TypeOfExprType *T) {
QualType ASTNodeImporter::VisitTypeOfExprType(const TypeOfExprType *T) {
Expr *ToExpr = Importer.Import(T->getUnderlyingExpr());
if (!ToExpr)
return QualType();
@ -1537,7 +1541,7 @@ QualType ASTNodeImporter::VisitTypeOfExprType(TypeOfExprType *T) {
return Importer.getToContext().getTypeOfExprType(ToExpr);
}
QualType ASTNodeImporter::VisitTypeOfType(TypeOfType *T) {
QualType ASTNodeImporter::VisitTypeOfType(const TypeOfType *T) {
QualType ToUnderlyingType = Importer.Import(T->getUnderlyingType());
if (ToUnderlyingType.isNull())
return QualType();
@ -1545,7 +1549,7 @@ QualType ASTNodeImporter::VisitTypeOfType(TypeOfType *T) {
return Importer.getToContext().getTypeOfType(ToUnderlyingType);
}
QualType ASTNodeImporter::VisitDecltypeType(DecltypeType *T) {
QualType ASTNodeImporter::VisitDecltypeType(const DecltypeType *T) {
Expr *ToExpr = Importer.Import(T->getUnderlyingExpr());
if (!ToExpr)
return QualType();
@ -1553,7 +1557,7 @@ QualType ASTNodeImporter::VisitDecltypeType(DecltypeType *T) {
return Importer.getToContext().getDecltypeType(ToExpr);
}
QualType ASTNodeImporter::VisitRecordType(RecordType *T) {
QualType ASTNodeImporter::VisitRecordType(const RecordType *T) {
RecordDecl *ToDecl
= dyn_cast_or_null<RecordDecl>(Importer.Import(T->getDecl()));
if (!ToDecl)
@ -1562,7 +1566,7 @@ QualType ASTNodeImporter::VisitRecordType(RecordType *T) {
return Importer.getToContext().getTagDeclType(ToDecl);
}
QualType ASTNodeImporter::VisitEnumType(EnumType *T) {
QualType ASTNodeImporter::VisitEnumType(const EnumType *T) {
EnumDecl *ToDecl
= dyn_cast_or_null<EnumDecl>(Importer.Import(T->getDecl()));
if (!ToDecl)
@ -1572,7 +1576,7 @@ QualType ASTNodeImporter::VisitEnumType(EnumType *T) {
}
QualType ASTNodeImporter::VisitTemplateSpecializationType(
TemplateSpecializationType *T) {
const TemplateSpecializationType *T) {
TemplateName ToTemplate = Importer.Import(T->getTemplateName());
if (ToTemplate.isNull())
return QualType();
@ -1595,7 +1599,7 @@ QualType ASTNodeImporter::VisitTemplateSpecializationType(
ToCanonType);
}
QualType ASTNodeImporter::VisitElaboratedType(ElaboratedType *T) {
QualType ASTNodeImporter::VisitElaboratedType(const ElaboratedType *T) {
NestedNameSpecifier *ToQualifier = 0;
// Note: the qualifier in an ElaboratedType is optional.
if (T->getQualifier()) {
@ -1612,7 +1616,7 @@ QualType ASTNodeImporter::VisitElaboratedType(ElaboratedType *T) {
ToQualifier, ToNamedType);
}
QualType ASTNodeImporter::VisitObjCInterfaceType(ObjCInterfaceType *T) {
QualType ASTNodeImporter::VisitObjCInterfaceType(const ObjCInterfaceType *T) {
ObjCInterfaceDecl *Class
= dyn_cast_or_null<ObjCInterfaceDecl>(Importer.Import(T->getDecl()));
if (!Class)
@ -1621,7 +1625,7 @@ QualType ASTNodeImporter::VisitObjCInterfaceType(ObjCInterfaceType *T) {
return Importer.getToContext().getObjCInterfaceType(Class);
}
QualType ASTNodeImporter::VisitObjCObjectType(ObjCObjectType *T) {
QualType ASTNodeImporter::VisitObjCObjectType(const ObjCObjectType *T) {
QualType ToBaseType = Importer.Import(T->getBaseType());
if (ToBaseType.isNull())
return QualType();
@ -1642,7 +1646,8 @@ QualType ASTNodeImporter::VisitObjCObjectType(ObjCObjectType *T) {
Protocols.size());
}
QualType ASTNodeImporter::VisitObjCObjectPointerType(ObjCObjectPointerType *T) {
QualType
ASTNodeImporter::VisitObjCObjectPointerType(const ObjCObjectPointerType *T) {
QualType ToPointeeType = Importer.Import(T->getPointeeType());
if (ToPointeeType.isNull())
return QualType();
@ -3920,23 +3925,25 @@ ASTImporter::~ASTImporter() { }
QualType ASTImporter::Import(QualType FromT) {
if (FromT.isNull())
return QualType();
const Type *fromTy = FromT.getTypePtr();
// Check whether we've already imported this type.
llvm::DenseMap<Type *, Type *>::iterator Pos
= ImportedTypes.find(FromT.getTypePtr());
llvm::DenseMap<const Type *, const Type *>::iterator Pos
= ImportedTypes.find(fromTy);
if (Pos != ImportedTypes.end())
return ToContext.getQualifiedType(Pos->second, FromT.getQualifiers());
return ToContext.getQualifiedType(Pos->second, FromT.getLocalQualifiers());
// Import the type
ASTNodeImporter Importer(*this);
QualType ToT = Importer.Visit(FromT.getTypePtr());
QualType ToT = Importer.Visit(fromTy);
if (ToT.isNull())
return ToT;
// Record the imported type.
ImportedTypes[FromT.getTypePtr()] = ToT.getTypePtr();
ImportedTypes[fromTy] = ToT.getTypePtr();
return ToContext.getQualifiedType(ToT, FromT.getQualifiers());
return ToContext.getQualifiedType(ToT, FromT.getLocalQualifiers());
}
TypeSourceInfo *ASTImporter::Import(TypeSourceInfo *FromTSI) {
@ -4282,7 +4289,7 @@ Decl *ASTImporter::Imported(Decl *From, Decl *To) {
}
bool ASTImporter::IsStructurallyEquivalent(QualType From, QualType To) {
llvm::DenseMap<Type *, Type *>::iterator Pos
llvm::DenseMap<const Type *, const Type *>::iterator Pos
= ImportedTypes.find(From.getTypePtr());
if (Pos != ImportedTypes.end() && ToContext.hasSameType(Import(From), To))
return true;

View File

@ -1891,7 +1891,7 @@ TagDecl* TagDecl::getCanonicalDecl() {
void TagDecl::setTypedefForAnonDecl(TypedefDecl *TDD) {
TypedefDeclOrQualifier = TDD;
if (TypeForDecl)
TypeForDecl->ClearLinkageCache();
const_cast<Type*>(TypeForDecl)->ClearLinkageCache();
ClearLinkageCache();
}

View File

@ -1068,13 +1068,6 @@ TypeLoc CXXCtorInitializer::getBaseClassLoc() const {
return TypeLoc();
}
Type *CXXCtorInitializer::getBaseClass() {
if (isBaseInitializer())
return Initializee.get<TypeSourceInfo*>()->getType().getTypePtr();
else
return 0;
}
const Type *CXXCtorInitializer::getBaseClass() const {
if (isBaseInitializer())
return Initializee.get<TypeSourceInfo*>()->getType().getTypePtr();

View File

@ -368,7 +368,7 @@ void DeclPrinter::VisitFunctionDecl(FunctionDecl *D) {
std::string Proto = D->getNameInfo().getAsString();
QualType Ty = D->getType();
while (ParenType* PT = dyn_cast<ParenType>(Ty)) {
while (const ParenType *PT = dyn_cast<ParenType>(Ty)) {
Proto = '(' + Proto + ')';
Ty = PT->getInnerType();
}

View File

@ -226,7 +226,7 @@ struct XMLDumper : public XMLDeclVisitor<XMLDumper>,
//---- General utilities -------------------------------------------//
void setPointer(llvm::StringRef prop, void *p) {
void setPointer(llvm::StringRef prop, const void *p) {
llvm::SmallString<10> buffer;
llvm::raw_svector_ostream os(buffer);
os << p;

View File

@ -2768,7 +2768,7 @@ Stmt::child_iterator SizeOfAlignOfExpr::child_begin() {
// size expression of the VLA needs to be treated as an executable expression.
// Why isn't this weirdness documented better in StmtIterator?
if (isArgumentType()) {
if (VariableArrayType* T = dyn_cast<VariableArrayType>(
if (const VariableArrayType* T = dyn_cast<VariableArrayType>(
getArgumentType().getTypePtr()))
return child_iterator(T);
return child_iterator();

View File

@ -995,7 +995,7 @@ CXXRecordDecl *UnresolvedMemberExpr::getNamingClass() const {
// lookup.
CXXRecordDecl *Record = 0;
if (getQualifier()) {
Type *T = getQualifier()->getAsType();
const Type *T = getQualifier()->getAsType();
assert(T && "qualifier in member expression does not name type");
Record = T->getAsCXXRecordDecl();
assert(Record && "qualifier in member expression does not name record");

View File

@ -381,7 +381,8 @@ void CXXNameMangler::mangleFunctionEncoding(const FunctionDecl *FD) {
// Do the canonicalization out here because parameter types can
// undergo additional canonicalization (e.g. array decay).
FunctionType *FT = cast<FunctionType>(Context.getASTContext()
const FunctionType *FT
= cast<FunctionType>(Context.getASTContext()
.getCanonicalType(FD->getType()));
mangleBareFunctionType(FT, MangleReturnType);

View File

@ -238,7 +238,7 @@ void MicrosoftCXXNameMangler::mangleVariableEncoding(const VarDecl *VD) {
Out << 'A';
} else if (Ty->isArrayType()) {
// Global arrays are funny, too.
mangleType(static_cast<ArrayType *>(Ty.getTypePtr()), true);
mangleType(cast<ArrayType>(Ty.getTypePtr()), true);
Out << 'A';
} else {
mangleType(Ty.getLocalUnqualifiedType());

View File

@ -68,12 +68,12 @@ NestedNameSpecifier::Create(const ASTContext &Context,
NestedNameSpecifier *
NestedNameSpecifier::Create(const ASTContext &Context,
NestedNameSpecifier *Prefix,
bool Template, Type *T) {
bool Template, const Type *T) {
assert(T && "Type cannot be NULL");
NestedNameSpecifier Mockup;
Mockup.Prefix.setPointer(Prefix);
Mockup.Prefix.setInt(Template? TypeSpecWithTemplate : TypeSpec);
Mockup.Specifier = T;
Mockup.Specifier = const_cast<Type*>(T);
return FindOrInsert(Context, Mockup);
}
@ -159,7 +159,7 @@ NestedNameSpecifier::print(llvm::raw_ostream &OS,
case TypeSpec: {
std::string TypeStr;
Type *T = getAsType();
const Type *T = getAsType();
PrintingPolicy InnerPolicy(Policy);
InnerPolicy.SuppressScope = true;

View File

@ -18,9 +18,9 @@ using namespace clang;
// FIXME: Add support for dependent-sized array types in C++?
// Does it even make sense to build a CFG for an uninstantiated template?
static inline VariableArrayType* FindVA(Type* t) {
while (ArrayType* vt = dyn_cast<ArrayType>(t)) {
if (VariableArrayType* vat = dyn_cast<VariableArrayType>(vt))
static inline const VariableArrayType *FindVA(const Type* t) {
while (const ArrayType *vt = dyn_cast<ArrayType>(t)) {
if (const VariableArrayType *vat = dyn_cast<VariableArrayType>(vt))
if (vat->getSizeExpr())
return vat;
@ -33,7 +33,7 @@ static inline VariableArrayType* FindVA(Type* t) {
void StmtIteratorBase::NextVA() {
assert (getVAPtr());
VariableArrayType* p = getVAPtr();
const VariableArrayType *p = getVAPtr();
p = FindVA(p->getElementType().getTypePtr());
setVAPtr(p);
@ -90,7 +90,7 @@ void StmtIteratorBase::NextDecl(bool ImmediateAdvance) {
bool StmtIteratorBase::HandleDecl(Decl* D) {
if (VarDecl* VD = dyn_cast<VarDecl>(D)) {
if (VariableArrayType* VAPtr = FindVA(VD->getType().getTypePtr())) {
if (const VariableArrayType* VAPtr = FindVA(VD->getType().getTypePtr())) {
setVAPtr(VAPtr);
return true;
}
@ -99,7 +99,7 @@ bool StmtIteratorBase::HandleDecl(Decl* D) {
return true;
}
else if (TypedefDecl* TD = dyn_cast<TypedefDecl>(D)) {
if (VariableArrayType* VAPtr =
if (const VariableArrayType* VAPtr =
FindVA(TD->getUnderlyingType().getTypePtr())) {
setVAPtr(VAPtr);
return true;
@ -124,16 +124,16 @@ StmtIteratorBase::StmtIteratorBase(Decl** dgi, Decl** dge)
NextDecl(false);
}
StmtIteratorBase::StmtIteratorBase(VariableArrayType* t)
StmtIteratorBase::StmtIteratorBase(const VariableArrayType* t)
: stmt(0), decl(0), RawVAPtr(SizeOfTypeVAMode) {
RawVAPtr |= reinterpret_cast<uintptr_t>(t);
}
Stmt*& StmtIteratorBase::GetDeclExpr() const {
if (VariableArrayType* VAPtr = getVAPtr()) {
if (const VariableArrayType* VAPtr = getVAPtr()) {
assert (VAPtr->SizeExpr);
return VAPtr->SizeExpr;
return const_cast<Stmt*&>(VAPtr->SizeExpr);
}
assert (inDecl() || inDeclGroup());

View File

@ -419,9 +419,9 @@ private:
// FIXME: Add support for dependent-sized array types in C++?
// Does it even make sense to build a CFG for an uninstantiated template?
static VariableArrayType* FindVA(Type* t) {
while (ArrayType* vt = dyn_cast<ArrayType>(t)) {
if (VariableArrayType* vat = dyn_cast<VariableArrayType>(vt))
static const VariableArrayType *FindVA(const Type *t) {
while (const ArrayType *vt = dyn_cast<ArrayType>(t)) {
if (const VariableArrayType *vat = dyn_cast<VariableArrayType>(vt))
if (vat->getSizeExpr())
return vat;
@ -1309,8 +1309,8 @@ CFGBlock *CFGBuilder::VisitDeclSubExpr(DeclStmt* DS) {
}
// If the type of VD is a VLA, then we must process its size expressions.
for (VariableArrayType* VA = FindVA(VD->getType().getTypePtr()); VA != 0;
VA = FindVA(VA->getElementType().getTypePtr()))
for (const VariableArrayType* VA = FindVA(VD->getType().getTypePtr());
VA != 0; VA = FindVA(VA->getElementType().getTypePtr()))
Block = addStmt(VA->getSizeExpr());
// Remove variable from local scope.
@ -2100,7 +2100,7 @@ CFGBlock *CFGBuilder::VisitSizeOfAlignOfExpr(SizeOfAlignOfExpr *E,
// VLA types have expressions that must be evaluated.
if (E->isArgumentType()) {
for (VariableArrayType* VA = FindVA(E->getArgumentType().getTypePtr());
for (const VariableArrayType *VA =FindVA(E->getArgumentType().getTypePtr());
VA != 0; VA = FindVA(VA->getElementType().getTypePtr()))
addStmt(VA->getSizeExpr());
}

View File

@ -118,7 +118,7 @@ cocoa::NamingConvention cocoa::deriveNamingConvention(Selector S,
bool cocoa::isRefType(QualType RetTy, llvm::StringRef Prefix,
llvm::StringRef Name) {
// Recursively walk the typedef stack, allowing typedefs of reference types.
while (TypedefType* TD = dyn_cast<TypedefType>(RetTy.getTypePtr())) {
while (const TypedefType *TD = dyn_cast<TypedefType>(RetTy.getTypePtr())) {
llvm::StringRef TDName = TD->getDecl()->getIdentifier()->getName();
if (TDName.startswith(Prefix) && TDName.endswith("Ref"))
return true;

View File

@ -821,7 +821,7 @@ CodeGenFunction::GenerateBlockFunction(GlobalDecl GD, const BlockExpr *BExpr,
SC_Static,
SC_None,
false, HasPrototype);
if (FunctionProtoType *FT = dyn_cast<FunctionProtoType>(FnType)) {
if (const FunctionProtoType *FT = dyn_cast<FunctionProtoType>(FnType)) {
const FunctionDecl *CFD = dyn_cast<FunctionDecl>(CurCodeDecl);
FunctionDecl *FD = const_cast<FunctionDecl *>(CFD);
llvm::SmallVector<ParmVarDecl*, 16> Params;

View File

@ -1307,11 +1307,9 @@ static QualType UnwrapTypeForDebugInfo(QualType T) {
case Type::TemplateSpecialization:
T = cast<TemplateSpecializationType>(T)->desugar();
break;
case Type::TypeOfExpr: {
TypeOfExprType *Ty = cast<TypeOfExprType>(T);
T = Ty->getUnderlyingExpr()->getType();
case Type::TypeOfExpr:
T = cast<TypeOfExprType>(T)->getUnderlyingExpr()->getType();
break;
}
case Type::TypeOf:
T = cast<TypeOfType>(T)->getUnderlyingType();
break;

View File

@ -2065,8 +2065,7 @@ Value *ScalarExprEmitter::EmitCompare(const BinaryOperator *E,unsigned UICmpOpc,
*SecondVecArg = RHS;
QualType ElTy = LHSTy->getAs<VectorType>()->getElementType();
Type *Ty = CGF.getContext().getCanonicalType(ElTy).getTypePtr();
const BuiltinType *BTy = dyn_cast<BuiltinType>(Ty);
const BuiltinType *BTy = ElTy->getAs<BuiltinType>();
BuiltinType::Kind ElementKind = BTy->getKind();
switch(E->getOpcode()) {

View File

@ -100,7 +100,7 @@ CodeGenTBAA::getTBAAInfo(QualType QTy) {
if (TypeHasMayAlias(QTy))
return getChar();
Type *Ty = Context.getCanonicalType(QTy).getTypePtr();
const Type *Ty = Context.getCanonicalType(QTy).getTypePtr();
if (llvm::MDNode *N = MetadataCache[Ty])
return N;

View File

@ -85,7 +85,7 @@ const llvm::Type *CodeGenTypes::ConvertTypeRecursive(QualType T) {
T = Context.getCanonicalType(T);
// See if type is already cached.
llvm::DenseMap<Type *, llvm::PATypeHolder>::iterator
llvm::DenseMap<const Type *, llvm::PATypeHolder>::iterator
I = TypeCache.find(T.getTypePtr());
// If type is found in map and this is not a definition for a opaque
// place holder type then use it. Otherwise, convert type T.

View File

@ -88,7 +88,7 @@ private:
/// and maps llvm::Types to corresponding clang::Type. llvm::PATypeHolder is
/// used instead of llvm::Type because it allows us to bypass potential
/// dangling type pointers due to type refinement on llvm side.
llvm::DenseMap<Type *, llvm::PATypeHolder> TypeCache;
llvm::DenseMap<const Type *, llvm::PATypeHolder> TypeCache;
/// ConvertNewType - Convert type T into a llvm::Type. Do not use this
/// method directly because it does not do any type caching. This method

View File

@ -29,7 +29,7 @@ public:
TypeWriter(DocumentXML& doc) : Doc(doc) {}
#define NODE_XML( CLASS, NAME ) \
void Visit##CLASS(CLASS* T) { \
void Visit##CLASS(const CLASS* T) { \
Doc.addSubNode(NAME);
#define ID_ATTRIBUTE_XML // done by the Document class itself
@ -82,7 +82,7 @@ public:
TypeAdder(DocumentXML& doc) : Doc(doc) {}
#define NODE_XML( CLASS, NAME ) \
void Visit##CLASS(CLASS* T) \
void Visit##CLASS(const CLASS* T) \
{
#define ID_ATTRIBUTE_XML
@ -101,7 +101,7 @@ public:
//---------------------------------------------------------
void DocumentXML::addParentTypes(const Type* pType) {
TypeAdder(*this).Visit(const_cast<Type*>(pType));
TypeAdder(*this).Visit(pType);
}
//---------------------------------------------------------

View File

@ -472,7 +472,7 @@ namespace {
void RewriteObjC::RewriteBlocksInFunctionProtoType(QualType funcType,
NamedDecl *D) {
if (FunctionProtoType *fproto
if (const FunctionProtoType *fproto
= dyn_cast<FunctionProtoType>(funcType.IgnoreParens())) {
for (FunctionProtoType::arg_type_iterator I = fproto->arg_type_begin(),
E = fproto->arg_type_end(); I && (I != E); ++I)
@ -1410,7 +1410,7 @@ Stmt *RewriteObjC::RewriteObjCIvarRefExpr(ObjCIvarRefExpr *IV,
const Expr *BaseExpr = IV->getBase();
if (CurMethodDef) {
if (BaseExpr->getType()->isObjCObjectPointerType()) {
ObjCInterfaceType *iFaceDecl =
const ObjCInterfaceType *iFaceDecl =
dyn_cast<ObjCInterfaceType>(BaseExpr->getType()->getPointeeType());
assert(iFaceDecl && "RewriteObjCIvarRefExpr - iFaceDecl is null");
// lookup which class implements the instance variable.
@ -1457,7 +1457,7 @@ Stmt *RewriteObjC::RewriteObjCIvarRefExpr(ObjCIvarRefExpr *IV,
// Explicit ivar refs need to have a cast inserted.
// FIXME: consider sharing some of this code with the code above.
if (BaseExpr->getType()->isObjCObjectPointerType()) {
ObjCInterfaceType *iFaceDecl =
const ObjCInterfaceType *iFaceDecl =
dyn_cast<ObjCInterfaceType>(BaseExpr->getType()->getPointeeType());
// lookup which class implements the instance variable.
ObjCInterfaceDecl *clsDeclared = 0;

View File

@ -518,7 +518,6 @@ Sema::CXXScopeTy *Sema::BuildCXXNestedNameSpecifier(Scope *S,
// a declaration context.
if (NamespaceAliasDecl *Alias = dyn_cast<NamespaceAliasDecl>(SD))
return NestedNameSpecifier::Create(Context, Prefix,
Alias->getNamespace());
QualType T = Context.getTypeDeclType(cast<TypeDecl>(SD));

View File

@ -827,7 +827,7 @@ NamedDecl *Sema::LazilyCreateBuiltin(IdentifierInfo *II, unsigned bid,
// Create Decl objects for each parameter, adding them to the
// FunctionDecl.
if (FunctionProtoType *FT = dyn_cast<FunctionProtoType>(R)) {
if (const FunctionProtoType *FT = dyn_cast<FunctionProtoType>(R)) {
llvm::SmallVector<ParmVarDecl*, 16> Params;
for (unsigned i = 0, e = FT->getNumArgs(); i != e; ++i)
Params.push_back(ParmVarDecl::Create(Context, New, SourceLocation(), 0,
@ -6143,7 +6143,8 @@ Decl *Sema::ActOnTag(Scope *S, unsigned TagSpec, TagUseKind TUK,
} else {
// If the type is currently being defined, complain
// about a nested redefinition.
TagType *Tag = cast<TagType>(Context.getTagDeclType(PrevTagDecl));
const TagType *Tag
= cast<TagType>(Context.getTagDeclType(PrevTagDecl));
if (Tag->isBeingDefined()) {
Diag(NameLoc, diag::err_nested_redefinition) << Name;
Diag(PrevTagDecl->getLocation(),
@ -7108,7 +7109,7 @@ void Sema::ActOnFields(Scope* S,
FieldDecl *FD = cast<FieldDecl>(Fields[i]);
// Get the type for the field.
Type *FDTy = FD->getType().getTypePtr();
const Type *FDTy = FD->getType().getTypePtr();
if (!FD->isAnonymousStructOrUnion()) {
// Remember all fields written by the user.

View File

@ -2028,7 +2028,7 @@ static void *GetKeyForTopLevelField(FieldDecl *Field) {
}
static void *GetKeyForBase(ASTContext &Context, QualType BaseType) {
return Context.getCanonicalType(BaseType).getTypePtr();
return const_cast<Type*>(Context.getCanonicalType(BaseType).getTypePtr());
}
static void *GetKeyForMember(ASTContext &Context,
@ -2167,7 +2167,7 @@ bool CheckRedundantInit(Sema &S,
<< Field->getDeclName()
<< Init->getSourceRange();
else {
Type *BaseClass = Init->getBaseClass();
const Type *BaseClass = Init->getBaseClass();
assert(BaseClass && "neither field nor base");
S.Diag(Init->getSourceLocation(),
diag::err_multiple_base_initialization)

View File

@ -7986,7 +7986,7 @@ ExprResult Sema::BuildUnaryOp(Scope *S, SourceLocation OpLoc,
// Unary Operators. 'Tok' is the token for the operator.
ExprResult Sema::ActOnUnaryOp(Scope *S, SourceLocation OpLoc,
tok::TokenKind Op, Expr *Input) {
tok::TokenKind Op, Expr *Input) {
return BuildUnaryOp(S, OpLoc, ConvertTokenKindToUnaryOpcode(Op), Input);
}

View File

@ -375,7 +375,7 @@ Sema::ActOnCXXTypeid(SourceLocation OpLoc, SourceLocation LParenLoc,
/// Retrieve the UuidAttr associated with QT.
static UuidAttr *GetUuidAttrOfType(QualType QT) {
// Optionally remove one level of pointer, reference or array indirection.
Type *Ty = QT.getTypePtr();;
const Type *Ty = QT.getTypePtr();;
if (QT->isPointerType() || QT->isReferenceType())
Ty = QT->getPointeeType().getTypePtr();
else if (QT->isArrayType())

View File

@ -647,8 +647,8 @@ bool Sema::IsOverload(FunctionDecl *New, FunctionDecl *Old,
isa<FunctionNoProtoType>(NewQType.getTypePtr()))
return false;
FunctionProtoType* OldType = cast<FunctionProtoType>(OldQType);
FunctionProtoType* NewType = cast<FunctionProtoType>(NewQType);
const FunctionProtoType* OldType = cast<FunctionProtoType>(OldQType);
const FunctionProtoType* NewType = cast<FunctionProtoType>(NewQType);
// The signature of a function includes the types of its
// parameters (C++ 1.3.10), which includes the presence or absence
@ -1012,7 +1012,7 @@ static bool IsStandardConversion(Sema &S, Expr* From, QualType ToType,
FromType = Fn->getType();
if (CXXMethodDecl *Method = dyn_cast<CXXMethodDecl>(Fn)) {
if (!Method->isStatic()) {
Type *ClassType
const Type *ClassType
= S.Context.getTypeDeclType(Method->getParent()).getTypePtr();
FromType = S.Context.getMemberPointerType(FromType, ClassType);
}
@ -1760,8 +1760,8 @@ bool Sema::isObjCPointerConversion(QualType FromType, QualType ToType,
/// for equlity of their argument types. Caller has already checked that
/// they have same number of arguments. This routine assumes that Objective-C
/// pointer types which only differ in their protocol qualifiers are equal.
bool Sema::FunctionArgTypesAreEqual(FunctionProtoType* OldType,
FunctionProtoType* NewType){
bool Sema::FunctionArgTypesAreEqual(const FunctionProtoType *OldType,
const FunctionProtoType *NewType) {
if (!getLangOptions().ObjC1)
return std::equal(OldType->arg_type_begin(), OldType->arg_type_end(),
NewType->arg_type_begin());

View File

@ -5192,7 +5192,7 @@ static bool ScopeSpecifierHasTemplateId(const CXXScopeSpec &SS) {
// C++98 has the same restriction, just worded differently.
for (NestedNameSpecifier *NNS = (NestedNameSpecifier *)SS.getScopeRep();
NNS; NNS = NNS->getPrefix())
if (Type *T = NNS->getAsType())
if (const Type *T = NNS->getAsType())
if (isa<TemplateSpecializationType>(T))
return true;
@ -5867,7 +5867,7 @@ Sema::ActOnTypenameType(Scope *S, SourceLocation TypenameLoc,
// TODO: it's really silly that we make a template specialization
// type earlier only to drop it again here.
TemplateSpecializationType *TST = cast<TemplateSpecializationType>(T);
const TemplateSpecializationType *TST = cast<TemplateSpecializationType>(T);
DependentTemplateName *DTN =
TST->getTemplateName().getAsDependentTemplateName();
assert(DTN && "dependent template has non-dependent name?");

View File

@ -1108,7 +1108,7 @@ TemplateInstantiator::TransformFunctionTypeParam(ParmVarDecl *OldParm,
QualType
TemplateInstantiator::TransformTemplateTypeParmType(TypeLocBuilder &TLB,
TemplateTypeParmTypeLoc TL) {
TemplateTypeParmType *T = TL.getTypePtr();
const TemplateTypeParmType *T = TL.getTypePtr();
if (T->getDepth() < TemplateArgs.getNumLevels()) {
// Replace the template type parameter with its corresponding
// template argument.

View File

@ -1388,7 +1388,7 @@ QualType Sema::GetTypeFromParser(ParsedType Ty, TypeSourceInfo **TInfo) {
}
TypeSourceInfo *DI = 0;
if (LocInfoType *LIT = dyn_cast<LocInfoType>(QT)) {
if (const LocInfoType *LIT = dyn_cast<LocInfoType>(QT)) {
QT = LIT->getType();
DI = LIT->getTypeSourceInfo();
}

View File

@ -3237,7 +3237,7 @@ template<typename Derived>
QualType
TreeTransform<Derived>::TransformMemberPointerType(TypeLocBuilder &TLB,
MemberPointerTypeLoc TL) {
MemberPointerType *T = TL.getTypePtr();
const MemberPointerType *T = TL.getTypePtr();
QualType PointeeType = getDerived().TransformType(TLB, TL.getPointeeLoc());
if (PointeeType.isNull())
@ -3269,7 +3269,7 @@ template<typename Derived>
QualType
TreeTransform<Derived>::TransformConstantArrayType(TypeLocBuilder &TLB,
ConstantArrayTypeLoc TL) {
ConstantArrayType *T = TL.getTypePtr();
const ConstantArrayType *T = TL.getTypePtr();
QualType ElementType = getDerived().TransformType(TLB, TL.getElementLoc());
if (ElementType.isNull())
return QualType();
@ -3304,7 +3304,7 @@ template<typename Derived>
QualType TreeTransform<Derived>::TransformIncompleteArrayType(
TypeLocBuilder &TLB,
IncompleteArrayTypeLoc TL) {
IncompleteArrayType *T = TL.getTypePtr();
const IncompleteArrayType *T = TL.getTypePtr();
QualType ElementType = getDerived().TransformType(TLB, TL.getElementLoc());
if (ElementType.isNull())
return QualType();
@ -3332,7 +3332,7 @@ template<typename Derived>
QualType
TreeTransform<Derived>::TransformVariableArrayType(TypeLocBuilder &TLB,
VariableArrayTypeLoc TL) {
VariableArrayType *T = TL.getTypePtr();
const VariableArrayType *T = TL.getTypePtr();
QualType ElementType = getDerived().TransformType(TLB, TL.getElementLoc());
if (ElementType.isNull())
return QualType();
@ -3372,7 +3372,7 @@ template<typename Derived>
QualType
TreeTransform<Derived>::TransformDependentSizedArrayType(TypeLocBuilder &TLB,
DependentSizedArrayTypeLoc TL) {
DependentSizedArrayType *T = TL.getTypePtr();
const DependentSizedArrayType *T = TL.getTypePtr();
QualType ElementType = getDerived().TransformType(TLB, TL.getElementLoc());
if (ElementType.isNull())
return QualType();
@ -3415,7 +3415,7 @@ template<typename Derived>
QualType TreeTransform<Derived>::TransformDependentSizedExtVectorType(
TypeLocBuilder &TLB,
DependentSizedExtVectorTypeLoc TL) {
DependentSizedExtVectorType *T = TL.getTypePtr();
const DependentSizedExtVectorType *T = TL.getTypePtr();
// FIXME: ext vector locs should be nested
QualType ElementType = getDerived().TransformType(T->getElementType());
@ -3456,7 +3456,7 @@ QualType TreeTransform<Derived>::TransformDependentSizedExtVectorType(
template<typename Derived>
QualType TreeTransform<Derived>::TransformVectorType(TypeLocBuilder &TLB,
VectorTypeLoc TL) {
VectorType *T = TL.getTypePtr();
const VectorType *T = TL.getTypePtr();
QualType ElementType = getDerived().TransformType(T->getElementType());
if (ElementType.isNull())
return QualType();
@ -3479,7 +3479,7 @@ QualType TreeTransform<Derived>::TransformVectorType(TypeLocBuilder &TLB,
template<typename Derived>
QualType TreeTransform<Derived>::TransformExtVectorType(TypeLocBuilder &TLB,
ExtVectorTypeLoc TL) {
VectorType *T = TL.getTypePtr();
const VectorType *T = TL.getTypePtr();
QualType ElementType = getDerived().TransformType(T->getElementType());
if (ElementType.isNull())
return QualType();
@ -3733,7 +3733,7 @@ TreeTransform<Derived>::TransformFunctionProtoType(TypeLocBuilder &TLB,
//
llvm::SmallVector<QualType, 4> ParamTypes;
llvm::SmallVector<ParmVarDecl*, 4> ParamDecls;
FunctionProtoType *T = TL.getTypePtr();
const FunctionProtoType *T = TL.getTypePtr();
QualType ResultType;
@ -3791,7 +3791,7 @@ template<typename Derived>
QualType TreeTransform<Derived>::TransformFunctionNoProtoType(
TypeLocBuilder &TLB,
FunctionNoProtoTypeLoc TL) {
FunctionNoProtoType *T = TL.getTypePtr();
const FunctionNoProtoType *T = TL.getTypePtr();
QualType ResultType = getDerived().TransformType(TLB, TL.getResultLoc());
if (ResultType.isNull())
return QualType();
@ -3812,7 +3812,7 @@ QualType TreeTransform<Derived>::TransformFunctionNoProtoType(
template<typename Derived> QualType
TreeTransform<Derived>::TransformUnresolvedUsingType(TypeLocBuilder &TLB,
UnresolvedUsingTypeLoc TL) {
UnresolvedUsingType *T = TL.getTypePtr();
const UnresolvedUsingType *T = TL.getTypePtr();
Decl *D = getDerived().TransformDecl(TL.getNameLoc(), T->getDecl());
if (!D)
return QualType();
@ -3835,7 +3835,7 @@ TreeTransform<Derived>::TransformUnresolvedUsingType(TypeLocBuilder &TLB,
template<typename Derived>
QualType TreeTransform<Derived>::TransformTypedefType(TypeLocBuilder &TLB,
TypedefTypeLoc TL) {
TypedefType *T = TL.getTypePtr();
const TypedefType *T = TL.getTypePtr();
TypedefDecl *Typedef
= cast_or_null<TypedefDecl>(getDerived().TransformDecl(TL.getNameLoc(),
T->getDecl()));
@ -3910,7 +3910,7 @@ QualType TreeTransform<Derived>::TransformTypeOfType(TypeLocBuilder &TLB,
template<typename Derived>
QualType TreeTransform<Derived>::TransformDecltypeType(TypeLocBuilder &TLB,
DecltypeTypeLoc TL) {
DecltypeType *T = TL.getTypePtr();
const DecltypeType *T = TL.getTypePtr();
// decltype expressions are not potentially evaluated contexts
EnterExpressionEvaluationContext Unevaluated(SemaRef, Sema::Unevaluated);
@ -3937,7 +3937,7 @@ QualType TreeTransform<Derived>::TransformDecltypeType(TypeLocBuilder &TLB,
template<typename Derived>
QualType TreeTransform<Derived>::TransformRecordType(TypeLocBuilder &TLB,
RecordTypeLoc TL) {
RecordType *T = TL.getTypePtr();
const RecordType *T = TL.getTypePtr();
RecordDecl *Record
= cast_or_null<RecordDecl>(getDerived().TransformDecl(TL.getNameLoc(),
T->getDecl()));
@ -3961,7 +3961,7 @@ QualType TreeTransform<Derived>::TransformRecordType(TypeLocBuilder &TLB,
template<typename Derived>
QualType TreeTransform<Derived>::TransformEnumType(TypeLocBuilder &TLB,
EnumTypeLoc TL) {
EnumType *T = TL.getTypePtr();
const EnumType *T = TL.getTypePtr();
EnumDecl *Enum
= cast_or_null<EnumDecl>(getDerived().TransformDecl(TL.getNameLoc(),
T->getDecl()));
@ -4136,7 +4136,7 @@ template<typename Derived>
QualType
TreeTransform<Derived>::TransformElaboratedType(TypeLocBuilder &TLB,
ElaboratedTypeLoc TL) {
ElaboratedType *T = TL.getTypePtr();
const ElaboratedType *T = TL.getTypePtr();
NestedNameSpecifier *NNS = 0;
// NOTE: the qualifier in an ElaboratedType is optional.
@ -4230,7 +4230,7 @@ TreeTransform<Derived>::TransformParenType(TypeLocBuilder &TLB,
template<typename Derived>
QualType TreeTransform<Derived>::TransformDependentNameType(TypeLocBuilder &TLB,
DependentNameTypeLoc TL) {
DependentNameType *T = TL.getTypePtr();
const DependentNameType *T = TL.getTypePtr();
NestedNameSpecifier *NNS
= getDerived().TransformNestedNameSpecifier(T->getQualifier(),
@ -4267,7 +4267,7 @@ template<typename Derived>
QualType TreeTransform<Derived>::
TransformDependentTemplateSpecializationType(TypeLocBuilder &TLB,
DependentTemplateSpecializationTypeLoc TL) {
DependentTemplateSpecializationType *T = TL.getTypePtr();
const DependentTemplateSpecializationType *T = TL.getTypePtr();
NestedNameSpecifier *NNS
= getDerived().TransformNestedNameSpecifier(T->getQualifier(),
@ -4284,7 +4284,7 @@ QualType TreeTransform<Derived>::
TransformDependentTemplateSpecializationType(TypeLocBuilder &TLB,
DependentTemplateSpecializationTypeLoc TL,
NestedNameSpecifier *NNS) {
DependentTemplateSpecializationType *T = TL.getTypePtr();
const DependentTemplateSpecializationType *T = TL.getTypePtr();
TemplateArgumentListInfo NewTemplateArgs;
NewTemplateArgs.setLAngleLoc(TL.getLAngleLoc());

View File

@ -2922,7 +2922,7 @@ QualType ASTReader::ReadTypeRecord(unsigned Index) {
}
bool IsDependent = Record[0];
QualType T = Context->getRecordType(cast<RecordDecl>(GetDecl(Record[1])));
T->setDependent(IsDependent);
const_cast<Type*>(T.getTypePtr())->setDependent(IsDependent);
return T;
}
@ -2933,7 +2933,7 @@ QualType ASTReader::ReadTypeRecord(unsigned Index) {
}
bool IsDependent = Record[0];
QualType T = Context->getEnumType(cast<EnumDecl>(GetDecl(Record[1])));
T->setDependent(IsDependent);
const_cast<Type*>(T.getTypePtr())->setDependent(IsDependent);
return T;
}
@ -3093,7 +3093,7 @@ QualType ASTReader::ReadTypeRecord(unsigned Index) {
else
T = Context->getTemplateSpecializationType(Name, Args.data(),
Args.size(), Canon);
T->setDependent(IsDependent);
const_cast<Type*>(T.getTypePtr())->setDependent(IsDependent);
return T;
}
}
@ -4475,7 +4475,7 @@ ASTReader::ReadNestedNameSpecifier(const RecordData &Record, unsigned &Idx) {
case NestedNameSpecifier::TypeSpec:
case NestedNameSpecifier::TypeSpecWithTemplate: {
Type *T = GetType(Record[Idx++]).getTypePtrOrNull();
const Type *T = GetType(Record[Idx++]).getTypePtrOrNull();
if (!T)
return 0;

View File

@ -63,7 +63,7 @@ void ExprEngine::evalArguments(ConstExprIterator AI, ConstExprIterator AE,
const CXXThisRegion *ExprEngine::getCXXThisRegion(const CXXRecordDecl *D,
const StackFrameContext *SFC) {
Type *T = D->getTypeForDecl();
const Type *T = D->getTypeForDecl();
QualType PT = getContext().getPointerType(QualType(T, 0));
return svalBuilder.getRegionManager().getCXXThisRegion(PT, SFC);
}

View File

@ -38,7 +38,7 @@ void CastSizeChecker::PreVisitCastExpr(CheckerContext &C, const CastExpr *CE) {
const Expr *E = CE->getSubExpr();
ASTContext &Ctx = C.getASTContext();
QualType ToTy = Ctx.getCanonicalType(CE->getType());
PointerType *ToPTy = dyn_cast<PointerType>(ToTy.getTypePtr());
const PointerType *ToPTy = dyn_cast<PointerType>(ToTy.getTypePtr());
if (!ToPTy)
return;

View File

@ -43,8 +43,8 @@ void CastToStructChecker::PreVisitCastExpr(CheckerContext &C,
QualType OrigTy = Ctx.getCanonicalType(E->getType());
QualType ToTy = Ctx.getCanonicalType(CE->getType());
PointerType *OrigPTy = dyn_cast<PointerType>(OrigTy.getTypePtr());
PointerType *ToPTy = dyn_cast<PointerType>(ToTy.getTypePtr());
const PointerType *OrigPTy = dyn_cast<PointerType>(OrigTy.getTypePtr());
const PointerType *ToPTy = dyn_cast<PointerType>(ToTy.getTypePtr());
if (!ToPTy || !OrigPTy)
return;

View File

@ -801,7 +801,7 @@ SVal RegionStoreManager::ArrayToPointer(Loc Array) {
// Strip off typedefs from the ArrayRegion's ValueType.
QualType T = ArrayR->getValueType().getDesugaredType(Ctx);
ArrayType *AT = cast<ArrayType>(T);
const ArrayType *AT = cast<ArrayType>(T);
T = AT->getElementType();
NonLoc ZeroIdx = svalBuilder.makeZeroArrayIndex();

View File

@ -1172,7 +1172,7 @@ bool CursorVisitor::VisitNestedNameSpecifier(NestedNameSpecifier *NNS,
// If the type has a form where we know that the beginning of the source
// range matches up with a reference cursor. Visit the appropriate reference
// cursor.
Type *T = NNS->getAsType();
const Type *T = NNS->getAsType();
if (const TypedefType *Typedef = dyn_cast<TypedefType>(T))
return Visit(MakeCursorTypeRef(Typedef->getDecl(), Range.getBegin(), TU));
if (const TagType *Tag = dyn_cast<TagType>(T))

View File

@ -64,7 +64,7 @@ static CXTypeKind GetBuiltinTypeKind(const BuiltinType *BT) {
}
static CXTypeKind GetTypeKind(QualType T) {
Type *TP = T.getTypePtrOrNull();
const Type *TP = T.getTypePtrOrNull();
if (!TP)
return CXType_Invalid;
@ -187,7 +187,7 @@ CXType clang_getCanonicalType(CXType CT) {
CXType clang_getPointeeType(CXType CT) {
QualType T = GetQualType(CT);
Type *TP = T.getTypePtrOrNull();
const Type *TP = T.getTypePtrOrNull();
if (!TP)
return MakeCXType(QualType(), GetTU(CT));
@ -218,7 +218,7 @@ CXCursor clang_getTypeDeclaration(CXType CT) {
return cxcursor::MakeCXCursorInvalid(CXCursor_NoDeclFound);
QualType T = GetQualType(CT);
Type *TP = T.getTypePtrOrNull();
const Type *TP = T.getTypePtrOrNull();
if (!TP)
return cxcursor::MakeCXCursorInvalid(CXCursor_NoDeclFound);