some minor cleanups to SourceManager, and eliminate the
SourceManager::getBuffer(SourceLocation) method.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@62494 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/include/clang/Basic/SourceManager.h b/include/clang/Basic/SourceManager.h
index 629d8ca..c3c1a69 100644
--- a/include/clang/Basic/SourceManager.h
+++ b/include/clang/Basic/SourceManager.h
@@ -286,7 +286,7 @@
/// 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 @@
/// 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 @@
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;
diff --git a/lib/Basic/SourceLocation.cpp b/lib/Basic/SourceLocation.cpp
index dcfd547..1f5804ff 100644
--- a/lib/Basic/SourceLocation.cpp
+++ b/lib/Basic/SourceLocation.cpp
@@ -111,7 +111,7 @@
const llvm::MemoryBuffer* FullSourceLoc::getBuffer() const {
assert(isValid());
- return SrcMgr->getBuffer(*this);
+ return SrcMgr->getBuffer(SrcMgr->getCanonicalFileID(*this));
}
void FullSourceLoc::dump() const {
diff --git a/lib/Basic/SourceManager.cpp b/lib/Basic/SourceManager.cpp
index f793c97..b053b16 100644
--- a/lib/Basic/SourceManager.cpp
+++ b/lib/Basic/SourceManager.cpp
@@ -184,7 +184,7 @@
/// 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());
}