14#ifndef LLVM_CLANG_BASIC_DIAGNOSTICIDS_H
15#define LLVM_CLANG_BASIC_DIAGNOSTICIDS_H
19#include "llvm/ADT/IntrusiveRefCntPtr.h"
20#include "llvm/ADT/StringRef.h"
21#include "llvm/Support/ErrorHandling.h"
105#include "clang/Basic/DiagnosticCommonInterface.inc"
110 unsigned Severity : 3;
111 LLVM_PREFERRED_TYPE(
bool)
113 LLVM_PREFERRED_TYPE(
bool)
114 unsigned IsPragma : 1;
115 LLVM_PREFERRED_TYPE(
bool)
116 unsigned HasNoWarningAsError : 1;
117 LLVM_PREFERRED_TYPE(
bool)
118 unsigned HasNoErrorAsFatal : 1;
119 LLVM_PREFERRED_TYPE(
bool)
120 unsigned WasUpgradedFromWarning : 1;
128 Result.IsPragma = IsPragma;
129 Result.HasNoWarningAsError = 0;
130 Result.HasNoErrorAsFatal = 0;
131 Result.WasUpgradedFromWarning = 0;
160 return (IsUser << 7) | (IsPragma << 6) | (HasNoWarningAsError << 5) |
161 (HasNoErrorAsFatal << 4) | (WasUpgradedFromWarning << 3) | Severity;
166 Result.IsUser = (Bits >> 7) & 1;
167 Result.IsPragma = (Bits >> 6) & 1;
168 Result.HasNoWarningAsError = (Bits >> 5) & 1;
169 Result.HasNoErrorAsFatal = (Bits >> 4) & 1;
170 Result.WasUpgradedFromWarning = (Bits >> 3) & 1;
171 Result.Severity = Bits & 0x7;
206 unsigned DefaultSeverity : 3;
207 LLVM_PREFERRED_TYPE(
Class)
208 unsigned DiagClass : 3;
209 LLVM_PREFERRED_TYPE(
bool)
210 unsigned ShowInSystemHeader : 1;
211 LLVM_PREFERRED_TYPE(
bool)
212 unsigned ShowInSystemMacro : 1;
213 LLVM_PREFERRED_TYPE(
bool)
214 unsigned HasGroup : 1;
216 std::string Description;
218 auto get_as_tuple()
const {
219 return std::tuple(DefaultSeverity, DiagClass, ShowInSystemHeader,
220 ShowInSystemMacro, HasGroup, Group,
221 std::string_view{Description});
227 bool ShowInSystemHeader =
false,
228 bool ShowInSystemMacro =
false,
229 std::optional<diag::Group> Group = std::nullopt)
230 : DefaultSeverity(static_cast<
unsigned>(DefaultSeverity)),
231 DiagClass(
Class), ShowInSystemHeader(ShowInSystemHeader),
232 ShowInSystemMacro(ShowInSystemMacro), HasGroup(Group !=
std::nullopt),
233 Group(Group.value_or(
diag::Group{})),
234 Description(
std::move(Description)) {}
252 return lhs.get_as_tuple() == rhs.get_as_tuple();
257 return lhs.get_as_tuple() < rhs.get_as_tuple();
264 LLVM_PREFERRED_TYPE(
bool)
270 std::unique_ptr<
diag::CustomDiagInfo> CustomDiagInfo;
272 auto GIs = std::make_unique<GroupInfo[]>(
275 GIs[i] = {{},
false};
285 return llvm::makeIntrusiveRefCnt<DiagnosticIDs>();
326 llvm_unreachable(
"Fully covered switch above!");
359 bool isNote(
unsigned DiagID)
const;
482 std::vector<diag::kind> &Diags);
491 unsigned CompatDiagId);
519 Class getDiagClass(
unsigned DiagID)
const;
523 bool isUnrecoverable(
unsigned DiagID)
const;
Forward-declares and imports various common LLVM datatypes that clang wants to use unqualified.
static DiagnosticBuilder Diag(DiagnosticsEngine *Diags, const LangOptions &Features, FullSourceLoc TokLoc, const char *TokBegin, const char *TokRangeBegin, const char *TokRangeEnd, unsigned DiagID)
Produce a diagnostic highlighting some portion of a literal.
A little helper class used to produce diagnostics.
friend bool operator==(const CustomDiagDesc &lhs, const CustomDiagDesc &rhs)
bool ShouldShowInSystemHeader() const
friend bool operator<(const CustomDiagDesc &lhs, const CustomDiagDesc &rhs)
std::optional< diag::Group > GetGroup() const
diag::Severity GetDefaultSeverity() const
CustomDiagDesc(diag::Severity DefaultSeverity, std::string Description, unsigned Class=CLASS_WARNING, bool ShowInSystemHeader=false, bool ShowInSystemMacro=false, std::optional< diag::Group > Group=std::nullopt)
std::string_view GetDescription() const
void initCustomDiagMapping(DiagnosticMapping &, unsigned DiagID)
static StringRef getCategoryNameFromID(unsigned CategoryID)
Given a category ID, return the name of the category.
unsigned getCustomDiagID(Level Level, StringRef Message)
static unsigned getNumberOfCategories()
Return the number of diagnostic categories.
static StringRef getNearestOption(diag::Flavor Flavor, StringRef Group)
Get the diagnostic option with the closest edit distance to the given group name.
bool getDiagnosticsInGroup(diag::Flavor Flavor, StringRef Group, SmallVectorImpl< diag::kind > &Diags) const
Get the set of all diagnostic IDs in the group with the given name.
static std::vector< std::string > getDiagnosticFlags()
Get the string of all diagnostic flags.
bool isWarningOrExtension(unsigned DiagID) const
Return true if the unmapped diagnostic levelof the specified diagnostic ID is a Warning or Extension.
void setGroupSeverity(StringRef Group, diag::Severity)
bool isExtensionDiag(unsigned DiagID) const
Determine whether the given diagnostic ID is for an extension of some sort.
DiagnosticMapping getDefaultMapping(unsigned DiagID) const
Get the default mapping for this diagnostic.
std::string getStableID(unsigned DiagID) const
Given a diagnostic ID, return the stable ID of the diagnostic.
static SFINAEResponse getDiagnosticSFINAEResponse(unsigned DiagID)
Determines whether the given built-in diagnostic ID is for an error that is suppressed if it occurs d...
bool shouldSuppressAsSystemWarning(unsigned DiagID, SourceLocation Loc, const DiagnosticsEngine &Diag) const
Return true if either of the following two conditions hold:
bool isDefaultMappingAsError(unsigned DiagID) const
Return true if the specified diagnostic is mapped to errors by default.
void setGroupNoWarningsAsError(StringRef Group, bool)
bool isTrapDiag(unsigned DiagID) const
static bool isCodegenABICheckDiagnostic(unsigned DiagID)
Return true if a given diagnostic is a codegen-time ABI check.
StringRef getDescription(unsigned DiagID) const
Given a diagnostic ID, return a description of the issue.
SFINAEResponse
Enumeration describing how the emission of a diagnostic should be treated when it occurs during C++ t...
@ SFINAE_SubstitutionFailure
The diagnostic should not be reported, but it should cause template argument deduction to fail.
@ SFINAE_Suppress
The diagnostic should be suppressed entirely.
@ SFINAE_AccessControl
The diagnostic is an access-control diagnostic, which will be substitution failures in some contexts ...
@ SFINAE_Report
The diagnostic should be reported.
bool isNote(unsigned DiagID) const
Determine whether the given diagnostic ID is a Note.
StringRef getWarningOptionForDiag(unsigned DiagID)
Return the lowest-level warning option that enables the specified diagnostic.
static StringRef getWarningOptionDocumentation(diag::Group GroupID)
Given a diagnostic group ID, return its documentation.
static std::optional< diag::Group > getGroupForWarningOption(StringRef)
Given a group ID, returns the flag that toggles the group.
friend class DiagnosticsEngine
static bool IsCustomDiag(diag::kind Diag)
static unsigned getCompatDiagId(const LangOptions &LangOpts, unsigned CompatDiagId)
Get the appropriate diagnostic Id to use for issuing a compatibility diagnostic.
unsigned getCustomDiagID(CustomDiagDesc Diag)
Return an ID for a diagnostic with the specified format string and level.
Level
The level of the diagnostic, after it has been through mapping.
static unsigned getCategoryNumberForDiag(unsigned DiagID)
Return the category number that a specified DiagID belongs to, or 0 if no category.
static StringRef getWarningOptionForGroup(diag::Group)
Given a group ID, returns the flag that toggles the group.
static bool isARCDiagnostic(unsigned DiagID)
Return true if a given diagnostic falls into an ARC diagnostic category.
static void getAllDiagnostics(diag::Flavor Flavor, std::vector< diag::kind > &Diags)
Get the set of all diagnostic IDs.
std::optional< diag::Group > getGroupForDiag(unsigned DiagID) const
Return the lowest-level group that contains the specified diagnostic.
static llvm::IntrusiveRefCntPtr< DiagnosticIDs > create()
static bool isDeferrable(unsigned DiagID)
Whether the diagnostic message can be deferred.
llvm::SmallVector< StringRef, 4 > getLegacyStableIDs(unsigned DiagID) const
Given a diagnostic ID, return the previous stable IDs of the diagnostic.
bool hasNoErrorAsFatal() const
bool wasUpgradedFromWarning() const
Whether this mapping attempted to map the diagnostic to a warning, but was overruled because the diag...
unsigned serialize() const
Serialize this mapping as a raw integer.
bool operator==(DiagnosticMapping Other) const
bool isErrorOrFatal() const
void setNoWarningAsError(bool Value)
void setSeverity(diag::Severity Value)
static DiagnosticMapping deserialize(unsigned Bits)
Deserialize a mapping.
diag::Severity getSeverity() const
void setUpgradedFromWarning(bool Value)
static DiagnosticMapping Make(diag::Severity Severity, bool IsUser, bool IsPragma)
void setNoErrorAsFatal(bool Value)
bool hasNoWarningAsError() const
Concrete class used by the front-end to report problems and issues.
Keeps track of the various options that can be enabled, which controls the dialect of C or C++ that i...
Encodes a location in the source.
Flavor
Flavors of diagnostics we can emit.
@ WarningOrError
A diagnostic that indicates a problem or potential problem.
@ DIAG_SIZE_SERIALIZATION
@ DIAG_START_SERIALIZATION
unsigned kind
All of the diagnostics that can be emitted by the frontend.
Severity
Enum values that allow the client to map NOTEs, WARNINGs, and EXTENSIONs to either Ignore (nothing),...
@ Warning
Present this diagnostic as a warning.
@ Fatal
Present this diagnostic as a fatal error.
@ Error
Present this diagnostic as an error.
@ Remark
Present this diagnostic as a remark.
@ Ignored
Do not present this diagnostic, ignore it.
Top level wrappers for InstallAPI frontend operations.
@ Result
The result type of a method or function.
@ Class
The "class" keyword introduces the elaborated-type-specifier.
@ Other
Other implicit parameter.
__packed_splat4 __packed_splat2 __packed_splat8 __packed_splat4 __packed_splat2 uint8_t
unsigned HasNoWarningAsError