|
clang
5.0.0
|
Diagnostic builder for CUDA 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 | |
| CUDADiagBuilder (Kind K, SourceLocation Loc, unsigned DiagID, FunctionDecl *Fn, Sema &S) | |
| ~CUDADiagBuilder () | |
| 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. More... | |
Friends | |
| template<typename T > | |
| const CUDADiagBuilder & | operator<< (const CUDADiagBuilder &Diag, const T &Value) |
Diagnostic builder for CUDA 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::CUDADiagBuilder::CUDADiagBuilder | ( | Kind | K, |
| SourceLocation | Loc, | ||
| unsigned | DiagID, | ||
| FunctionDecl * | Fn, | ||
| Sema & | S | ||
| ) |
Definition at line 559 of file SemaCUDA.cpp.
References clang::Sema::Diag(), K_Deferred, K_Immediate, K_ImmediateWithCallStack, K_Nop, and clang::Sema::PDiag().
| Sema::CUDADiagBuilder::~CUDADiagBuilder | ( | ) |
Definition at line 592 of file SemaCUDA.cpp.
References clang::Sema::CUDADeferredDiags, EmitCallStackNotes(), clang::DiagnosticsEngine::getDiagnosticLevel(), clang::Sema::getDiagnostics(), S, and clang::DiagnosticsEngine::Warning.
|
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 (CUDADiagBuilder(...) << foo << bar) return ExprError();
But see CUDADiagIfDeviceCode() and CUDADiagIfHostCode() – you probably want to use these instead of creating a CUDADiagBuilder yourself.
|
friend |
1.8.6