Go to the documentation of this file.
15 #ifndef LLVM_CLANG_BASIC_PARTIALDIAGNOSTIC_H
16 #define LLVM_CLANG_BASIC_PARTIALDIAGNOSTIC_H
21 #include "llvm/ADT/SmallVector.h"
22 #include "llvm/ADT/StringRef.h"
26 #include <type_traits>
38 mutable unsigned DiagID = 0;
52 if (Other.DiagStorage) {
68 typename = std::enable_if_t<!std::is_lvalue_reference<T>::value>>
78 Other.DiagStorage =
nullptr;
83 : DiagID(Other.DiagID) {
86 if (Other.DiagStorage)
91 : DiagID(Other.getID()) {
94 for (
unsigned I = 0, N = Other.getNumArgs(); I != N; ++I) {
102 for (
unsigned I = 0, N = Other.getNumRanges(); I != N; ++I)
106 for (
unsigned I = 0, N = Other.getNumFixItHints(); I != N; ++I)
111 DiagID = Other.DiagID;
112 if (Other.DiagStorage) {
127 DiagID = Other.DiagID;
131 Other.DiagStorage =
nullptr;
136 std::swap(DiagID, PD.DiagID);
181 this->DiagID = DiagID;
190 assert(I < DiagStorage->NumDiagArgs &&
"Not enough diagnostic args");
209 #endif // LLVM_CLANG_BASIC_PARTIALDIAGNOSTIC_H
PartialDiagnostic & operator=(PartialDiagnostic &&Other)
A little helper class used to produce diagnostics.
unsigned char DiagArgumentsKind[MaxArguments]
Specifies for each argument whether it is in DiagArgumentsStr or in DiagArguments.
Concrete class used by the front-end to report problems and issues.
PartialDiagnostic & operator=(const PartialDiagnostic &Other)
PartialDiagnostic(NullDiagnostic)
Create a null partial diagnostic, which cannot carry a payload, and only exists to be swapped with a ...
void AddTaggedVal(uint64_t V, DiagnosticsEngine::ArgumentKind Kind) const
SmallVector< CharSourceRange, 8 > DiagRanges
The list of ranges added to this diagnostic.
Annotates a diagnostic with some code that should be inserted, removed, or replaced to fix the proble...
A little helper class (which is basically a smart pointer that forwards info from DiagnosticsEngine) ...
void Reset(unsigned DiagID=0)
Clear out this partial diagnostic, giving it a new diagnostic ID and removing all of its arguments,...
DiagStorageAllocator * Allocator
Allocator used to allocate storage for this diagnostic.
std::string DiagArgumentsStr[MaxArguments]
The values for the various substitution positions that have string arguments.
std::pair< SourceLocation, PartialDiagnostic > PartialDiagnosticAt
A partial diagnostic along with the source location where this diagnostic occurs.
void Clear() const
Clear out the current diagnostic.
DiagnosticStorage * DiagStorage
The streaming interface shared between DiagnosticBuilder and PartialDiagnostic.
void Clear()
Clear out the current diagnostic.
__UINTPTR_TYPE__ uintptr_t
An unsigned integer type with the property that any valid pointer to void can be converted to this ty...
PartialDiagnostic(unsigned DiagID, DiagStorageAllocator &Allocator_)
const StreamingDiagnostic & operator<<(const StreamingDiagnostic &DB, const ASTContext::SectionInfo &Section)
Insertion operator for diagnostics.
const PartialDiagnostic & operator<<(const T &V) const
void EmitToString(DiagnosticsEngine &Diags, SmallVectorImpl< char > &Buf) const
void Emit(const DiagnosticBuilder &DB) const
const PartialDiagnostic & operator<<(T &&V) const
PartialDiagnostic(const Diagnostic &Other, DiagStorageAllocator &Allocator_)
PartialDiagnostic(PartialDiagnostic &&Other)
void AddString(StringRef V) const
Represents a character-granular source range.
DiagnosticStorage * getStorage() const
Retrieve storage for this particular diagnostic.
void setDiagID(unsigned ID)
unsigned getDiagID() const
void swap(PartialDiagnostic &PD)
PartialDiagnostic(const PartialDiagnostic &Other)
unsigned char NumDiagArgs
The number of entries in Arguments.
void AddFixItHint(const FixItHint &Hint) const
uint64_t DiagArgumentsVal[MaxArguments]
The values for the various substitution positions.
PartialDiagnostic(const PartialDiagnostic &Other, DiagnosticStorage *DiagStorage_)
StringRef getStringArg(unsigned I)
Retrieve the string argument at the given index.
void FormatDiagnostic(SmallVectorImpl< char > &OutStr) const
Format this diagnostic into a string, substituting the formal arguments into the %0 slots.
@ ak_std_string
std::string
SmallVector< FixItHint, 6 > FixItHints
If valid, provides a hint with some code to insert, remove, or modify at a particular position.
An allocator for DiagnosticStorage objects, which uses a small cache to objects, used to reduce mallo...
void AddSourceRange(const CharSourceRange &R) const
DiagnosticBuilder Report(SourceLocation Loc, unsigned DiagID)
Issue the message to the client.