]> granicus.if.org Git - clang/commitdiff
Increase the max PCH level for declarations to 7. Add a FromPCH flag to types.
authorSebastian Redl <sebastian.redl@getdesigned.at>
Wed, 14 Jul 2010 20:26:45 +0000 (20:26 +0000)
committerSebastian Redl <sebastian.redl@getdesigned.at>
Wed, 14 Jul 2010 20:26:45 +0000 (20:26 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@108354 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/AST/DeclBase.h
include/clang/AST/Type.h
lib/Frontend/PCHReader.cpp

index 2d2407ffb18d67eeb49b29a056160d5c59ab5578..be30b8ed296be3ab1c2675150f7e8a254fef2439 100644 (file)
@@ -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;
   }
index 49dbd3ec2950bcec5a3f04a3147c4703d864372b..4c148e8fa221fbd4c3ac14c9ce59733c97e9e303 100644 (file)
@@ -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<TypeClass>(TC); }
 
+  /// \brief Whether this type comes from a PCH file.
+  bool isFromPCH() const { return FromPCH; }
+
   bool isCanonicalUnqualified() const {
     return CanonicalType.getTypePtr() == this;
   }
index cb0be410b5a425ba39b6ef8b7901269ad4024260..56b77b1e94c1d7b89f1c11b3050f6ce26b7c0b12 100644 (file)
@@ -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);
 }