LLVM API Documentation

llvm::SourceMgr Class Reference

#include <SourceMgr.h>

Collaboration diagram for llvm::SourceMgr:
[legend]

List of all members.

Public Member Functions

 SourceMgr ()
 ~SourceMgr ()
void setIncludeDirs (const std::vector< std::string > &Dirs)
const SrcBuffer & getBufferInfo (unsigned i) const
const MemoryBuffer * getMemoryBuffer (unsigned i) const
SMLoc getParentIncludeLoc (unsigned i) const
unsigned AddNewSourceBuffer (MemoryBuffer *F, SMLoc IncludeLoc)
unsigned AddIncludeFile (const std::string &Filename, SMLoc IncludeLoc)
int FindBufferContainingLoc (SMLoc Loc) const
unsigned FindLineNumber (SMLoc Loc, int BufferID=-1) const
void PrintMessage (SMLoc Loc, const std::string &Msg, const char *Type) const
SMDiagnostic GetMessage (SMLoc Loc, const std::string &Msg, const char *Type) const

Classes

struct  SrcBuffer


Detailed Description

SourceMgr - This owns the files read by a parser, handles include stacks, and handles diagnostic wrangling.

Definition at line 51 of file SourceMgr.h.


Constructor & Destructor Documentation

llvm::SourceMgr::SourceMgr (  )  [inline]

Definition at line 75 of file SourceMgr.h.

SourceMgr::~SourceMgr (  ) 

Definition at line 34 of file SourceMgr.cpp.

References getCache().


Member Function Documentation

void llvm::SourceMgr::setIncludeDirs ( const std::vector< std::string > &  Dirs  )  [inline]

Definition at line 78 of file SourceMgr.h.

const SrcBuffer& llvm::SourceMgr::getBufferInfo ( unsigned  i  )  const [inline]

Definition at line 82 of file SourceMgr.h.

Referenced by FindLineNumber(), GetMessage(), and PrintMessage().

const MemoryBuffer* llvm::SourceMgr::getMemoryBuffer ( unsigned  i  )  const [inline]

Definition at line 87 of file SourceMgr.h.

SMLoc llvm::SourceMgr::getParentIncludeLoc ( unsigned  i  )  const [inline]

Definition at line 92 of file SourceMgr.h.

unsigned llvm::SourceMgr::AddNewSourceBuffer ( MemoryBuffer *  F,
SMLoc  IncludeLoc 
) [inline]

Definition at line 97 of file SourceMgr.h.

Referenced by AddIncludeFile(), llvm::ParseAssemblyFile(), and llvm::ParseAssemblyString().

unsigned SourceMgr::AddIncludeFile ( const std::string &  Filename,
SMLoc  IncludeLoc 
)

AddIncludeFile - Search for a file with the specified name in the current directory or in one of the IncludeDirs. If no file is found, this returns ~0, otherwise it returns the buffer ID of the stacked file.

AddIncludeFile - Search for a file with the specified name in the current directory or in one of the IncludeDirs. If no file is found, this returns ~0, otherwise it returns the buffer ID of the stacked file.

Definition at line 48 of file SourceMgr.cpp.

References AddNewSourceBuffer(), and llvm::MemoryBuffer::getFile().

int SourceMgr::FindBufferContainingLoc ( SMLoc  Loc  )  const

FindBufferContainingLoc - Return the ID of the buffer containing the specified location, returning -1 if not found.

FindBufferContainingLoc - Return the ID of the buffer containing the specified location, returning -1 if not found.

Definition at line 67 of file SourceMgr.cpp.

References llvm::SMLoc::getPointer().

Referenced by FindLineNumber(), GetMessage(), and PrintMessage().

unsigned SourceMgr::FindLineNumber ( SMLoc  Loc,
int  BufferID = -1 
) const

FindLineNumber - Find the line number for the specified location in the specified file. This is not a fast method.

FindLineNumber - Find the line number for the specified location in the specified file. This is not a fast method.

Definition at line 79 of file SourceMgr.cpp.

References FindBufferContainingLoc(), getBufferInfo(), llvm::MemoryBuffer::getBufferStart(), getCache(), llvm::SMLoc::getFromPointer(), and llvm::SMLoc::getPointer().

Referenced by GetMessage().

void SourceMgr::PrintMessage ( SMLoc  Loc,
const std::string &  Msg,
const char *  Type 
) const

PrintMessage - Emit a message about the specified location with the specified string.

Parameters:
Type - If non-null, the kind of message (e.g., "error") which is prefixed to the message.

Definition at line 173 of file SourceMgr.cpp.

References llvm::errs(), FindBufferContainingLoc(), getBufferInfo(), GetMessage(), and llvm::SMDiagnostic::Print().

SMDiagnostic SourceMgr::GetMessage ( SMLoc  Loc,
const std::string &  Msg,
const char *  Type 
) const

GetMessage - Return an SMDiagnostic at the specified location with the specified string.

Parameters:
Type - If non-null, the kind of message (e.g., "error") which is prefixed to the message.
GetMessage - Return an SMDiagnostic at the specified location with the specified string.

Parameters:
Type - If non-null, the kind of message (e.g., "error") which is prefixed to the message.

Definition at line 138 of file SourceMgr.cpp.

References FindBufferContainingLoc(), FindLineNumber(), llvm::MemoryBuffer::getBufferEnd(), llvm::MemoryBuffer::getBufferIdentifier(), getBufferInfo(), llvm::MemoryBuffer::getBufferStart(), and llvm::SMLoc::getPointer().

Referenced by llvm::LLLexer::Error(), and PrintMessage().


The documentation for this class was generated from the following files: