]> granicus.if.org Git - clang/commitdiff
more plumbing for #line propagation. Use happy bit #3
authorChris Lattner <sabre@nondot.org>
Tue, 3 Feb 2009 22:13:05 +0000 (22:13 +0000)
committerChris Lattner <sabre@nondot.org>
Tue, 3 Feb 2009 22:13:05 +0000 (22:13 +0000)
out of FileInfo :)

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@63672 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/Basic/SourceManager.h
lib/Basic/SourceManager.cpp

index a875f93c33a8863203bad4ffd630ec756c5dec86..dd76f7896f81441eb024e1134eb42c2f16ab02ae 100644 (file)
@@ -161,6 +161,16 @@ namespace SrcMgr {
     CharacteristicKind getFileCharacteristic() const { 
       return (CharacteristicKind)(Data & 3);
     }
+
+    /// hasLineDirectives - Return true if this FileID has #line directives in
+    /// it.
+    bool hasLineDirectives() const { return (Data & 4) != 0; }
+    
+    /// setHasLineDirectives - Set the flag that indicates that this FileID has
+    /// line table entries associated with it.
+    void setHasLineDirectives() {
+      Data |= 4;
+    }
   };
   
   /// InstantiationInfo - Each InstantiationInfo encodes the Instantiation
index ce9efb034a9375f7d1e692477c0e927e19285d25..02568d373fe4afbf731f5476d39c0f2820beeb1f 100644 (file)
@@ -84,7 +84,8 @@ public:
   ~LineTableInfo() {}
   
   unsigned getLineTableFilenameID(const char *Ptr, unsigned Len);
-
+  void AddLineNote(FileID FID, unsigned Offset,
+                   unsigned LineNo, int FilenameID);
 };
 } // namespace clang
 
@@ -105,6 +106,16 @@ unsigned LineTableInfo::getLineTableFilenameID(const char *Ptr, unsigned Len) {
   return FilenamesByID.size()-1;
 }
 
+/// AddLineNote - Add a line note to the line table that indicates that there
+/// is a #line at the specified FID/Offset location which changes the presumed
+/// location to LineNo/FilenameID.
+void LineTableInfo::AddLineNote(FileID FID, unsigned Offset,
+                                unsigned LineNo, int FilenameID) {
+  
+}
+
+
+
 /// getLineTableFilenameID - Return the uniqued ID for the specified filename.
 /// 
 unsigned SourceManager::getLineTableFilenameID(const char *Ptr, unsigned Len) {
@@ -119,7 +130,16 @@ unsigned SourceManager::getLineTableFilenameID(const char *Ptr, unsigned Len) {
 /// unspecified.
 void SourceManager::AddLineNote(SourceLocation Loc, unsigned LineNo,
                                 int FilenameID) {
+  std::pair<FileID, unsigned> LocInfo = getDecomposedInstantiationLoc(Loc);
+  
+  const SrcMgr::FileInfo &FileInfo = getSLocEntry(LocInfo.first).getFile();
+
+  // Remember that this file has #line directives now if it doesn't already.
+  const_cast<SrcMgr::FileInfo&>(FileInfo).setHasLineDirectives();
   
+  if (LineTable == 0)
+    LineTable = new LineTableInfo();
+  LineTable->AddLineNote(LocInfo.first, LocInfo.second, LineNo, FilenameID);
 }