[llvm-commits] [llvm] r49025 - in /llvm/trunk: include/llvm/System/MappedFile.h lib/Debugger/SourceFile.cpp lib/Support/MemoryBuffer.cpp
Chris Lattner
sabre at nondot.org
Mon Mar 31 20:40:54 PDT 2008
Author: lattner
Date: Mon Mar 31 22:40:53 2008
New Revision: 49025
URL: http://llvm.org/viewvc/llvm-project?rev=49025&view=rev
Log:
Remove the MappedFile::charBase member, rename base -> getBase() and
make getBase() return a const-correct pointer.
Modified:
llvm/trunk/include/llvm/System/MappedFile.h
llvm/trunk/lib/Debugger/SourceFile.cpp
llvm/trunk/lib/Support/MemoryBuffer.cpp
Modified: llvm/trunk/include/llvm/System/MappedFile.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/System/MappedFile.h?rev=49025&r1=49024&r2=49025&view=diff
==============================================================================
--- llvm/trunk/include/llvm/System/MappedFile.h (original)
+++ llvm/trunk/include/llvm/System/MappedFile.h Mon Mar 31 22:40:53 2008
@@ -25,7 +25,7 @@
/// This class provides an abstraction for a memory mapped file in the
/// operating system's filesystem. It provides platform independent operations
- /// for mapping a file into memory for both read access.
+ /// for mapping a file into memory for read access.
class MappedFile {
sys::PathWithStatus Path; ///< Path to the file.
void *BasePtr; ///< Pointer to the base memory address
@@ -44,19 +44,9 @@
/// This function determines if the file is currently mapped or not.
bool isMapped() const { return BasePtr != 0; }
- /// This function returns a void* pointer to the base address of the file
+ /// getBase - Returns a const void* pointer to the base address of the file
/// mapping. This is the memory address of the first byte in the file.
- /// Note that although a non-const pointer is returned, the memory might
- /// not actually be writable, depending on the MappingOptions used when
- /// the MappedFile was opened.
- void* base() const { return BasePtr; }
-
- /// This function returns a char* pointer to the base address of the file
- /// mapping. This is the memory address of the first byte in the file.
- /// Note that although a non-const pointer is returned, the memory might
- /// not actually be writable, depending on the MappingOptions used when
- /// the MappedFile was opened.
- char* charBase() const { return reinterpret_cast<char*>(BasePtr); }
+ const void *getBase() const { return BasePtr; }
/// This function returns a reference to the sys::Path object kept by the
/// MappedFile object. This contains the path to the file that is or
Modified: llvm/trunk/lib/Debugger/SourceFile.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Debugger/SourceFile.cpp?rev=49025&r1=49024&r2=49025&view=diff
==============================================================================
--- llvm/trunk/lib/Debugger/SourceFile.cpp (original)
+++ llvm/trunk/lib/Debugger/SourceFile.cpp Mon Mar 31 22:40:53 2008
@@ -28,7 +28,7 @@
///
void SourceFile::calculateLineOffsets() const {
assert(LineOffset.empty() && "Line offsets already computed!");
- const char *BufPtr = File.charBase();
+ const char *BufPtr = (const char *)File.getBase();
const char *FileStart = BufPtr;
const char *FileEnd = FileStart + File.size();
do {
@@ -61,12 +61,12 @@
if (LineNo >= LineOffset.size()) return;
// Otherwise, they are asking for a valid line, which we can fulfill.
- LineStart = File.charBase()+LineOffset[LineNo];
+ LineStart = (const char *)File.getBase()+LineOffset[LineNo];
if (LineNo+1 < LineOffset.size())
- LineEnd = File.charBase()+LineOffset[LineNo+1];
+ LineEnd = (const char *)File.getBase()+LineOffset[LineNo+1];
else
- LineEnd = File.charBase() + File.size();
+ LineEnd = (const char *)File.getBase() + File.size();
// If the line ended with a newline, strip it off.
while (LineEnd != LineStart && (LineEnd[-1] == '\n' || LineEnd[-1] == '\r'))
Modified: llvm/trunk/lib/Support/MemoryBuffer.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/MemoryBuffer.cpp?rev=49025&r1=49024&r2=49025&view=diff
==============================================================================
--- llvm/trunk/lib/Support/MemoryBuffer.cpp (original)
+++ llvm/trunk/lib/Support/MemoryBuffer.cpp Mon Mar 31 22:40:53 2008
@@ -173,11 +173,12 @@
// If this file is not an exact multiple of the system page size (common
// case), then the OS has zero terminated the buffer for us.
- if ((Size & (PageSize-1))) {
- init(File.charBase(), File.charBase()+Size);
+ const char *FileBase = static_cast<const char*>(File.getBase());
+ if ((Size & (PageSize-1)) != 0) {
+ init(FileBase, FileBase+Size);
} else {
// Otherwise, we allocate a new memory buffer and copy the data over
- initCopyOf(File.charBase(), File.charBase()+Size);
+ initCopyOf(FileBase, FileBase+Size);
// No need to keep the file mapped any longer.
File.unmap();
More information about the llvm-commits
mailing list