clang  14.0.0git
Public Types | Public Member Functions | Static Public Member Functions | Friends | List of all members
clang::DiagnosticIDs Class Reference

Used for handling and querying diagnostic IDs. More...

#include "clang/Basic/DiagnosticIDs.h"

Inheritance diagram for clang::DiagnosticIDs:
Inheritance graph
[legend]
Collaboration diagram for clang::DiagnosticIDs:
Collaboration graph
[legend]

Public Types

enum  Level {
  Ignored, Note, Remark, Warning,
  Error, Fatal
}
 The level of the diagnostic, after it has been through mapping. More...
 
enum  SFINAEResponse { SFINAE_SubstitutionFailure, SFINAE_Suppress, SFINAE_Report, SFINAE_AccessControl }
 Enumeration describing how the emission of a diagnostic should be treated when it occurs during C++ template argument deduction. More...
 

Public Member Functions

 DiagnosticIDs ()
 
 ~DiagnosticIDs ()
 
unsigned getCustomDiagID (Level L, StringRef FormatString)
 Return an ID for a diagnostic with the specified format string and level. More...
 
StringRef getDescription (unsigned DiagID) const
 Given a diagnostic ID, return a description of the issue. More...
 
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. More...
 

Static Public Member Functions

static bool isBuiltinWarningOrExtension (unsigned DiagID)
 Return true if the unmapped diagnostic levelof the specified diagnostic ID is a Warning or Extension. More...
 
static bool isDefaultMappingAsError (unsigned DiagID)
 Return true if the specified diagnostic is mapped to errors by default. More...
 
static bool isBuiltinNote (unsigned DiagID)
 Determine whether the given built-in diagnostic ID is a Note. More...
 
static bool isBuiltinExtensionDiag (unsigned DiagID)
 Determine whether the given built-in diagnostic ID is for an extension of some sort. More...
 
static bool isBuiltinExtensionDiag (unsigned DiagID, bool &EnabledByDefault)
 Determine whether the given built-in diagnostic ID is for an extension of some sort, and whether it is enabled by default. More...
 
static StringRef getWarningOptionForGroup (diag::Group)
 Given a group ID, returns the flag that toggles the group. More...
 
static StringRef getWarningOptionForDiag (unsigned DiagID)
 Return the lowest-level warning option that enables the specified diagnostic. More...
 
static unsigned getCategoryNumberForDiag (unsigned DiagID)
 Return the category number that a specified DiagID belongs to, or 0 if no category. More...
 
static unsigned getNumberOfCategories ()
 Return the number of diagnostic categories. More...
 
static StringRef getCategoryNameFromID (unsigned CategoryID)
 Given a category ID, return the name of the category. More...
 
static bool isARCDiagnostic (unsigned DiagID)
 Return true if a given diagnostic falls into an ARC diagnostic category. More...
 
static SFINAEResponse getDiagnosticSFINAEResponse (unsigned DiagID)
 Determines whether the given built-in diagnostic ID is for an error that is suppressed if it occurs during C++ template argument deduction. More...
 
static bool isDeferrable (unsigned DiagID)
 Whether the diagnostic message can be deferred. More...
 
static std::vector< std::stringgetDiagnosticFlags ()
 Get the string of all diagnostic flags. More...
 
static void getAllDiagnostics (diag::Flavor Flavor, std::vector< diag::kind > &Diags)
 Get the set of all diagnostic IDs. More...
 
static StringRef getNearestOption (diag::Flavor Flavor, StringRef Group)
 Get the diagnostic option with the closest edit distance to the given group name. More...
 

Friends

class DiagnosticsEngine
 

Detailed Description

Used for handling and querying diagnostic IDs.

Can be used and shared by multiple Diagnostics for multiple translation units.

Definition at line 166 of file DiagnosticIDs.h.

Member Enumeration Documentation

◆ Level

The level of the diagnostic, after it has been through mapping.

Enumerator
Ignored 
Note 
Remark 
Warning 
Error 
Fatal 

Definition at line 169 of file DiagnosticIDs.h.

◆ SFINAEResponse

Enumeration describing how the emission of a diagnostic should be treated when it occurs during C++ template argument deduction.

Enumerator
SFINAE_SubstitutionFailure 

The diagnostic should not be reported, but it should cause template argument deduction to fail.

The vast majority of errors that occur during template argument deduction fall into this category.

SFINAE_Suppress 

The diagnostic should be suppressed entirely.

Warnings generally fall into this category. 
SFINAE_Report 

The diagnostic should be reported.

The diagnostic should be reported. Various fatal errors (e.g.,
template instantiation depth exceeded) fall into this category. 
SFINAE_AccessControl 

The diagnostic is an access-control diagnostic, which will be substitution failures in some contexts and reported in others.

Definition at line 256 of file DiagnosticIDs.h.

Constructor & Destructor Documentation

