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

sabre at cs.uiuc.edu sabre at cs.uiuc.edu
Wed Jul 11 09:23:03 PDT 2007


Author: sabre
Date: Wed Jul 11 11:23:03 2007
New Revision: 38596

URL: http://llvm.org/viewvc/llvm-project?rev=38596&view=rev
Log:
Expose a useful helper method.

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

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

==============================================================================
--- cfe/cfe/trunk/Basic/SourceManager.cpp (original)
+++ cfe/cfe/trunk/Basic/SourceManager.cpp Wed Jul 11 11:23:03 2007
@@ -120,6 +120,20 @@
   return FileIDs.size();
 }
 
+/// getInstantiationLoc - Return a new SourceLocation that encodes the fact
+/// that a token from physloc PhysLoc should actually be referenced from
+/// InstantiationLoc.
+SourceLocation SourceManager::getInstantiationLoc(SourceLocation PhysLoc,
+                                                  SourceLocation InstantLoc) {
+  unsigned CharFilePos = PhysLoc.getRawFilePos();
+  unsigned CharFileID  = PhysLoc.getFileID();
+  
+  unsigned InstantiationFileID =
+    createFileIDForMacroExp(InstantLoc, CharFileID);
+  return SourceLocation(InstantiationFileID, CharFilePos);
+}
+
+
 
 /// getCharacterData - Return a pointer to the start of the specified location
 /// in the appropriate SourceBuffer.  This returns null if it cannot be

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

==============================================================================
--- cfe/cfe/trunk/include/clang/Basic/SourceManager.h (original)
+++ cfe/cfe/trunk/include/clang/Basic/SourceManager.h Wed Jul 11 11:23:03 2007
@@ -184,6 +184,12 @@
     return createFileID(createMemBufferInfoRec(Buffer), SourceLocation());
   }
   
+  /// getInstantiationLoc - Return a new SourceLocation that encodes the fact
+  /// that a token from physloc PhysLoc should actually be referenced from
+  /// InstantiationLoc.
+  SourceLocation getInstantiationLoc(SourceLocation PhysLoc,
+                                     SourceLocation InstantiationLoc);
+  
   /// createFileIDForMacroExp - Return a new FileID for a macro expansion at
   /// SourcePos, where the macro token character came from PhysicalFileID.
   ///





More information about the cfe-commits mailing list