15 #ifndef LLVM_SUPPORT_SOURCEMGR_H 16 #define LLVM_SUPPORT_SOURCEMGR_H 58 std::unique_ptr<MemoryBuffer> Buffer;
65 std::vector<uint16_t> *,
66 std::vector<uint32_t> *,
67 std::vector<uint64_t> *>;
75 mutable VariableSizeOffsets OffsetCache;
82 unsigned getLineNumber(
const char *Ptr)
const;
87 SrcBuffer() =
default;
88 SrcBuffer(SrcBuffer &&);
89 SrcBuffer(
const SrcBuffer &) =
delete;
90 SrcBuffer &
operator=(
const SrcBuffer &) =
delete;
95 std::vector<SrcBuffer> Buffers;
98 std::vector<std::string> IncludeDirectories;
101 void *DiagContext =
nullptr;
103 bool isValidBufferID(
unsigned i)
const {
return i && i <= Buffers.size(); }
114 IncludeDirectories = Dirs;
128 assert(isValidBufferID(i));
129 return Buffers[i - 1];
133 assert(isValidBufferID(i));
134 return Buffers[i - 1].Buffer.get();
138 return Buffers.size();
147 assert(isValidBufferID(i));
148 return Buffers[i - 1].IncludeLoc;
156 NB.Buffer = std::move(F);
157 NB.IncludeLoc = IncludeLoc;
158 Buffers.push_back(std::move(NB));
159 return Buffers.size();
169 std::string &IncludedFile);
185 unsigned BufferID = 0)
const;
195 bool ShowColors =
true)
const;
201 bool ShowColors =
true)
const;
208 bool ShowColors =
true)
const;
237 : Range(Loc, Loc), Text(Insertion.str()) {
243 : Range(R), Text(Replacement.str()) {
255 return Text < Other.Text;
264 std::string Filename;
268 std::string Message, LineContents;
269 std::vector<std::pair<unsigned, unsigned>> Ranges;
277 : Filename(filename), LineNo(-1), ColumnNo(-1), Kind(Knd), Message(Msg) {}
283 ArrayRef<std::pair<unsigned,unsigned>> Ranges,
305 bool ShowKindLabel =
true)
const;
310 #endif // LLVM_SUPPORT_SOURCEMGR_H Represents a range in source code.
unsigned FindBufferContainingLoc(SMLoc Loc) const
Return the ID of the buffer containing the specified location.
This class represents lattice values for constants.
DiagHandlerTy getDiagHandler() const
SMFixIt(SMLoc Loc, const Twine &Insertion)
unsigned getNumBuffers() const
void push_back(const T &Elt)
void PrintIncludeStack(SMLoc IncludeLoc, raw_ostream &OS) const
Prints the names of included files and the line of the file they were included from.
ArrayRef< SMFixIt > getFixIts() const
std::pair< unsigned, unsigned > getLineAndColumn(SMLoc Loc, unsigned BufferID=0) const
Find the line and column number for the specified location in the specified file. ...
void addFixIt(const SMFixIt &Hint)
void PrintMessage(raw_ostream &OS, SMLoc Loc, DiagKind Kind, const Twine &Msg, ArrayRef< SMRange > Ranges=None, ArrayRef< SMFixIt > FixIts=None, bool ShowColors=true) const
Emit a message about the specified location with the specified string.
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
const MemoryBuffer * getMemoryBuffer(unsigned i) const
StringRef getLineContents() const
unsigned AddNewSourceBuffer(std::unique_ptr< MemoryBuffer > F, SMLoc IncludeLoc)
Add a new source buffer to this source manager.
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory)...
StringRef getText() const
unsigned getMainFileID() const
const char * getPointer() const
void setDiagHandler(DiagHandlerTy DH, void *Ctx=nullptr)
Specify a diagnostic handler to be invoked every time PrintMessage is called.
static void print(raw_ostream &Out, object::Archive::Kind Kind, T Val)
This owns the files read by a parser, handles include stacks, and handles diagnostic wrangling...
Represents a single fixit, a replacement of one range of text with another.
void(*)(const SMDiagnostic &, void *Context) DiagHandlerTy
Clients that want to handle their own diagnostics in a custom way can register a function pointer+con...
SMDiagnostic GetMessage(SMLoc Loc, DiagKind Kind, const Twine &Msg, ArrayRef< SMRange > Ranges=None, ArrayRef< SMFixIt > FixIts=None) const
Return an SMDiagnostic at the specified location with the specified string.
const SrcBuffer & getBufferInfo(unsigned i) const
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small...
StringRef getMessage() const
ArrayRef< std::pair< unsigned, unsigned > > getRanges() const
This interface provides simple read-only access to a block of memory, and provides simple methods for...
StringRef getFilename() const
SourceMgr::DiagKind getKind() const
unsigned FindLineNumber(SMLoc Loc, unsigned BufferID=0) const
Find the line number for the specified location in the specified file.
bool operator<(const SMFixIt &Other) const
unsigned AddIncludeFile(const std::string &Filename, SMLoc IncludeLoc, std::string &IncludedFile)
Search for a file with the specified name in the current directory or in one of the IncludeDirs...
SMLoc getParentIncludeLoc(unsigned i) const
StringRef filename(StringRef path, Style style=Style::native)
Get filename.
void * getDiagContext() const
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
SourceMgr & operator=(const SourceMgr &)=delete
This class implements an extremely fast bulk output stream that can only output to a stream...
void setIncludeDirs(const std::vector< std::string > &Dirs)
SMDiagnostic(StringRef filename, SourceMgr::DiagKind Knd, StringRef Msg)
StringRef - Represent a constant reference to a string, i.e.
Represents a location in source code.
SMFixIt(SMRange R, const Twine &Replacement)
const SourceMgr * getSourceMgr() const
A discriminated union of two or more pointer types, with the discriminator in the low bit of the poin...
Instances of this class encapsulate one diagnostic report, allowing printing to a raw_ostream as a ca...