clang API Documentation

Functions
Diagnostic.cpp File Reference
#include "clang/Basic/CharInfo.h"
#include "clang/Basic/Diagnostic.h"
#include "clang/Basic/DiagnosticOptions.h"
#include "clang/Basic/IdentifierTable.h"
#include "clang/Basic/PartialDiagnostic.h"
#include "llvm/ADT/SmallString.h"
#include "llvm/ADT/StringExtras.h"
#include "llvm/Support/CrashRecoveryContext.h"
#include "llvm/Support/raw_ostream.h"
Include dependency graph for Diagnostic.cpp:

Go to the source code of this file.

Functions

static void DummyArgToStringFn (DiagnosticsEngine::ArgumentKind AK, intptr_t QT, StringRef Modifier, StringRef Argument, ArrayRef< DiagnosticsEngine::ArgumentValue > PrevArgs, SmallVectorImpl< char > &Output, void *Cookie, ArrayRef< intptr_t > QualTypeVals)
template<std::size_t StrLen>
static bool ModifierIs (const char *Modifier, unsigned ModifierLen, const char(&Str)[StrLen])
 ModifierIs - Return true if the specified modifier matches specified string.
static const char * ScanFormat (const char *I, const char *E, char Target)
static void HandleSelectModifier (const Diagnostic &DInfo, unsigned ValNo, const char *Argument, unsigned ArgumentLen, SmallVectorImpl< char > &OutStr)
static void HandleIntegerSModifier (unsigned ValNo, SmallVectorImpl< char > &OutStr)
static void HandleOrdinalModifier (unsigned ValNo, SmallVectorImpl< char > &OutStr)
static unsigned PluralNumber (const char *&Start, const char *End)
 PluralNumber - Parse an unsigned integer and advance Start.
static bool TestPluralRange (unsigned Val, const char *&Start, const char *End)
 TestPluralRange - Test if Val is in the parsed range. Modifies Start.
static bool EvalPluralExpr (unsigned ValNo, const char *Start, const char *End)
 EvalPluralExpr - Actual expression evaluator for HandlePluralModifier.
static void HandlePluralModifier (const Diagnostic &DInfo, unsigned ValNo, const char *Argument, unsigned ArgumentLen, SmallVectorImpl< char > &OutStr)
static const char * getTokenDescForDiagnostic (tok::TokenKind Kind)
 Returns the friendly description for a token kind that will appear without quotes in diagnostic messages. These strings may be translatable in future.

Function Documentation

static void DummyArgToStringFn ( DiagnosticsEngine::ArgumentKind  AK,
intptr_t  QT,
StringRef  Modifier,
StringRef  Argument,
ArrayRef< DiagnosticsEngine::ArgumentValue PrevArgs,
SmallVectorImpl< char > &  Output,
void *  Cookie,
ArrayRef< intptr_t >  QualTypeVals 
) [static]

Definition at line 26 of file Diagnostic.cpp.

Referenced by clang::DiagnosticsEngine::DiagnosticsEngine().

static bool EvalPluralExpr ( unsigned  ValNo,
const char *  Start,
const char *  End 
) [static]

EvalPluralExpr - Actual expression evaluator for HandlePluralModifier.

Definition at line 504 of file Diagnostic.cpp.

References AttributeLangSupport::C, PluralNumber(), and TestPluralRange().

Referenced by HandlePluralModifier().

static const char* getTokenDescForDiagnostic ( tok::TokenKind  Kind) [static]

Returns the friendly description for a token kind that will appear without quotes in diagnostic messages. These strings may be translatable in future.

Definition at line 597 of file Diagnostic.cpp.

Referenced by clang::Diagnostic::FormatDiagnostic().

static void HandleIntegerSModifier ( unsigned  ValNo,
SmallVectorImpl< char > &  OutStr 
) [static]

HandleIntegerSModifier - Handle the integer 's' modifier. This adds the letter 's' to the string if the value is not 1. This is used in cases like this: "you idiot, you have %4 parameter%s4!".

Definition at line 452 of file Diagnostic.cpp.

Referenced by clang::Diagnostic::FormatDiagnostic().

static void HandleOrdinalModifier ( unsigned  ValNo,
SmallVectorImpl< char > &  OutStr 
) [static]

