X-Git-Url: http://demsky.eecs.uci.edu/git/?a=blobdiff_plain;f=include%2Fllvm%2FDebugger%2FSourceFile.h;h=249435af8b179945c50915f41f63244491071b36;hb=f72fb679eff7de84e3e18b75d63a18cb3510bcdd;hp=042350ab1fdc087f06c8947ba54600a0a5b8e7b7;hpb=3343be3f2efc0a4907cf5ed99d2218a10ef46345;p=oota-llvm.git diff --git a/include/llvm/Debugger/SourceFile.h b/include/llvm/Debugger/SourceFile.h index 042350ab1fd..249435af8b1 100644 --- a/include/llvm/Debugger/SourceFile.h +++ b/include/llvm/Debugger/SourceFile.h @@ -1,10 +1,10 @@ //===- SourceFile.h - Class to represent a source code file -----*- C++ -*-===// -// +// // The LLVM Compiler Infrastructure // -// This file was developed by the LLVM research group and is distributed under -// the University of Illinois Open Source License. See LICENSE.TXT for details. -// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// //===----------------------------------------------------------------------===// // // This file defines the SourceFile class which is used to represent a single @@ -17,11 +17,12 @@ #define LLVM_DEBUGGER_SOURCEFILE_H #include "llvm/System/Path.h" -#include "llvm/System/MappedFile.h" +#include "llvm/ADT/OwningPtr.h" #include namespace llvm { class GlobalVariable; + class MemoryBuffer; class SourceFile { /// Filename - This is the full path of the file that is loaded. @@ -35,7 +36,7 @@ namespace llvm { const GlobalVariable *Descriptor; /// This is the memory mapping for the file so we can gain access to it. - sys::MappedFile File; + OwningPtr File; /// LineOffset - This vector contains a mapping from source line numbers to /// their offsets in the file. This data is computed lazily, the first time @@ -49,22 +50,18 @@ namespace llvm { /// NOT throw an exception if the file is not found, if there is an error /// reading it, or if the user cancels the operation. Instead, it will just /// be an empty source file. - SourceFile(const std::string &fn, const GlobalVariable *Desc) - : Filename(fn), Descriptor(Desc), File(Filename) { - readFile(); - } - ~SourceFile() { - File.unmap(); - } + SourceFile(const std::string &fn, const GlobalVariable *Desc); + + ~SourceFile(); /// getDescriptor - Return the debugging decriptor for this source file. /// const GlobalVariable *getDescriptor() const { return Descriptor; } - + /// getFilename - Return the fully resolved path that this file was loaded /// from. const std::string &getFilename() const { return Filename.toString(); } - + /// getSourceLine - Given a line number, return the start and end of the /// line in the file. If the line number is invalid, or if the file could /// not be loaded, null pointers are returned for the start and end of the @@ -72,19 +69,15 @@ namespace llvm { /// any newlines from the end of the line, to ease formatting of the text. void getSourceLine(unsigned LineNo, const char *&LineStart, const char *&LineEnd) const; - + /// getNumLines - Return the number of lines the source file contains. /// unsigned getNumLines() const { if (LineOffset.empty()) calculateLineOffsets(); - return LineOffset.size(); + return static_cast(LineOffset.size()); } private: - /// readFile - Load Filename into memory - /// - void readFile(); - /// calculateLineOffsets - Compute the LineOffset vector for the current /// file. void calculateLineOffsets() const;