From: Sebastian Redl Date: Wed, 14 Jul 2010 20:26:45 +0000 (+0000) Subject: Increase the max PCH level for declarations to 7. Add a FromPCH flag to types. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=07a353c2af3a3c557205466d4f4ed2513462ebfe;p=clang Increase the max PCH level for declarations to 7. Add a FromPCH flag to types. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@108354 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/clang/AST/DeclBase.h b/include/clang/AST/DeclBase.h index 2d2407ffb1..be30b8ed29 100644 --- a/include/clang/AST/DeclBase.h +++ b/include/clang/AST/DeclBase.h @@ -92,7 +92,7 @@ public: /// These are meant as bitmasks, so that searches in /// C++ can look into the "tag" namespace during ordinary lookup. /// - /// Decl currently provides 16 bits of IDNS bits. + /// Decl currently provides 15 bits of IDNS bits. enum IdentifierNamespace { /// Labels, declared with 'x:' and referenced with 'goto x'. IDNS_Label = 0x0001, @@ -225,10 +225,10 @@ protected: // PCHLevel - the "level" of precompiled header/AST file from which this // declaration was built. - unsigned PCHLevel : 2; + unsigned PCHLevel : 3; /// IdentifierNamespace - This specifies what IDNS_* namespace this lives in. - unsigned IdentifierNamespace : 16; + unsigned IdentifierNamespace : 15; private: #ifndef NDEBUG @@ -358,14 +358,14 @@ public: unsigned getPCHLevel() const { return PCHLevel; } /// \brief The maximum PCH level that any declaration may have. - static const unsigned MaxPCHLevel = 3; - + static const unsigned MaxPCHLevel = 7; + /// \brief Set the PCH level of this declaration. void setPCHLevel(unsigned Level) { - assert(Level < MaxPCHLevel && "PCH level exceeds the maximum"); + assert(Level <= MaxPCHLevel && "PCH level exceeds the maximum"); PCHLevel = Level; } - + unsigned getIdentifierNamespace() const { return IdentifierNamespace; } diff --git a/include/clang/AST/Type.h b/include/clang/AST/Type.h index 49dbd3ec29..4c148e8fa2 100644 --- a/include/clang/AST/Type.h +++ b/include/clang/AST/Type.h @@ -786,19 +786,27 @@ private: /// \brief Linkage of this type. mutable unsigned CachedLinkage : 2; - + + /// \brief FromPCH - Whether this type comes from a PCH file. + mutable bool FromPCH : 1; + + /// \brief Set whether this type comes from a PCH file. + void setFromPCH(bool V = true) const { + FromPCH = V; + } + protected: /// \brief Compute the linkage of this type. virtual Linkage getLinkageImpl() const; - enum { BitsRemainingInType = 20 }; + enum { BitsRemainingInType = 19 }; // silence VC++ warning C4355: 'this' : used in base member initializer list Type *this_() { return this; } Type(TypeClass tc, QualType Canonical, bool dependent) : CanonicalType(Canonical.isNull() ? QualType(this_(), 0) : Canonical), TC(tc), Dependent(dependent), LinkageKnown(false), - CachedLinkage(NoLinkage) {} + CachedLinkage(NoLinkage), FromPCH(false) {} virtual ~Type() {} virtual void Destroy(ASTContext& C); friend class ASTContext; @@ -806,6 +814,9 @@ protected: public: TypeClass getTypeClass() const { return static_cast(TC); } + /// \brief Whether this type comes from a PCH file. + bool isFromPCH() const { return FromPCH; } + bool isCanonicalUnqualified() const { return CanonicalType.getTypePtr() == this; } diff --git a/lib/Frontend/PCHReader.cpp b/lib/Frontend/PCHReader.cpp index cb0be410b5..56b77b1e94 100644 --- a/lib/Frontend/PCHReader.cpp +++ b/lib/Frontend/PCHReader.cpp @@ -2626,8 +2626,10 @@ QualType PCHReader::GetType(pch::TypeID ID) { Index -= pch::NUM_PREDEF_TYPE_IDS; //assert(Index < TypesLoaded.size() && "Type index out-of-range"); - if (TypesLoaded[Index].isNull()) + if (TypesLoaded[Index].isNull()) { TypesLoaded[Index] = ReadTypeRecord(TypeOffsets[Index]); + TypesLoaded[Index]->setFromPCH(); + } return TypesLoaded[Index].withFastQualifiers(FastQuals); }