]> granicus.if.org Git - clang/commitdiff
some minor cleanups to SourceManager, and eliminate the
authorChris Lattner <sabre@nondot.org>
Mon, 19 Jan 2009 07:30:29 +0000 (07:30 +0000)
committerChris Lattner <sabre@nondot.org>
Mon, 19 Jan 2009 07:30:29 +0000 (07:30 +0000)
SourceManager::getBuffer(SourceLocation) method.

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

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

index 629d8ca574c4d3cc9618b6462b98aaade99e412f..c3c1a6963133cd2119bbf55edf5ee839c5ce4767 100644 (file)
@@ -286,7 +286,7 @@ public:
   /// being #included from the specified IncludePosition.  This returns 0 on
   /// error and translates NULL into standard input.
   FileID createFileID(const FileEntry *SourceFile, SourceLocation IncludePos,
-                        SrcMgr::CharacteristicKind FileCharacter) {
+                      SrcMgr::CharacteristicKind FileCharacter) {
     const SrcMgr::ContentCache *IR = getContentCache(SourceFile);
     if (IR == 0) return FileID();    // Error opening file?
     return createFileID(IR, IncludePos, FileCharacter);
@@ -294,8 +294,7 @@ public:
   
   /// createMainFileID - Create the FileID for the main source file.
   FileID createMainFileID(const FileEntry *SourceFile,
-                            SourceLocation IncludePos) {
-    
+                          SourceLocation IncludePos) {
     assert(MainFileID.isInvalid() && "MainFileID already set!");
     MainFileID = createFileID(SourceFile, IncludePos, SrcMgr::C_User);
     return MainFileID;
@@ -335,11 +334,6 @@ public:
     return getContentCache(FID)->getBuffer();
   }
   
-  const llvm::MemoryBuffer *getBuffer(SourceLocation Loc) const {
-    return getContentCacheForLoc(Loc)->getBuffer();
-  }
-  
-  
   /// getBufferData - Return a pointer to the start and end of the character
   /// data for the specified FileID.
   std::pair<const char*, const char*> getBufferData(SourceLocation Loc) const;
index dcfd547eec4b1e97a93aedd10bdaeafdd6882975..1f5804ff9cac72444b6998c1f4d93b2e400417e3 100644 (file)
@@ -111,7 +111,7 @@ const char *FullSourceLoc::getCharacterData() const {
 
 const llvm::MemoryBuffer* FullSourceLoc::getBuffer() const {
   assert(isValid());
-  return SrcMgr->getBuffer(*this);
+  return SrcMgr->getBuffer(SrcMgr->getCanonicalFileID(*this));
 }
 
 void FullSourceLoc::dump() const {
index f793c978ccbbbae4633271063d00e56a5f201e62..b053b160e1cee7ff1edb68bd1c21a5b3c4dc18fc 100644 (file)
@@ -184,7 +184,7 @@ SourceLocation SourceManager::getInstantiationLoc(SourceLocation SpellingLoc,
 /// data for the specified location.
 std::pair<const char*, const char*> 
 SourceManager::getBufferData(SourceLocation Loc) const {
-  const llvm::MemoryBuffer *Buf = getBuffer(Loc);
+  const llvm::MemoryBuffer *Buf = getBuffer(getCanonicalFileID(Loc));
   return std::make_pair(Buf->getBufferStart(), Buf->getBufferEnd());
 }