Include the SourceManager's line table in the PCH file. We can now
properly cope with #line directives in PCH files.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@68963 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/include/clang/Basic/SourceManager.h b/include/clang/Basic/SourceManager.h
index dcf344e..217640e 100644
--- a/include/clang/Basic/SourceManager.h
+++ b/include/clang/Basic/SourceManager.h
@@ -589,7 +589,13 @@
   void AddLineNote(SourceLocation Loc, unsigned LineNo, int FilenameID,
                    bool IsFileEntry, bool IsFileExit, 
                    bool IsSystemHeader, bool IsExternCHeader);
-  
+
+  /// \brief Determine if the source manager has a line table.
+  bool hasLineTable() const { return LineTable != 0; }
+
+  /// \brief Retrieve the stored line table.
+  LineTableInfo &getLineTable();
+
   //===--------------------------------------------------------------------===//
   // Other miscellaneous methods.
   //===--------------------------------------------------------------------===//
@@ -624,6 +630,11 @@
 
   unsigned sloc_entry_size() const { return SLocEntryTable.size(); }
 
+  const SrcMgr::SLocEntry &getSLocEntry(FileID FID) const {
+    assert(FID.ID < SLocEntryTable.size() && "Invalid id");
+    return SLocEntryTable[FID.ID];
+  }
+
 private:
   friend class SrcMgr::ContentCache; // Used for deserialization.
   
@@ -654,11 +665,6 @@
   ///  memory buffer.
   const SrcMgr::ContentCache* 
   createMemBufferContentCache(const llvm::MemoryBuffer *Buf);
-
-  const SrcMgr::SLocEntry &getSLocEntry(FileID FID) const {
-    assert(FID.ID < SLocEntryTable.size() && "Invalid id");
-    return SLocEntryTable[FID.ID];
-  }
   
   FileID getFileIDSlow(unsigned SLocOffset) const;
 
diff --git a/include/clang/Basic/SourceManagerInternals.h b/include/clang/Basic/SourceManagerInternals.h
index 2f90f64..0bcb68e 100644
--- a/include/clang/Basic/SourceManagerInternals.h
+++ b/include/clang/Basic/SourceManagerInternals.h
@@ -102,7 +102,8 @@
     assert(ID < FilenamesByID.size() && "Invalid FilenameID");
     return FilenamesByID[ID]->getKeyData();
   }
-  
+  unsigned getNumFilenames() const { return FilenamesByID.size(); }
+
   void AddLineNote(unsigned FID, unsigned Offset,
                    unsigned LineNo, int FilenameID);
   void AddLineNote(unsigned FID, unsigned Offset,
@@ -113,6 +114,15 @@
   /// FindNearestLineEntry - Find the line entry nearest to FID that is before
   /// it.  If there is no line entry before Offset in FID, return null.
   const LineEntry *FindNearestLineEntry(unsigned FID, unsigned Offset);
+
+  // Low-level access
+  typedef std::map<unsigned, std::vector<LineEntry> >::iterator iterator;
+  iterator begin() { return LineEntries.begin(); }
+  iterator end() { return LineEntries.end(); }
+
+  /// \brief Add a new line entry that has already been encoded into
+  /// the internal representation of the line table.
+  void AddEntry(unsigned FID, const std::vector<LineEntry> &Entries);
 };
 
 } // end namespace clang
diff --git a/include/clang/Frontend/PCHBitCodes.h b/include/clang/Frontend/PCHBitCodes.h
index 7782f36..79d70c8 100644
--- a/include/clang/Frontend/PCHBitCodes.h
+++ b/include/clang/Frontend/PCHBitCodes.h
@@ -147,7 +147,10 @@
       SM_SLOC_BUFFER_BLOB = 3,
       /// \brief Describes a source location entry (SLocEntry) for a
       /// macro instantiation.
-      SM_SLOC_INSTANTIATION_ENTRY = 4
+      SM_SLOC_INSTANTIATION_ENTRY = 4,
+      /// \brief Describes the SourceManager's line table, with
+      /// information about #line directives.
+      SM_LINE_TABLE = 5
     };
     
     /// \brief Record types used within a preprocessor block.