clang
9.0.0
|
Diagnostic builder for CUDA/OpenMP devices 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 | |
DeviceDiagBuilder (Kind K, SourceLocation Loc, unsigned DiagID, FunctionDecl *Fn, Sema &S) | |
DeviceDiagBuilder (DeviceDiagBuilder &&D) | |
DeviceDiagBuilder (const DeviceDiagBuilder &)=default | |
~DeviceDiagBuilder () | |
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 DeviceDiagBuilder & | operator<< (const DeviceDiagBuilder &Diag, const T &Value) |
Diagnostic builder for CUDA/OpenMP devices 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::DeviceDiagBuilder::DeviceDiagBuilder | ( | Kind | K, |
SourceLocation | Loc, | ||
unsigned | DiagID, | ||
FunctionDecl * | Fn, | ||
Sema & | S | ||
) |
Definition at line 1427 of file Sema.cpp.
Referenced by clang::Sema::targetDiag().
Sema::DeviceDiagBuilder::DeviceDiagBuilder | ( | DeviceDiagBuilder && | D | ) |
|
default |
Sema::DeviceDiagBuilder::~DeviceDiagBuilder | ( | ) |
Definition at line 1458 of file Sema.cpp.
References emitCallStackNotes(), clang::DiagnosticsEngine::getDiagnosticLevel(), clang::Sema::getDiagnostics(), 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 (DeviceDiagBuilder(...) << foo << bar) return ExprError();
But see CUDADiagIfDeviceCode() and CUDADiagIfHostCode() – you probably want to use these instead of creating a DeviceDiagBuilder yourself.
|
friend |