#include "llvm/Support/SourceMgr.h"
#include "llvm/ADT/ArrayRef.h"
#include "llvm/ADT/STLExtras.h"
#include "llvm/ADT/SmallString.h"
#include "llvm/ADT/SmallVector.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/ADT/Twine.h"
#include "llvm/Support/ErrorOr.h"
#include "llvm/Support/Locale.h"
#include "llvm/Support/MemoryBuffer.h"
#include "llvm/Support/Path.h"
#include "llvm/Support/SMLoc.h"
#include "llvm/Support/WithColor.h"
#include "llvm/Support/raw_ostream.h"
#include <algorithm>
#include <cassert>
#include <cstddef>
#include <limits>
#include <memory>
#include <string>
#include <utility>
usingnamespacellvm;
static const size_t TabStop = …;
unsigned SourceMgr::AddIncludeFile(const std::string &Filename,
SMLoc IncludeLoc,
std::string &IncludedFile) { … }
ErrorOr<std::unique_ptr<MemoryBuffer>>
SourceMgr::OpenIncludeFile(const std::string &Filename,
std::string &IncludedFile) { … }
unsigned SourceMgr::FindBufferContainingLoc(SMLoc Loc) const { … }
template <typename T>
static std::vector<T> &GetOrCreateOffsetCache(void *&OffsetCache,
MemoryBuffer *Buffer) { … }
template <typename T>
unsigned SourceMgr::SrcBuffer::getLineNumberSpecialized(const char *Ptr) const { … }
unsigned SourceMgr::SrcBuffer::getLineNumber(const char *Ptr) const { … }
template <typename T>
const char *SourceMgr::SrcBuffer::getPointerForLineNumberSpecialized(
unsigned LineNo) const { … }
const char *
SourceMgr::SrcBuffer::getPointerForLineNumber(unsigned LineNo) const { … }
SourceMgr::SrcBuffer::SrcBuffer(SourceMgr::SrcBuffer &&Other)
: … { … }
SourceMgr::SrcBuffer::~SrcBuffer() { … }
std::pair<unsigned, unsigned>
SourceMgr::getLineAndColumn(SMLoc Loc, unsigned BufferID) const { … }
std::string SourceMgr::getFormattedLocationNoOffset(SMLoc Loc,
bool IncludePath) const { … }
SMLoc SourceMgr::FindLocForLineAndColumn(unsigned BufferID, unsigned LineNo,
unsigned ColNo) { … }
void SourceMgr::PrintIncludeStack(SMLoc IncludeLoc, raw_ostream &OS) const { … }
SMDiagnostic SourceMgr::GetMessage(SMLoc Loc, SourceMgr::DiagKind Kind,
const Twine &Msg, ArrayRef<SMRange> Ranges,
ArrayRef<SMFixIt> FixIts) const { … }
void SourceMgr::PrintMessage(raw_ostream &OS, const SMDiagnostic &Diagnostic,
bool ShowColors) const { … }
void SourceMgr::PrintMessage(raw_ostream &OS, SMLoc Loc,
SourceMgr::DiagKind Kind, const Twine &Msg,
ArrayRef<SMRange> Ranges, ArrayRef<SMFixIt> FixIts,
bool ShowColors) const { … }
void SourceMgr::PrintMessage(SMLoc Loc, SourceMgr::DiagKind Kind,
const Twine &Msg, ArrayRef<SMRange> Ranges,
ArrayRef<SMFixIt> FixIts, bool ShowColors) const { … }
SMFixIt::SMFixIt(SMRange R, const Twine &Replacement)
: … { … }
SMDiagnostic::SMDiagnostic(const SourceMgr &sm, SMLoc L, StringRef FN, int Line,
int Col, SourceMgr::DiagKind Kind, StringRef Msg,
StringRef LineStr,
ArrayRef<std::pair<unsigned, unsigned>> Ranges,
ArrayRef<SMFixIt> Hints)
: … { … }
static void buildFixItLine(std::string &CaretLine, std::string &FixItLine,
ArrayRef<SMFixIt> FixIts,
ArrayRef<char> SourceLine) { … }
static void printSourceLine(raw_ostream &S, StringRef LineContents) { … }
static bool isNonASCII(char c) { … }
void SMDiagnostic::print(const char *ProgName, raw_ostream &OS, bool ShowColors,
bool ShowKindLabel, bool ShowLocation) const { … }