clang  6.0.0svn
Public Types | Public Member Functions | Friends | List of all members
clang::Sema::CUDADiagBuilder Class Reference

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 CUDADiagBuilderoperator<< (const CUDADiagBuilder &Diag, const T &Value)
 

Detailed Description

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.

Definition at line 9895 of file Sema.h.

Member Enumeration Documentation

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

Constructor & Destructor Documentation

◆ CUDADiagBuilder()

Sema::CUDADiagBuilder::CUDADiagBuilder ( Kind  K,
SourceLocation  Loc,
unsigned  DiagID,
FunctionDecl Fn,
Sema S 
)

◆ ~CUDADiagBuilder()

Sema::CUDADiagBuilder::~CUDADiagBuilder ( )

Member Function Documentation

◆ operator bool()

clang::Sema::CUDADiagBuilder::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 (CUDADiagBuilder(...) << foo << bar) return ExprError();

But see CUDADiagIfDeviceCode() and CUDADiagIfHostCode() – you probably want to use these instead of creating a CUDADiagBuilder yourself.

Definition at line 9926 of file Sema.h.

Friends And Related Function Documentation

◆ operator<<

template<typename T >
const CUDADiagBuilder& operator<< ( const CUDADiagBuilder Diag,
const T Value 
)
friend

Definition at line 9929 of file Sema.h.


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