Index: include/clang/AST/Type.h =================================================================== --- include/clang/AST/Type.h +++ include/clang/AST/Type.h @@ -722,27 +722,27 @@ /// applied to this type. unsigned getCVRQualifiers() const; - bool isConstant(ASTContext& Ctx) const { + bool isConstant(const ASTContext& Ctx) const { return QualType::isConstant(*this, Ctx); } /// \brief Determine whether this is a Plain Old Data (POD) type (C++ 3.9p10). - bool isPODType(ASTContext &Context) const; + bool isPODType(const ASTContext &Context) const; /// Return true if this is a POD type according to the rules of the C++98 /// standard, regardless of the current compilation's language. - bool isCXX98PODType(ASTContext &Context) const; + bool isCXX98PODType(const ASTContext &Context) const; /// Return true if this is a POD type according to the more relaxed rules /// of the C++11 standard, regardless of the current compilation's language. /// (C++0x [basic.types]p9) - bool isCXX11PODType(ASTContext &Context) const; + bool isCXX11PODType(const ASTContext &Context) const; /// Return true if this is a trivial type per (C++0x [basic.types]p9) - bool isTrivialType(ASTContext &Context) const; + bool isTrivialType(const ASTContext &Context) const; /// Return true if this is a trivially copyable type (C++0x [basic.types]p9) - bool isTriviallyCopyableType(ASTContext &Context) const; + bool isTriviallyCopyableType(const ASTContext &Context) const; // Don't promise in the API that anything besides 'const' can be // easily added. @@ -1084,7 +1084,7 @@ // These methods are implemented in a separate translation unit; // "static"-ize them to avoid creating temporary QualTypes in the // caller. - static bool isConstant(QualType T, ASTContext& Ctx); + static bool isConstant(QualType T, const ASTContext& Ctx); static QualType getDesugaredType(QualType T, const ASTContext &Context); static SplitQualType getSplitDesugaredType(QualType T); static SplitQualType getSplitUnqualifiedTypeImpl(QualType type); @@ -1619,7 +1619,7 @@ bool isChar16Type() const; bool isChar32Type() const; bool isAnyCharacterType() const; - bool isIntegralType(ASTContext &Ctx) const; + bool isIntegralType(const ASTContext &Ctx) const; /// Determine whether this type is an integral or enumeration type. bool isIntegralOrEnumerationType() const; @@ -2513,13 +2513,13 @@ /// \brief Determine the number of bits required to address a member of // an array with the given element type and number of elements. - static unsigned getNumAddressingBits(ASTContext &Context, + static unsigned getNumAddressingBits(const ASTContext &Context, QualType ElementType, const llvm::APInt &NumElements); /// \brief Determine the maximum number of active bits that an array's size /// can require, which limits the maximum size of the array. - static unsigned getMaxSizeBits(ASTContext &Context); + static unsigned getMaxSizeBits(const ASTContext &Context); void Profile(llvm::FoldingSetNodeID &ID) { Profile(ID, getElementType(), getSize(), @@ -3004,7 +3004,7 @@ /// \brief Determine the type of an expression that calls a function of /// this type. - QualType getCallResultType(ASTContext &Context) const { + QualType getCallResultType(const ASTContext &Context) const { return getReturnType().getNonLValueExprType(Context); } Index: lib/AST/Type.cpp =================================================================== --- lib/AST/Type.cpp +++ lib/AST/Type.cpp @@ -64,7 +64,7 @@ return nullptr; } -bool QualType::isConstant(QualType T, ASTContext &Ctx) { +bool QualType::isConstant(QualType T, const ASTContext &Ctx) { if (T.isConstQualified()) return true; @@ -74,7 +74,7 @@ return T.getAddressSpace() == LangAS::opencl_constant; } -unsigned ConstantArrayType::getNumAddressingBits(ASTContext &Context, +unsigned ConstantArrayType::getNumAddressingBits(const ASTContext &Context, QualType ElementType, const llvm::APInt &NumElements) { uint64_t ElementSize = Context.getTypeSizeInChars(ElementType).getQuantity(); @@ -109,7 +109,7 @@ return TotalSize.getActiveBits(); } -unsigned ConstantArrayType::getMaxSizeBits(ASTContext &Context) { +unsigned ConstantArrayType::getMaxSizeBits(const ASTContext &Context) { unsigned Bits = Context.getTypeSize(Context.getSizeType()); // Limit the number of bits in size_t so that maximal bit size fits 64 bit @@ -1616,7 +1616,7 @@ /// \param Ctx The context in which this type occurs. /// /// \returns true if the type is considered an integral type, false otherwise. -bool Type::isIntegralType(ASTContext &Ctx) const { +bool Type::isIntegralType(const ASTContext &Ctx) const { if (const BuiltinType *BT = dyn_cast(CanonicalType)) return BT->getKind() >= BuiltinType::Bool && BT->getKind() <= BuiltinType::Int128; @@ -1958,7 +1958,7 @@ } } -bool QualType::isPODType(ASTContext &Context) const { +bool QualType::isPODType(const ASTContext &Context) const { // C++11 has a more relaxed definition of POD. if (Context.getLangOpts().CPlusPlus11) return isCXX11PODType(Context); @@ -1966,7 +1966,7 @@ return isCXX98PODType(Context); } -bool QualType::isCXX98PODType(ASTContext &Context) const { +bool QualType::isCXX98PODType(const ASTContext &Context) const { // The compiler shouldn't query this for incomplete types, but the user might. // We return false for that case. Except for incomplete arrays of PODs, which // are PODs according to the standard. @@ -2026,7 +2026,7 @@ } } -bool QualType::isTrivialType(ASTContext &Context) const { +bool QualType::isTrivialType(const ASTContext &Context) const { // The compiler shouldn't query this for incomplete types, but the user might. // We return false for that case. Except for incomplete arrays of PODs, which // are PODs according to the standard. @@ -2089,7 +2089,7 @@ return false; } -bool QualType::isTriviallyCopyableType(ASTContext &Context) const { +bool QualType::isTriviallyCopyableType(const ASTContext &Context) const { if ((*this)->isArrayType()) return Context.getBaseElementType(*this).isTriviallyCopyableType(Context); @@ -2249,7 +2249,7 @@ // This is effectively the intersection of isTrivialType and // isStandardLayoutType. We implement it directly to avoid redundant // conversions from a type to a CXXRecordDecl. -bool QualType::isCXX11PODType(ASTContext &Context) const { +bool QualType::isCXX11PODType(const ASTContext &Context) const { const Type *ty = getTypePtr(); if (ty->isDependentType()) return false;