clang API Documentation

Public Member Functions | Static Public Member Functions | Protected Member Functions | Friends
clang::DiagnosticBuilder Class Reference

#include <Diagnostic.h>

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

List of all members.

Public Member Functions

 DiagnosticBuilder (const DiagnosticBuilder &D)
 ~DiagnosticBuilder ()
 Destructor - The dtor emits the diagnostic.
 operator bool () const
void AddString (StringRef S) const
void AddTaggedVal (intptr_t V, DiagnosticsEngine::ArgumentKind Kind) const
void AddSourceRange (const CharSourceRange &R) const
void AddFixItHint (const FixItHint &Hint) const

Static Public Member Functions

static DiagnosticBuilder getEmpty ()
 Retrieve an empty diagnostic builder.

Protected Member Functions

void FlushCounts ()
void Clear () const
 Clear out the current diagnostic.
bool isActive () const
 isActive - Determine whether this diagnostic is still active.
bool Emit ()
 Force the diagnostic builder to emit the diagnostic now.

Friends

class DiagnosticsEngine
class PartialDiagnostic

Detailed Description

DiagnosticBuilder - This is 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 771 of file Diagnostic.h.


Constructor & Destructor Documentation

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 839 of file Diagnostic.h.

References Clear(), and NumArgs.

clang::DiagnosticBuilder::~DiagnosticBuilder ( ) [inline]

Destructor - The dtor emits the diagnostic.

Definition at line 854 of file Diagnostic.h.

References Emit().


Member Function Documentation

void clang::DiagnosticBuilder::AddFixItHint ( const FixItHint Hint) const [inline]
void clang::DiagnosticBuilder::AddSourceRange ( const CharSourceRange R) const [inline]

Definition at line 879 of file Diagnostic.h.

References isActive().

Referenced by clang::PartialDiagnostic::Emit(), and clang::operator<<().

void clang::DiagnosticBuilder::AddString ( StringRef  S) const [inline]
void clang::DiagnosticBuilder::AddTaggedVal ( intptr_t  V,
DiagnosticsEngine::ArgumentKind  Kind 
) const [inline]

Definition at line 871 of file Diagnostic.h.

References isActive(), and NumArgs.

Referenced by clang::PartialDiagnostic::Emit(), and clang::operator<<().

void clang::DiagnosticBuilder::Clear ( ) const [inline, protected]

Clear out the current diagnostic.

Definition at line 803 of file Diagnostic.h.

Referenced by DiagnosticBuilder(), Emit(), and clang::Sema::SemaDiagnosticBuilder::~SemaDiagnosticBuilder().

bool clang::DiagnosticBuilder::Emit ( ) [inline, protected]

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 818 of file Diagnostic.h.

References Clear(), clang::DiagnosticsEngine::EmitCurrentDiagnostic(), FlushCounts(), and isActive().

Referenced by ~DiagnosticBuilder().

void clang::DiagnosticBuilder::FlushCounts ( ) [inline, protected]

Definition at line 796 of file Diagnostic.h.

References NumArgs.

Referenced by Emit(), and clang::Sema::SemaDiagnosticBuilder::~SemaDiagnosticBuilder().

static DiagnosticBuilder clang::DiagnosticBuilder::getEmpty ( ) [inline, static]

Retrieve an empty diagnostic builder.

Definition at line 849 of file Diagnostic.h.

Referenced by clang::Sema::ActOnStartOfSwitchStmt(), and clang::Sema::VerifyIntegerConstantExpression().

bool clang::DiagnosticBuilder::isActive ( ) const [inline, protected]

isActive - Determine whether this diagnostic is still active.

Definition at line 809 of file Diagnostic.h.

Referenced by AddFixItHint(), AddSourceRange(), AddString(), AddTaggedVal(), Emit(), and clang::Sema::SemaDiagnosticBuilder::~SemaDiagnosticBuilder().

clang::DiagnosticBuilder::operator bool ( ) const [inline]

Operator bool: conversion of DiagnosticBuilder to bool always returns true. This allows is to be used in boolean error contexts like: return Diag(...);

Definition at line 861 of file Diagnostic.h.


Friends And Related Function Documentation

friend class DiagnosticsEngine [friend]

Definition at line 783 of file Diagnostic.h.

friend class PartialDiagnostic [friend]

Definition at line 793 of file Diagnostic.h.


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