◆ DiagnosticIDs()

DiagnosticIDs::DiagnosticIDs ( )

Definition at line 404 of file DiagnosticIDs.cpp.

◆ ~DiagnosticIDs()

DiagnosticIDs::~DiagnosticIDs ( )

Definition at line 406 of file DiagnosticIDs.cpp.

Member Function Documentation

◆ getAllDiagnostics()

void DiagnosticIDs::getAllDiagnostics ( diag::Flavor  Flavor,
std::vector< diag::kind > &  Diags 
)
static

Get the set of all diagnostic IDs.

Definition at line 685 of file DiagnosticIDs.cpp.

References StaticDiagInfoSize.

Referenced by clang::DiagnosticsEngine::setSeverityForAll().

◆ getCategoryNameFromID()

StringRef DiagnosticIDs::getCategoryNameFromID ( unsigned  CategoryID)
static

Given a category ID, return the name of the category.

getCategoryNameFromID - Given a category ID, return the name of the category, an empty string if CategoryID is zero, or null if CategoryID is invalid.

Definition at line 324 of file DiagnosticIDs.cpp.

References CategoryNameTable, and getNumberOfCategories().

Referenced by isARCDiagnostic(), PrintDiagnosticCategories(), printDiagnosticOptions(), and clang::arcmt::writeARCDiagsToPlist().

◆ getCategoryNumberForDiag()

unsigned DiagnosticIDs::getCategoryNumberForDiag ( unsigned  DiagID)
static

Return the category number that a specified DiagID belongs to, or 0 if no category.

getCategoryNumberForDiag - Return the category number that a specified DiagID belongs to, or 0 if no category.

Definition at line 275 of file DiagnosticIDs.cpp.

References GetDiagInfo().

Referenced by isARCDiagnostic(), printDiagnosticOptions(), and clang::arcmt::writeARCDiagsToPlist().

◆ getCustomDiagID()

unsigned DiagnosticIDs::getCustomDiagID ( Level  L,
StringRef  FormatString 
)

Return an ID for a diagnostic with the specified format string and level.

getCustomDiagID - Return an ID for a diagnostic with the specified message and level.

If this is the first request for this diagnostic, it is registered and created, otherwise the existing ID is returned.

If this is the first request for this diagnostic, it is registered and created, otherwise the existing ID is returned.

Parameters
FormatStringA fixed diagnostic format string that will be hashed and mapped to a unique DiagID.

Definition at line 414 of file DiagnosticIDs.cpp.

◆ getDescription()

StringRef DiagnosticIDs::getDescription ( unsigned  DiagID) const

Given a diagnostic ID, return a description of the issue.

getDescription - Given a diagnostic ID, return a description of the issue.

Definition at line 462 of file DiagnosticIDs.cpp.

References GetDiagInfo().

◆ getDiagnosticFlags()

std::vector< std::string > DiagnosticIDs::getDiagnosticFlags ( )
static

Get the string of all diagnostic flags.

Returns
A list of all diagnostics flags as they would be written in a command line invocation including their no- variants. For example: {"-Wempty-body", "-Wno-empty-body", ...}

Definition at line 632 of file DiagnosticIDs.cpp.

References Diag(), and string().

◆ getDiagnosticSFINAEResponse()

DiagnosticIDs::SFINAEResponse DiagnosticIDs::getDiagnosticSFINAEResponse ( unsigned  DiagID)
static

Determines whether the given built-in diagnostic ID is for an error that is suppressed if it occurs during C++ template argument deduction.

When an error is suppressed due to SFINAE, the template argument deduction fails but no diagnostic is emitted. Certain classes of errors, such as those errors that involve C++ access control, are not SFINAE errors.

Definition at line 333 of file DiagnosticIDs.cpp.

References GetDiagInfo(), and SFINAE_Report.

Referenced by clang::Sema::EmitCurrentDiagnostic().

◆ getDiagnosticsInGroup()

bool DiagnosticIDs::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.

Parameters
[out]Diags- On return, the diagnostics in the group.
Returns
true if the given group is unknown, false otherwise.

Definition at line 675 of file DiagnosticIDs.cpp.

References getDiagnosticsInGroup(), and OptionTable.

Referenced by getNearestOption().

◆ getNearestOption()

StringRef DiagnosticIDs::getNearestOption ( diag::Flavor  Flavor,
StringRef  Group 
)
static

Get the diagnostic option with the closest edit distance to the given group name.

Definition at line 692 of file DiagnosticIDs.cpp.

References getDiagnosticsInGroup(), and OptionTable.

Referenced by EmitUnknownDiagWarning().

◆ getNumberOfCategories()

unsigned DiagnosticIDs::getNumberOfCategories ( )
static

Return the number of diagnostic categories.

getNumberOfCategories - Return the number of categories

Definition at line 317 of file DiagnosticIDs.cpp.

