[cfe-commits] r63672 - in /cfe/trunk: include/clang/Basic/SourceManager.h lib/Basic/SourceManager.cpp

Chris Lattner sabre at nondot.org
Tue Feb 3 14:13:05 PST 2009


Author: lattner
Date: Tue Feb  3 16:13:05 2009
New Revision: 63672

URL: http://llvm.org/viewvc/llvm-project?rev=63672&view=rev
Log:
more plumbing for #line propagation.  Use happy bit #3 
out of FileInfo :)

Modified:
    cfe/trunk/include/clang/Basic/SourceManager.h
    cfe/trunk/lib/Basic/SourceManager.cpp

Modified: cfe/trunk/include/clang/Basic/SourceManager.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/SourceManager.h?rev=63672&r1=63671&r2=63672&view=diff

==============================================================================
--- cfe/trunk/include/clang/Basic/SourceManager.h (original)
+++ cfe/trunk/include/clang/Basic/SourceManager.h Tue Feb  3 16:13:05 2009
@@ -161,6 +161,16 @@
     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

Modified: cfe/trunk/lib/Basic/SourceManager.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/SourceManager.cpp?rev=63672&r1=63671&r2=63672&view=diff

==============================================================================
--- cfe/trunk/lib/Basic/SourceManager.cpp (original)
+++ cfe/trunk/lib/Basic/SourceManager.cpp Tue Feb  3 16:13:05 2009
@@ -84,7 +84,8 @@
   ~LineTableInfo() {}
   
   unsigned getLineTableFilenameID(const char *Ptr, unsigned Len);
-
+  void AddLineNote(FileID FID, unsigned Offset,
+                   unsigned LineNo, int FilenameID);
 };
 } // namespace clang
 
@@ -105,6 +106,16 @@
   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 @@
 /// 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);
 }
 
 





More information about the cfe-commits mailing list