#include "clang/Frontend/DiagnosticRenderer.h"
#include "clang/Basic/Diagnostic.h"
#include "clang/Basic/DiagnosticOptions.h"
#include "clang/Basic/LLVM.h"
#include "clang/Basic/SourceLocation.h"
#include "clang/Basic/SourceManager.h"
#include "clang/Edit/Commit.h"
#include "clang/Edit/EditedSource.h"
#include "clang/Edit/EditsReceiver.h"
#include "clang/Lex/Lexer.h"
#include "llvm/ADT/ArrayRef.h"
#include "llvm/ADT/DenseMap.h"
#include "llvm/ADT/SmallString.h"
#include "llvm/ADT/SmallVector.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/Support/raw_ostream.h"
#include <algorithm>
#include <cassert>
#include <iterator>
#include <utility>
usingnamespaceclang;
DiagnosticRenderer::DiagnosticRenderer(const LangOptions &LangOpts,
DiagnosticOptions *DiagOpts)
: … { … }
DiagnosticRenderer::~DiagnosticRenderer() = default;
namespace {
class FixitReceiver : public edit::EditsReceiver { … };
}
static void mergeFixits(ArrayRef<FixItHint> FixItHints,
const SourceManager &SM, const LangOptions &LangOpts,
SmallVectorImpl<FixItHint> &MergedFixits) { … }
void DiagnosticRenderer::emitDiagnostic(FullSourceLoc Loc,
DiagnosticsEngine::Level Level,
StringRef Message,
ArrayRef<CharSourceRange> Ranges,
ArrayRef<FixItHint> FixItHints,
DiagOrStoredDiag D) { … }
void DiagnosticRenderer::emitStoredDiagnostic(StoredDiagnostic &Diag) { … }
void DiagnosticRenderer::emitBasicNote(StringRef Message) { … }
void DiagnosticRenderer::emitIncludeStack(FullSourceLoc Loc, PresumedLoc PLoc,
DiagnosticsEngine::Level Level) { … }
void DiagnosticRenderer::emitIncludeStackRecursively(FullSourceLoc Loc) { … }
void DiagnosticRenderer::emitImportStack(FullSourceLoc Loc) { … }
void DiagnosticRenderer::emitImportStackRecursively(FullSourceLoc Loc,
StringRef ModuleName) { … }
void DiagnosticRenderer::emitModuleBuildStack(const SourceManager &SM) { … }
static SourceLocation
retrieveMacroLocation(SourceLocation Loc, FileID MacroFileID,
FileID CaretFileID,
const SmallVectorImpl<FileID> &CommonArgExpansions,
bool IsBegin, const SourceManager *SM,
bool &IsTokenRange) { … }
static void getMacroArgExpansionFileIDs(SourceLocation Loc,
SmallVectorImpl<FileID> &IDs,
bool IsBegin, const SourceManager *SM) { … }
static void computeCommonMacroArgExpansionFileIDs(
SourceLocation Begin, SourceLocation End, const SourceManager *SM,
SmallVectorImpl<FileID> &CommonArgExpansions) { … }
static void
mapDiagnosticRanges(FullSourceLoc CaretLoc, ArrayRef<CharSourceRange> Ranges,
SmallVectorImpl<CharSourceRange> &SpellingRanges) { … }
void DiagnosticRenderer::emitCaret(FullSourceLoc Loc,
DiagnosticsEngine::Level Level,
ArrayRef<CharSourceRange> Ranges,
ArrayRef<FixItHint> Hints) { … }
void DiagnosticRenderer::emitSingleMacroExpansion(
FullSourceLoc Loc, DiagnosticsEngine::Level Level,
ArrayRef<CharSourceRange> Ranges) { … }
static bool checkLocForMacroArgExpansion(SourceLocation Loc,
const SourceManager &SM,
SourceLocation ArgumentLoc) { … }
static bool checkRangeForMacroArgExpansion(CharSourceRange Range,
const SourceManager &SM,
SourceLocation ArgumentLoc) { … }
static bool checkRangesForMacroArgExpansion(FullSourceLoc Loc,
ArrayRef<CharSourceRange> Ranges) { … }
void DiagnosticRenderer::emitMacroExpansions(FullSourceLoc Loc,
DiagnosticsEngine::Level Level,
ArrayRef<CharSourceRange> Ranges,
ArrayRef<FixItHint> Hints) { … }
DiagnosticNoteRenderer::~DiagnosticNoteRenderer() = default;
void DiagnosticNoteRenderer::emitIncludeLocation(FullSourceLoc Loc,
PresumedLoc PLoc) { … }
void DiagnosticNoteRenderer::emitImportLocation(FullSourceLoc Loc,
PresumedLoc PLoc,
StringRef ModuleName) { … }
void DiagnosticNoteRenderer::emitBuildingModuleLocation(FullSourceLoc Loc,
PresumedLoc PLoc,
StringRef ModuleName) { … }