HandleOrdinalModifier - Handle the integer 'ord' modifier. This prints the ordinal form of the given integer, with 1 corresponding to the first ordinal. Currently this is hard-coded to use the English form.

Definition at line 462 of file Diagnostic.cpp.

Referenced by clang::Diagnostic::FormatDiagnostic().

static void HandlePluralModifier ( const Diagnostic DInfo,
unsigned  ValNo,
const char *  Argument,
unsigned  ArgumentLen,
SmallVectorImpl< char > &  OutStr 
) [static]

HandlePluralModifier - Handle the integer 'plural' modifier. This is used for complex plural forms, or in languages where all plurals are complex. The syntax is: plural{cond1:form1|cond2:form2|:form3}, where condn are conditions that are tested in order, the form corresponding to the first that applies being emitted. The empty condition is always true, making the last form a default case. Conditions are simple boolean expressions, where n is the number argument. Here are the rules. condition := expression | empty empty := -> always true expression := numeric [',' expression] -> logical or numeric := range -> true if n in range | '' number '=' range -> true if n % number in range range := number | '[' number ',' number ']' -> ranges are inclusive both ends

Here are some examples from the GNU gettext manual written in this form: English: {1:form0|:form1} Latvian: {0:form2|%100=11,%10=0,%10=[2,9]:form1|:form0} Gaeilge: {1:form0|2:form1|:form2} Romanian: {1:form0|0,%100=[1,19]:form1|:form2} Lithuanian: {%10=0,%100=[10,19]:form2|%10=1:form0|:form1} Russian (requires repeated form): {%100=[11,14]:form2|%10=1:form0|%10=[2,4]:form1|:form2} Slovak {1:form0|[2,4]:form1|:form2} Polish (requires repeated form): {1:form0|%100=[10,20]:form2|%10=[2,4]:form1|:form2}

Definition at line 570 of file Diagnostic.cpp.

References EvalPluralExpr(), clang::Diagnostic::FormatDiagnostic(), and ScanFormat().

Referenced by clang::Diagnostic::FormatDiagnostic().

static void HandleSelectModifier ( const Diagnostic DInfo,
unsigned  ValNo,
const char *  Argument,
unsigned  ArgumentLen,
SmallVectorImpl< char > &  OutStr 
) [static]

HandleSelectModifier - Handle the integer 'select' modifier. This is used like this: select{foo|bar|baz}2. This means that the integer argument "%2" has a value from 0-2. If the value is 0, the diagnostic prints 'foo'. If the value is 1, it prints 'bar'. If it has the value 2, it prints 'baz'. This is very useful for certain classes of variant diagnostics.

Definition at line 428 of file Diagnostic.cpp.

References clang::Diagnostic::FormatDiagnostic(), and ScanFormat().

Referenced by clang::Diagnostic::FormatDiagnostic().

template<std::size_t StrLen>
static bool ModifierIs ( const char *  Modifier,
unsigned  ModifierLen,
const char(&)  Str[StrLen] 
) [static]

ModifierIs - Return true if the specified modifier matches specified string.

Definition at line 391 of file Diagnostic.cpp.

Referenced by clang::Diagnostic::FormatDiagnostic().

static unsigned PluralNumber ( const char *&  Start,
const char *  End 
) [static]

PluralNumber - Parse an unsigned integer and advance Start.

Definition at line 475 of file Diagnostic.cpp.

Referenced by EvalPluralExpr(), and TestPluralRange().

static const char* ScanFormat ( const char *  I,
const char *  E,
char  Target 
) [static]

ScanForward - Scans forward, looking for the given character, skipping nested clauses and escaped characters.

Definition at line 398 of file Diagnostic.cpp.

References Depth, clang::isDigit(), and clang::isPunctuation().

Referenced by clang::Diagnostic::FormatDiagnostic(), HandlePluralModifier(), and HandleSelectModifier().

static bool TestPluralRange ( unsigned  Val,
const char *&  Start,
const char *  End 
) [static]

TestPluralRange - Test if Val is in the parsed range. Modifies Start.

Definition at line 487 of file Diagnostic.cpp.

References PluralNumber().

Referenced by EvalPluralExpr().