|
clang 24.0.0git
|
A generic diagnostic builder for errors which may or may not be deferred. More...
#include "clang/Sema/SemaBase.h"
Public Types | |
| enum | Kind { K_Nop , K_Immediate , K_ImmediateWithCallStack , K_Deferred } |
| using | DeferredDiagnosticsType |
Public Member Functions | |
| SemaDiagnosticBuilder (Kind K, SourceLocation Loc, unsigned DiagID, const FunctionDecl *Fn, Sema &S) | |
| SemaDiagnosticBuilder (SemaDiagnosticBuilder &&D) | |
| SemaDiagnosticBuilder (const SemaDiagnosticBuilder &)=default | |
| SemaDiagnosticBuilder & | operator= (const SemaDiagnosticBuilder &)=delete |
| SemaDiagnosticBuilder & | operator= (SemaDiagnosticBuilder &&)=delete |
| ~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.
Definition at line 120 of file SemaBase.h.
Definition at line 204 of file SemaBase.h.
| 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. |
Definition at line 122 of file SemaBase.h.
| clang::SemaBase::SemaDiagnosticBuilder::SemaDiagnosticBuilder | ( | Kind | K, |
| SourceLocation | Loc, | ||
| unsigned | DiagID, | ||
| const FunctionDecl * | Fn, | ||
| Sema & | S ) |
Referenced by ExprError, operator<<, operator<<(), operator=(), operator=(), SemaDiagnosticBuilder(), SemaDiagnosticBuilder(), and StmtError.
| clang::SemaBase::SemaDiagnosticBuilder::SemaDiagnosticBuilder | ( | SemaDiagnosticBuilder && | D | ) |
References SemaDiagnosticBuilder().
|
default |
References SemaDiagnosticBuilder().
| clang::SemaBase::SemaDiagnosticBuilder::~SemaDiagnosticBuilder | ( | ) |
| void clang::SemaBase::SemaDiagnosticBuilder::AddFixItHint | ( | const FixItHint & | Hint | ) | const |
Definition at line 47 of file SemaBase.cpp.
|
inline |
Definition at line 149 of file SemaBase.h.
Referenced by clang::SemaCUDA::checkRTTIInDefaultInit(), clang::SemaBase::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 DiagIfDeviceCode() and DiagIfHostCode() – you probably want to use these instead of creating a SemaDiagnosticBuilder yourself.
Definition at line 161 of file SemaBase.h.
References isImmediate().
|
inline |
Definition at line 201 of file SemaBase.h.
|
inline |
Definition at line 198 of file SemaBase.h.
References clang::ExprError().
|
inline |
Definition at line 202 of file SemaBase.h.
|
inline |
Definition at line 199 of file SemaBase.h.
References clang::StmtError().
|
inline |
Definition at line 200 of file SemaBase.h.
References clang::TypeError().
|
inline |
Definition at line 179 of file SemaBase.h.
References SemaDiagnosticBuilder(), clang::T, and V.
|
delete |
References SemaDiagnosticBuilder().
|
delete |
References SemaDiagnosticBuilder().
|
friend |
Definition at line 192 of file SemaBase.h.
References clang::ExprError(), and SemaDiagnosticBuilder().
|
friend |
Definition at line 37 of file SemaBase.cpp.
References clang::SemaBase::Diag(), and clang::PartialDiagnostic::Emit().
|
friend |
Definition at line 164 of file SemaBase.h.
References clang::SemaBase::Diag(), SemaDiagnosticBuilder(), and clang::T.
|
friend |
Definition at line 195 of file SemaBase.h.
References SemaDiagnosticBuilder(), and clang::StmtError().