clang 8.0.0

Public Member Functions | Static 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:
[legend]

## Public Member Functions
| DiagnosticBuilder (const DiagnosticBuilder &D)
| Copy constructor. More...
DiagnosticBuilder & | operator= (const DiagnosticBuilder &)=delete
| ~DiagnosticBuilder ()
| Emits the diagnostic. More...
const DiagnosticBuilder & | setForceEmit () const
| Forces the diagnostic to be emitted. More...
| operator bool () const
| Conversion of DiagnosticBuilder to bool always returns `true`. More...
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
void | addFlagValue (StringRef V) const

## Static Public Member Functions
static DiagnosticBuilder | getEmpty ()
| Retrieve an empty diagnostic builder. More...

## Protected Member Functions
void | FlushCounts ()
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...

## Friends
class | DiagnosticsEngine
class | PartialDiagnostic

## 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 1043 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 1113 of file Diagnostic.h.

References Clear().

## ◆ ~DiagnosticBuilder()

clang::DiagnosticBuilder::~DiagnosticBuilder | ( |  | ) |
| inline

Emits the diagnostic.

Definition at line 1124 of file Diagnostic.h.

## Member Function Documentation

## ◆ AddFixItHint()

void clang::DiagnosticBuilder::AddFixItHint | ( | const FixItHint & | Hint | ) | const
| inline

Definition at line 1169 of file Diagnostic.h.

References clang::FixItHint::isNull().

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

## ◆ addFlagValue()

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

Definition at line 1175 of file Diagnostic.h.

Referenced by clang::operator<<().

## ◆ AddSourceRange()

void clang::DiagnosticBuilder::AddSourceRange | ( | const CharSourceRange & | R | ) | const
| inline

Definition at line 1164 of file Diagnostic.h.

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

## ◆ AddString()

void clang::DiagnosticBuilder::AddString | ( | StringRef | S | ) | const
| inline

Definition at line 1148 of file Diagnostic.h.

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

## ◆ AddTaggedVal()

void clang::DiagnosticBuilder::AddTaggedVal | ( | intptr_t | V,
|  | DiagnosticsEngine::ArgumentKind | Kind
| ) |  | const
| inline

Definition at line 1156 of file Diagnostic.h.

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

## ◆ Clear()

void clang::DiagnosticBuilder::Clear | ( |  | ) | const
| inline protected

Clear out the current diagnostic.

Definition at line 1076 of file Diagnostic.h.

Referenced by DiagnosticBuilder().

## ◆ Emit()

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

## ◆ FlushCounts()

void clang::DiagnosticBuilder::FlushCounts | ( |  | ) |
| inline protected

Definition at line 1071 of file Diagnostic.h.

## ◆ getEmpty()

static DiagnosticBuilder clang::DiagnosticBuilder::getEmpty | ( |  | ) |
| inline static

Retrieve an empty diagnostic builder.

Definition at line 1129 of file Diagnostic.h.

## ◆ isActive()

bool clang::DiagnosticBuilder::isActive | ( |  | ) | const
| inline protected

Determine whether this diagnostic is still active.

Definition at line 1083 of file Diagnostic.h.

## ◆ operator bool()

clang::DiagnosticBuilder::operator bool | ( |  | ) | const
| inline

Conversion of DiagnosticBuilder 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 1146 of file Diagnostic.h.

## ◆ 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 1134 of file Diagnostic.h.

Referenced by PrintExpected(), and PrintUnexpected().

## Friends And Related Function Documentation

## ◆ DiagnosticsEngine

friend class DiagnosticsEngine
| friend

Definition at line 1044 of file Diagnostic.h.

## ◆ PartialDiagnostic

friend class PartialDiagnostic
| friend

Definition at line 1045 of file Diagnostic.h.

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

- include/clang/Basic/Diagnostic.h