clang 22.0.0git
StandaloneDiagnostic.h
Go to the documentation of this file.
1//===--- StandaloneDiagnostic.h - Serializable Diagnostic -------*- C++ -*-===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8//
9// A serializable diagnostic representation to retain diagnostics after their
10// SourceManager has been destroyed.
11//
12//===----------------------------------------------------------------------===//
13
14#ifndef LLVM_CLANG_FRONTEND_STANDALONEDIAGNOSTICS_H
15#define LLVM_CLANG_FRONTEND_STANDALONEDIAGNOSTICS_H
16
22#include "llvm/ADT/StringExtras.h"
23#include <cassert>
24#include <string>
25#include <vector>
26
27namespace clang {
28
29/// Represents a StoredDiagnostic in a form that can be retained until after its
30/// SourceManager has been destroyed.
31///
32/// Source locations are stored as a combination of filename and offsets into
33/// that file.
34/// To report the diagnostic, it must first be translated back into a
35/// StoredDiagnostic with a new associated SourceManager.
37 /// Represents a CharSourceRange within a StandaloneDiagnostic.
40 const LangOptions &LangOpts);
41
42 unsigned Begin = 0;
43 unsigned End = 0;
44 };
45
46 /// Represents a FixItHint within a StandaloneDiagnostic.
56
57 StandaloneDiagnostic(const LangOptions &LangOpts,
58 const StoredDiagnostic &InDiag);
59
62 unsigned ID = 0;
63 unsigned FileOffset = 0;
64 std::string Message;
65 std::string Filename;
66 std::vector<SourceOffsetRange> Ranges;
67 std::vector<StandaloneFixIt> FixIts;
68};
69
70/// Translates \c StandaloneDiag into a StoredDiagnostic, associating it with
71/// the provided FileManager and SourceManager.
72///
73/// This allows the diagnostic to be emitted using the diagnostics engine, since
74/// StandaloneDiagnostics themselfs cannot be emitted directly.
77 const StandaloneDiagnostic &StandaloneDiag,
78 llvm::StringMap<SourceLocation> &SrcLocCache);
79
80} // namespace clang
81
82#endif // STANDALONEDIAGNOSTICS
Defines the Diagnostic IDs-related interfaces.
Defines the clang::SourceLocation class and associated facilities.
Defines the SourceManager interface.
Defines various enumerations that describe declaration and type specifiers.
Represents a character-granular source range.
Level
The level of the diagnostic, after it has been through mapping.
Definition Diagnostic.h:237
Implements support for file system lookup, file system caching, and directory search management.
Definition FileManager.h:53
Annotates a diagnostic with some code that should be inserted, removed, or replaced to fix the proble...
Definition Diagnostic.h:79
Keeps track of the various options that can be enabled, which controls the dialect of C or C++ that i...
This class handles loading and caching of source files into memory.
Represents a diagnostic in a form that can be retained until its corresponding source manager is dest...
Public enums and private classes that are part of the SourceManager implementation.
CharacteristicKind
Indicates whether a file or directory holds normal user code, system code, or system code which is im...
The JSON file list parser is used to communicate input to InstallAPI.
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...
Represents a CharSourceRange within a StandaloneDiagnostic.
SourceOffsetRange(CharSourceRange Range, const SourceManager &SrcMgr, const LangOptions &LangOpts)
StandaloneFixIt(const SourceManager &SrcMgr, const LangOptions &LangOpts, const FixItHint &FixIt)
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)
std::vector< SourceOffsetRange > Ranges
DiagnosticsEngine::Level Level