clang: lib/Frontend/StandaloneDiagnostic.cpp Source File (original) (raw)

1

2

3

4

5

6

7

8

11

13

18 Begin = SrcMgr.getFileOffset(FileRange.getBegin());

19 End = SrcMgr.getFileOffset(FileRange.getEnd());

20}

21

29

32 : Level(InDiag.getLevel()), ID(InDiag.getID()),

33 Message(InDiag.getMessage()) {

35

36

38 return;

39

45 assert(Filename.empty() && "diagnostic with location has no source file?");

46

50

54}

55

59 llvm::StringMap &SrcLocCache) {

60 const auto FileRef = FileMgr.getOptionalFileRef(StandaloneDiag.Filename);

61 if (!FileRef)

64

65

67 auto It = SrcLocCache.find(StandaloneDiag.Filename);

68 if (It != SrcLocCache.end()) {

69 FileLoc = It->getValue();

70 }

71

72

75 SrcMgr.getOrCreateFileID(*FileRef, StandaloneDiag.FileKind);

76 FileLoc = SrcMgr.getLocForStartOfFile(FileID);

77

81

82 SrcLocCache[StandaloneDiag.Filename] = FileLoc;

83 }

84

87

88 auto ConvertOffsetRange =

93 false);

94 };

95

97 TranslatedRanges.reserve(StandaloneDiag.Ranges.size());

98 transform(StandaloneDiag.Ranges, std::back_inserter(TranslatedRanges),

99 ConvertOffsetRange);

100

102 TranslatedFixIts.reserve(StandaloneDiag.FixIts.size());

103 for (const auto &FixIt : StandaloneDiag.FixIts) {

105 TranslatedFixIt.CodeToInsert = FixIt.CodeToInsert;

106 TranslatedFixIt.RemoveRange = ConvertOffsetRange(FixIt.RemoveRange);

107 TranslatedFixIt.InsertFromRange = ConvertOffsetRange(FixIt.InsertFromRange);

109 TranslatedFixIts.push_back(std::move(TranslatedFixIt));

110 }

111

113 StandaloneDiag.Message, Loc, TranslatedRanges,

114 TranslatedFixIts);

115}

116

117}

Represents a character-granular source range.

An opaque identifier used by SourceManager which refers to a source file (MemoryBuffer) along with it...

Implements support for file system lookup, file system caching, and directory search management.

Annotates a diagnostic with some code that should be inserted, removed, or replaced to fix the proble...

bool BeforePreviousInsertions

CharSourceRange RemoveRange

Code that should be replaced to correct the error.

CharSourceRange InsertFromRange

Code in the specific range that should be inserted in the insertion location.

std::string CodeToInsert

The actual code to insert at the insertion location, as a string.

A SourceLocation and its associated SourceManager.

const SourceManager & getManager() const

Keeps track of the various options that can be enabled, which controls the dialect of C or C++ that i...

static CharSourceRange makeFileCharRange(CharSourceRange Range, const SourceManager &SM, const LangOptions &LangOpts)

Accepts a range and returns a character range with file locations.

Encodes a location in the source.

SourceLocation getLocWithOffset(IntTy Offset) const

Return a source location with the specified offset from this SourceLocation.

This class handles loading and caching of source files into memory.

A trivial tuple used to represent a source range.

Represents a diagnostic in a form that can be retained until its corresponding source manager is dest...

ArrayRef< FixItHint > getFixIts() const

ArrayRef< CharSourceRange > getRanges() const

const FullSourceLoc & getLocation() const

Public enums and private classes that are part of the SourceManager implementation.

The JSON file list parser is used to communicate input to InstallAPI.

for(const auto &A :T->param_types())

StoredDiagnostic translateStandaloneDiag(FileManager &FileMgr, SourceManager &SrcMgr, const StandaloneDiagnostic &StandaloneDiag, llvm::StringMap< SourceLocation > &SrcLocCache)

Translates StandaloneDiag into a StoredDiagnostic, associating it with the provided FileManager and S...

Definition StandaloneDiagnostic.cpp:57

Represents a CharSourceRange within a StandaloneDiagnostic.

SourceOffsetRange(CharSourceRange Range, const SourceManager &SrcMgr, const LangOptions &LangOpts)

Definition StandaloneDiagnostic.cpp:14

bool BeforePreviousInsertions

SourceOffsetRange RemoveRange

StandaloneFixIt(const SourceManager &SrcMgr, const LangOptions &LangOpts, const FixItHint &FixIt)

Definition StandaloneDiagnostic.cpp:22

SourceOffsetRange InsertFromRange

Represents a StoredDiagnostic in a form that can be retained until after its SourceManager has been d...

SrcMgr::CharacteristicKind FileKind

std::vector< StandaloneFixIt > FixIts

StandaloneDiagnostic(const LangOptions &LangOpts, const StoredDiagnostic &InDiag)

Definition StandaloneDiagnostic.cpp:30

std::vector< SourceOffsetRange > Ranges

DiagnosticsEngine::Level Level