clang 10.0.0git

Public Types | Public Member Functions | Friends | List of all members
clang::Sema::DeviceDiagBuilder Class Reference

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)

## Detailed Description

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.

Definition at line 11190 of file Sema.h.

## Member Enumeration Documentation

## ◆ Kind

enum clang::Sema::DeviceDiagBuilder::Kind

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 11192 of file Sema.h.

## Constructor & Destructor Documentation

## ◆ DeviceDiagBuilder() [1/3]

Sema::DeviceDiagBuilder::DeviceDiagBuilder | ( | Kind | K,
|  | SourceLocation | Loc,
|  | unsigned | DiagID,
|  | FunctionDecl * | Fn,
|  | Sema & | S
| ) |  |

Definition at line 1498 of file Sema.cpp.

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

## ◆ DeviceDiagBuilder() [2/3]

Sema::DeviceDiagBuilder::DeviceDiagBuilder | ( | DeviceDiagBuilder && | D | ) |

Definition at line 1519 of file Sema.cpp.

## ◆ DeviceDiagBuilder() [3/3]

clang::Sema::DeviceDiagBuilder::DeviceDiagBuilder | ( | const DeviceDiagBuilder & |  | ) |
| default

## ◆ ~DeviceDiagBuilder()

Sema::DeviceDiagBuilder::~DeviceDiagBuilder | ( |  | ) |

Definition at line 1529 of file Sema.cpp.

References emitCallStackNotes(), clang::DiagnosticsEngine::getDiagnosticLevel(), clang::Sema::getDiagnostics(), and clang::DiagnosticsEngine::Warning.

## Member Function Documentation

## ◆ operator bool()

clang::Sema::DeviceDiagBuilder::operator bool | ( |  | ) | const
| 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.

Definition at line 11223 of file Sema.h.

## Friends And Related Function Documentation

## ◆ operator<<

template<typename T >

const DeviceDiagBuilder& operator<< | ( | const DeviceDiagBuilder & | Diag,
|  | const T & | Value
| ) |  |
| friend

Definition at line 11226 of file Sema.h.

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

- include/clang/Sema/Sema.h
- lib/Sema/Sema.cpp