clang  14.0.0git
Classes | Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
clang::StreamingDiagnostic Class Reference

The streaming interface shared between DiagnosticBuilder and PartialDiagnostic. More...

#include "clang/Basic/Diagnostic.h"

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

Classes

class  DiagStorageAllocator
 An allocator for DiagnosticStorage objects, which uses a small cache to objects, used to reduce malloc()/free() traffic for partial diagnostics. More...
 

Public Member Functions

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

 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 ()
 

Protected Attributes

DiagnosticStorageDiagStorage = nullptr
 
DiagStorageAllocatorAllocator = nullptr
 Allocator used to allocate storage for this diagnostic. More...
 

Detailed Description

The streaming interface shared between DiagnosticBuilder and PartialDiagnostic.

This class is not intended to be constructed directly but only as base class of DiagnosticBuilder and PartialDiagnostic builder.

Any new type of argument accepted by DiagnosticBuilder and PartialDiagnostic should be implemented as a '<<' operator of StreamingDiagnostic, e.g.

const StreamingDiagnostic& operator<<(const StreamingDiagnostic&, NewArgType);

Definition at line 1108 of file Diagnostic.h.

Constructor & Destructor Documentation

◆ StreamingDiagnostic() [1/5]

clang::StreamingDiagnostic::StreamingDiagnostic ( )
protecteddefault

◆ StreamingDiagnostic() [2/5]

clang::StreamingDiagnostic::StreamingDiagnostic ( DiagnosticStorage Storage)
inlineexplicitprotected

Construct with an external storage not owned by itself.

The allocator is a null pointer in this case.

Definition at line 1234 of file Diagnostic.h.

◆ StreamingDiagnostic() [3/5]

clang::StreamingDiagnostic::StreamingDiagnostic ( DiagStorageAllocator Alloc)
inlineexplicitprotected

Construct with a storage allocator which will manage the storage.

The allocator is not a null pointer in this case.

Definition at line 1239 of file Diagnostic.h.

◆ StreamingDiagnostic() [4/5]

clang::StreamingDiagnostic::StreamingDiagnostic ( const StreamingDiagnostic Diag)
protecteddefault

◆ StreamingDiagnostic() [5/5]

clang::StreamingDiagnostic::StreamingDiagnostic ( StreamingDiagnostic &&  Diag)
protecteddefault

◆ ~StreamingDiagnostic()

clang::StreamingDiagnostic::~StreamingDiagnostic ( )
inlineprotected

Definition at line 1245 of file Diagnostic.h.

References freeStorage().

Member Function Documentation

◆ AddFixItHint()

void clang::StreamingDiagnostic::AddFixItHint ( const FixItHint Hint) const
inline

◆ AddSourceRange()

void clang::StreamingDiagnostic::AddSourceRange ( const CharSourceRange R) const
inline

◆ AddString()

void clang::StreamingDiagnostic::AddString ( StringRef  V) const
inline

◆ AddTaggedVal()

void clang::StreamingDiagnostic::AddTaggedVal ( uint64_t  V,
DiagnosticsEngine::ArgumentKind  Kind 
) const
inline

◆ freeStorage()

void clang::StreamingDiagnostic::freeStorage ( )
inline

◆ freeStorageSlow()

void clang::StreamingDiagnostic::freeStorageSlow ( )
inline

◆ getStorage()

DiagnosticStorage* clang::StreamingDiagnostic::getStorage ( ) const
inline

◆ operator bool()

clang::StreamingDiagnostic::operator bool ( ) const
inline

Conversion of StreamingDiagnostic to bool always returns true.

This allows is to be used in boolean error contexts (where true is used to indicate that an error has occurred), like:

return Diag(...);

Definition at line 1227 of file Diagnostic.h.

Member Data Documentation

◆ Allocator

DiagStorageAllocator* clang::StreamingDiagnostic::Allocator = nullptr
protected

Allocator used to allocate storage for this diagnostic.

Definition at line 1149 of file Diagnostic.h.

Referenced by freeStorageSlow(), getStorage(), clang::PartialDiagnostic::operator=(), clang::PartialDiagnostic::PartialDiagnostic(), and clang::PartialDiagnostic::swap().

◆ DiagStorage

DiagnosticStorage* clang::StreamingDiagnostic::DiagStorage = nullptr
mutableprotected

The documentation for this class was generated from the following file:
Diag
static DiagnosticBuilder Diag(DiagnosticsEngine *Diags, const LangOptions &Features, FullSourceLoc TokLoc, const char *TokBegin, const char *TokRangeBegin, const char *TokRangeEnd, unsigned DiagID)
Produce a diagnostic highlighting some portion of a literal.
Definition: LiteralSupport.cpp:78