瀏覽代碼

Add FullSourceLoc::getDecomposedLoc.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@66522 91177308-0d34-0410-b5e6-96231b3b80d8
Ted Kremenek 16 年之前
父節點
當前提交
321abd4583
共有 2 個文件被更改,包括 9 次插入0 次删除
  1. 5 0
      include/clang/Basic/SourceLocation.h
  2. 4 0
      lib/Basic/SourceLocation.cpp

+ 5 - 0
include/clang/Basic/SourceLocation.h

@@ -216,6 +216,11 @@ public:
   /// data for the specified FileID.
   std::pair<const char*, const char*> getBufferData() const;
   
+  /// getDecomposedLoc - Decompose the specified location into a raw FileID +
+  /// Offset pair.  The first element is the FileID, the second is the
+  /// offset from the start of the buffer of the location.
+  std::pair<FileID, unsigned> getDecomposedLoc() const;
+
   bool isInSystemHeader() const;
   
   /// Prints information about this FullSourceLoc to stderr. Useful for

+ 4 - 0
lib/Basic/SourceLocation.cpp

@@ -142,3 +142,7 @@ std::pair<const char*, const char*> FullSourceLoc::getBufferData() const {
   const llvm::MemoryBuffer *Buf = getBuffer();
   return std::make_pair(Buf->getBufferStart(), Buf->getBufferEnd());
 }
+
+std::pair<FileID, unsigned> FullSourceLoc::getDecomposedLoc() const {
+  return SrcMgr->getDecomposedLoc(*this);
+}