clang  14.0.0git
Public Member Functions | Protected Member Functions | Friends | List of all members
clang::DiagnosticBuilder Class Reference

A little helper class used to produce diagnostics. More...

#include "clang/Basic/Diagnostic.h"

Inheritance diagram for clang::DiagnosticBuilder:
Inheritance graph
[legend]
Collaboration diagram for clang::DiagnosticBuilder:
Collaboration graph
[legend]

Public Member Functions

 DiagnosticBuilder (const DiagnosticBuilder &D)
 Copy constructor. More...
 
template<typename T >
const DiagnosticBuilderoperator<< (const T &V) const
 
template<typename T , typename = typename std::enable_if< !std::is_lvalue_reference<T>::value>::type>
const DiagnosticBuilderoperator<< (T &&V) const
 
DiagnosticBuilderoperator= (const DiagnosticBuilder &)=delete
 
 ~DiagnosticBuilder ()
 Emits the diagnostic. More...
 
const DiagnosticBuildersetForceEmit () const
 Forces the diagnostic to be emitted. More...
 
void addFlagValue (StringRef V) const
 
- Public Member Functions inherited from clang::StreamingDiagnostic
DiagnosticStoragegetStorage () const
 Retrieve storage for this particular diagnostic. More...
 
void freeStorage ()
 
void freeStorageSlow ()
 
void AddTaggedVal (uint64_t V, DiagnosticsEngine::ArgumentKind Kind) const
 
void AddString (StringRef V) const
 
void AddSourceRange (const CharSourceRange &R) const
 
void AddFixItHint (const FixItHint &Hint) const
 
 operator bool () const
 Conversion of StreamingDiagnostic to bool always returns true. More...
 

Protected Member Functions

void Clear () const
 Clear out the current diagnostic. More...
 
bool isActive () const
 Determine whether this diagnostic is still active. More...
 
bool Emit ()
 Force the diagnostic builder to emit the diagnostic now. More...
 
- Protected Member Functions inherited from clang::StreamingDiagnostic
 StreamingDiagnostic ()=default
 
 StreamingDiagnostic (DiagnosticStorage *Storage)
 Construct with an external storage not owned by itself. More...
 
 StreamingDiagnostic (DiagStorageAllocator &Alloc)
 Construct with a storage allocator which will manage the storage. More...
 
 StreamingDiagnostic (const StreamingDiagnostic &Diag)=default
 
 StreamingDiagnostic (StreamingDiagnostic &&Diag)=default
 
 ~StreamingDiagnostic ()
 

Friends

class DiagnosticsEngine
 
class PartialDiagnostic
 

Additional Inherited Members

- Protected Attributes inherited from clang::StreamingDiagnostic
DiagnosticStorageDiagStorage = nullptr
 
DiagStorageAllocatorAllocator = nullptr
 Allocator used to allocate storage for this diagnostic. More...
 

Detailed Description

A little helper class used to produce diagnostics.

This is constructed by the DiagnosticsEngine::Report method, and allows insertion of extra information (arguments and source ranges) into the currently "in flight" diagnostic. When the temporary for the builder is destroyed, the diagnostic is issued.

Note that many of these will be created as temporary objects (many call sites), so we want them to be small and we never want their address taken. This ensures that compilers with somewhat reasonable optimizers will promote the common fields to registers, eliminating increments of the NumArgs field, for example.

Definition at line 1264 of file Diagnostic.h.

Constructor & Destructor Documentation

◆ DiagnosticBuilder()

clang::DiagnosticBuilder::DiagnosticBuilder ( const DiagnosticBuilder D)
inline

Copy constructor.

When copied, this "takes" the diagnostic info from the input and neuters it.

Definition at line 1329 of file Diagnostic.h.

References Clear(), and clang::StreamingDiagnostic::DiagStorage.

◆ ~DiagnosticBuilder()

clang::DiagnosticBuilder::~DiagnosticBuilder ( )
inline

Emits the diagnostic.

Definition at line 1359 of file Diagnostic.h.

References Emit().

Member Function Documentation

◆ addFlagValue()

void clang::DiagnosticBuilder::addFlagValue ( StringRef  V) const
inline

Definition at line 1367 of file Diagnostic.h.

References string(), and V.

Referenced by clang::operator<<().

◆ Clear()

void clang::DiagnosticBuilder::Clear ( ) const
inlineprotected

Clear out the current diagnostic.

Definition at line 1296 of file Diagnostic.h.

Referenced by DiagnosticBuilder(), clang::PartialDiagnostic::EmitToString(), and clang::Sema::ImmediateDiagBuilder::~ImmediateDiagBuilder().

◆ Emit()

bool clang::DiagnosticBuilder::Emit ( )
inlineprotected

Force the diagnostic builder to emit the diagnostic now.

Once this function has been called, the DiagnosticBuilder object should not be used again before it is destroyed.

Returns
true if a diagnostic was emitted, false if the diagnostic was suppressed.

Definition at line 1312 of file Diagnostic.h.

References isActive().

Referenced by ~DiagnosticBuilder().

◆ isActive()

bool clang::DiagnosticBuilder::isActive ( ) const
inlineprotected

Determine whether this diagnostic is still active.

Definition at line 1303 of file Diagnostic.h.

Referenced by Emit(), operator<<(), and clang::Sema::ImmediateDiagBuilder::~ImmediateDiagBuilder().

◆ operator<<() [1/2]

template<typename T >
const DiagnosticBuilder& clang::DiagnosticBuilder::operator<< ( const T &  V) const
inline

Definition at line 1337 of file Diagnostic.h.

References isActive(), and V.

◆ operator<<() [2/2]

template<typename T , typename = typename std::enable_if< !std::is_lvalue_reference<T>::value>::type>
const DiagnosticBuilder& clang::DiagnosticBuilder::operator<< ( T &&  V) const
inline

Definition at line 1349 of file Diagnostic.h.

References isActive(), and V.

◆ operator=()

DiagnosticBuilder& clang::DiagnosticBuilder::operator= ( const DiagnosticBuilder )
delete

◆ setForceEmit()

const DiagnosticBuilder& clang::DiagnosticBuilder::setForceEmit ( ) const
inline

Forces the diagnostic to be emitted.

Definition at line 1362 of file Diagnostic.h.

Referenced by PrintExpected(), and PrintUnexpected().

Friends And Related Function Documentation

◆ DiagnosticsEngine

friend class DiagnosticsEngine
friend

Definition at line 1265 of file Diagnostic.h.

◆ PartialDiagnostic

friend class PartialDiagnostic
friend

Definition at line 1266 of file Diagnostic.h.


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