From cb51a665b0dad7308b0dd4edf668048ce0eb5242 Mon Sep 17 00:00:00 2001 From: Etienne Bergeron Date: Fri, 13 May 2016 14:31:44 +0000 Subject: [PATCH] [AST] Add missing const qualifiers to AstContext in Type.cpp Summary: Add some missing const qualifiers to AstContext. The ASTContext can't be modified with accessors. There is no behavior change. This patch is cleanup only. Reviewers: rsmith Subscribers: cfe-commits Differential Revision: http://reviews.llvm.org/D20226 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@269418 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/clang/AST/Type.h | 22 +++++++++++----------- lib/AST/Type.cpp | 18 +++++++++--------- 2 files changed, 20 insertions(+), 20 deletions(-) diff --git a/include/clang/AST/Type.h b/include/clang/AST/Type.h index 09b3fc79b8..a68be969eb 100644 --- a/include/clang/AST/Type.h +++ b/include/clang/AST/Type.h @@ -722,27 +722,27 @@ public: /// 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 @@ private: // 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 @@ public: 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 @@ public: /// \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 @@ public: /// \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); } diff --git a/lib/AST/Type.cpp b/lib/AST/Type.cpp index 0262f5ba4a..0e5f0b256e 100644 --- a/lib/AST/Type.cpp +++ b/lib/AST/Type.cpp @@ -64,7 +64,7 @@ const IdentifierInfo* QualType::getBaseTypeIdentifier() const { 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 @@ bool QualType::isConstant(QualType T, ASTContext &Ctx) { 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 @@ unsigned ConstantArrayType::getNumAddressingBits(ASTContext &Context, 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 @@ bool Type::hasIntegerRepresentation() const { /// \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 Type::isIncompleteType(NamedDecl **Def) const { } } -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 @@ bool QualType::isPODType(ASTContext &Context) const { 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::isCXX98PODType(ASTContext &Context) const { } } -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 @@ bool QualType::isTrivialType(ASTContext &Context) const { 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 @@ bool Type::isStandardLayoutType() const { // 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; -- 2.40.0