clang 17.0.0git
|
A generic diagnostic builder for errors which may or may not be deferred. More...
#include "clang/Sema/Sema.h"
Public Types | |
enum | Kind { K_Nop , K_Immediate , K_ImmediateWithCallStack , K_Deferred } |
Public Member Functions | |
SemaDiagnosticBuilder (Kind K, SourceLocation Loc, unsigned DiagID, FunctionDecl *Fn, Sema &S) | |
SemaDiagnosticBuilder (SemaDiagnosticBuilder &&D) | |
SemaDiagnosticBuilder (const SemaDiagnosticBuilder &)=default | |
~SemaDiagnosticBuilder () | |
bool | isImmediate () const |
operator bool () const | |
Convertible to bool: True if we immediately emitted an error, false if we didn't emit an error or we created a deferred error. | |
template<typename T , typename = std::enable_if_t<!std::is_lvalue_reference<T>::value>> | |
const SemaDiagnosticBuilder & | operator<< (T &&V) const |
void | AddFixItHint (const FixItHint &Hint) const |
operator ExprResult () const | |
operator StmtResult () const | |
operator TypeResult () const | |
operator DeclResult () const | |
operator MemInitResult () const | |
Friends | |
template<typename T > | |
const SemaDiagnosticBuilder & | operator<< (const SemaDiagnosticBuilder &Diag, const T &Value) |
const SemaDiagnosticBuilder & | operator<< (const SemaDiagnosticBuilder &Diag, const PartialDiagnostic &PD) |
ExprResult | ExprError (const SemaDiagnosticBuilder &) |
StmtResult | StmtError (const SemaDiagnosticBuilder &) |
A generic diagnostic builder for errors which may or may not be deferred.
In CUDA, there exist constructs (e.g. variable-length arrays, try/catch) which are not allowed to appear inside device functions and are allowed to appear in host device functions only if the host+device function is never codegen'ed.
To handle this, we use the notion of "deferred diagnostics", where we attach a diagnostic to a FunctionDecl that's emitted iff it's codegen'ed.
This class lets you emit either a regular diagnostic, a deferred diagnostic, or no diagnostic at all, according to an argument you pass to its constructor, thus simplifying the process of creating these "maybe deferred" diagnostics.
Enumerator | |
---|---|
K_Nop | Emit no diagnostics. |
K_Immediate | Emit the diagnostic immediately (i.e., behave like Sema::Diag()). |
K_ImmediateWithCallStack | Emit the diagnostic immediately, and, if it's a warning or error, also emit a call stack showing how this function can be reached by an a priori known-emitted function. |
K_Deferred | Create a deferred diagnostic, which is emitted only if the function it's attached to is codegen'ed. Also emit a call stack as with K_ImmediateWithCallStack. |
Sema::SemaDiagnosticBuilder::SemaDiagnosticBuilder | ( | Kind | K, |
SourceLocation | Loc, | ||
unsigned | DiagID, | ||
FunctionDecl * | Fn, | ||
Sema & | S | ||
) |
Definition at line 1820 of file Sema.cpp.
References clang::Sema::DeviceDeferredDiags, clang::Sema::Diags, K_Deferred, K_Immediate, K_ImmediateWithCallStack, K_Nop, clang::Sema::PDiag(), and clang::DiagnosticsEngine::Report().
Sema::SemaDiagnosticBuilder::SemaDiagnosticBuilder | ( | SemaDiagnosticBuilder && | D | ) |
|
default |
Sema::SemaDiagnosticBuilder::~SemaDiagnosticBuilder | ( | ) |
Definition at line 1852 of file Sema.cpp.
References emitCallStackNotes(), clang::DiagnosticsEngine::getDiagnosticLevel(), clang::Sema::getDiagnostics(), and clang::DiagnosticsEngine::Warning.
|
inline |
Definition at line 1830 of file Sema.h.
References clang::Sema::DeviceDeferredDiags.
|
inline |
Definition at line 1783 of file Sema.h.
Referenced by clang::Sema::Diag(), and operator bool().
|
inline |
Convertible to bool: True if we immediately emitted an error, false if we didn't emit an error or we created a deferred error.
Example usage:
if (SemaDiagnosticBuilder(...) << foo << bar) return ExprError();
But see CUDADiagIfDeviceCode() and CUDADiagIfHostCode() – you probably want to use these instead of creating a SemaDiagnosticBuilder yourself.
Definition at line 1795 of file Sema.h.
References isImmediate().
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
Definition at line 1845 of file Sema.h.
References clang::TypeError().
|
inline |
Definition at line 1813 of file Sema.h.
References clang::Sema::DeviceDeferredDiags, and V.
|
friend |
Definition at line 1837 of file Sema.h.
Referenced by operator ExprResult().
|
friend |
|
friend |
|
friend |
Definition at line 1840 of file Sema.h.
Referenced by operator StmtResult().