References CategoryNameTable.

Referenced by getCategoryNameFromID(), and PrintDiagnosticCategories().

◆ getWarningOptionForDiag()

StringRef DiagnosticIDs::getWarningOptionForDiag ( unsigned  DiagID)
static

Return the lowest-level warning option that enables the specified diagnostic.

getWarningOptionForDiag - Return the lowest-level warning option that enables the specified diagnostic.

If there is no -Wfoo flag that controls the diagnostic, this returns null.

Definition at line 625 of file DiagnosticIDs.cpp.

References GetDiagInfo(), and getWarningOptionForGroup().

Referenced by clang::LogDiagnosticPrinter::HandleDiagnostic(), and printDiagnosticOptions().

◆ getWarningOptionForGroup()

StringRef DiagnosticIDs::getWarningOptionForGroup ( diag::Group  Group)
static

Given a group ID, returns the flag that toggles the group.

For example, for Group::DeprecatedDeclarations, returns "deprecated-declarations".

Definition at line 618 of file DiagnosticIDs.cpp.

References getName(), and OptionTable.

Referenced by clang::driver::tools::Clang::ConstructJob(), and getWarningOptionForDiag().

◆ isARCDiagnostic()

bool DiagnosticIDs::isARCDiagnostic ( unsigned  DiagID)
static

Return true if a given diagnostic falls into an ARC diagnostic category.

Definition at line 841 of file DiagnosticIDs.cpp.

References clang::transformer::cat(), getCategoryNameFromID(), and getCategoryNumberForDiag().

◆ isBuiltinExtensionDiag() [1/2]

static bool clang::DiagnosticIDs::isBuiltinExtensionDiag ( unsigned  DiagID)
inlinestatic

Determine whether the given built-in diagnostic ID is for an extension of some sort.

Definition at line 215 of file DiagnosticIDs.h.

◆ isBuiltinExtensionDiag() [2/2]

bool DiagnosticIDs::isBuiltinExtensionDiag ( unsigned  DiagID,
bool EnabledByDefault 
)
static

Determine whether the given built-in diagnostic ID is for an extension of some sort, and whether it is enabled by default.

isBuiltinExtensionDiag - Determine whether the given built-in diagnostic ID is for an extension of some sort.

This also returns EnabledByDefault, which is set to indicate whether the diagnostic is ignored by default (in which case -pedantic enables it) or treated as a warning/error by default.

Definition at line 442 of file DiagnosticIDs.cpp.

References clang::diag::DIAG_UPPER_LIMIT, getBuiltinDiagClass(), GetDefaultDiagMapping(), clang::DiagnosticMapping::getSeverity(), and clang::diag::Ignored.

◆ isBuiltinNote()

bool DiagnosticIDs::isBuiltinNote ( unsigned  DiagID)
static

Determine whether the given built-in diagnostic ID is a Note.

Definition at line 432 of file DiagnosticIDs.cpp.

References clang::diag::DIAG_UPPER_LIMIT, and getBuiltinDiagClass().

Referenced by clang::Sema::EmitCurrentDiagnostic().

◆ isBuiltinWarningOrExtension()

bool DiagnosticIDs::isBuiltinWarningOrExtension ( unsigned  DiagID)
static

Return true if the unmapped diagnostic levelof the specified diagnostic ID is a Warning or Extension.

isBuiltinWarningOrExtension - Return true if the unmapped diagnostic level of the specified diagnostic ID is a Warning or Extension.

This only works on builtin diagnostics, not custom ones, and is not legal to call on NOTEs.

Definition at line 425 of file DiagnosticIDs.cpp.

References clang::diag::DIAG_UPPER_LIMIT, and getBuiltinDiagClass().

Referenced by printDiagnosticOptions().

◆ isDefaultMappingAsError()

bool DiagnosticIDs::isDefaultMappingAsError ( unsigned  DiagID)
static

Return true if the specified diagnostic is mapped to errors by default.

Definition at line 453 of file DiagnosticIDs.cpp.

References clang::diag::DIAG_UPPER_LIMIT, clang::diag::Error, GetDefaultDiagMapping(), and clang::DiagnosticMapping::getSeverity().

Referenced by clang::Sema::hasUncompilableErrorOccurred(), and printDiagnosticOptions().

◆ isDeferrable()

bool DiagnosticIDs::isDeferrable ( unsigned  DiagID)
static

Whether the diagnostic message can be deferred.

For single source offloading languages, a diagnostic message occurred in a device host function may be deferred until the function is sure to be emitted.

Definition at line 339 of file DiagnosticIDs.cpp.

References GetDiagInfo().

Referenced by clang::Sema::Diag().

Friends And Related Function Documentation

◆ DiagnosticsEngine

friend class DiagnosticsEngine
friend

Definition at line 350 of file DiagnosticIDs.h.


The documentation for this class was generated from the following files: