clang 8.0.0

Public Member Functions | Static Public Member Functions | Public Attributes | List of all members
clang::StringLiteralParser Class Reference

StringLiteralParser - This decodes string escape characters and performs wide string analysis and Translation Phase #6 (concatenation of string literals) (C99 5.1.1.2p1). More...

`#include "clang/Lex/LiteralSupport.h"`

Collaboration diagram for clang::StringLiteralParser:
[legend]

## Public Member Functions
| StringLiteralParser (ArrayRef< Token > StringToks, Preprocessor &PP, bool Complain=true)
| StringLiteralParser (ArrayRef< Token > StringToks, const SourceManager &sm, const LangOptions &features, const TargetInfo &target, DiagnosticsEngine *diags=nullptr)
StringRef | GetString () const
unsigned | GetStringLength () const
unsigned | GetNumStringChars () const
unsigned | getOffsetOfStringByte (const Token &TheTok, unsigned ByteNo) const
| getOffsetOfStringByte - This function returns the offset of the specified byte of the string data represented by Token. More...
bool | isAscii () const
bool | isWide () const
bool | isUTF8 () const
bool | isUTF16 () const
bool | isUTF32 () const
bool | isPascal () const
StringRef | getUDSuffix () const
unsigned | getUDSuffixToken () const
| Get the index of a token containing a ud-suffix. More...
unsigned | getUDSuffixOffset () const
| Get the spelling offset of the first byte of the ud-suffix. More...

## Static Public Member Functions
static bool | isValidUDSuffix (const LangOptions &LangOpts, StringRef Suffix)
| Determine whether a suffix is a valid ud-suffix. More...

## Public Attributes
bool | hadError
bool | Pascal

## Detailed Description

StringLiteralParser - This decodes string escape characters and performs wide string analysis and Translation Phase #6 (concatenation of string literals) (C99 5.1.1.2p1).

Definition at line 206 of file LiteralSupport.h.

## Constructor & Destructor Documentation

## ◆ StringLiteralParser() [1/2]

StringLiteralParser::StringLiteralParser | ( | ArrayRef< Token > | StringToks,
|  | Preprocessor & | PP,
|  | bool | Complain = `true`
| ) |  |

    ///       string-literal: [C++0x lex.string]
    ///         encoding-prefix " [s-char-sequence] "
    ///         encoding-prefix R raw-string
    ///       encoding-prefix:
    ///         u8
    ///         u
    ///         U
    ///         L
    ///       s-char-sequence:
    ///         s-char
    ///         s-char-sequence s-char
    ///       s-char:
    ///         any member of the source character set except the double-quote ",
    ///           backslash \, or new-line character
    ///         escape-sequence
    ///         universal-character-name
    ///       raw-string:
    ///         " d-char-sequence ( r-char-sequence ) d-char-sequence "
    ///       r-char-sequence:
    ///         r-char
    ///         r-char-sequence r-char
    ///       r-char:
    ///         any member of the source character set, except a right parenthesis )
    ///           followed by the initial d-char-sequence (which may be empty)
    ///           followed by a double quote ".
    ///       d-char-sequence:
    ///         d-char
    ///         d-char-sequence d-char
    ///       d-char:
    ///         any member of the basic source character set except:
    ///           space, the left parenthesis (, the right parenthesis ),
    ///           the backslash \, and the control characters representing horizontal
    ///           tab, vertical tab, form feed, and newline.
    ///       escape-sequence: [C++0x lex.ccon]
    ///         simple-escape-sequence
    ///         octal-escape-sequence
    ///         hexadecimal-escape-sequence
    ///       simple-escape-sequence:
    ///         one of \' \" \? \\ \a \b \f \n \r \t \v
    ///       octal-escape-sequence:
    ///         \ octal-digit
    ///         \ octal-digit octal-digit
    ///         \ octal-digit octal-digit octal-digit
    ///       hexadecimal-escape-sequence:
    ///         \x hexadecimal-digit
    ///         hexadecimal-escape-sequence hexadecimal-digit
    ///       universal-character-name:
    ///         \u hex-quad
    ///         \U hex-quad hex-quad
    ///       hex-quad:
    ///         hex-digit hex-digit hex-digit hex-digit
    ///

Definition at line 1452 of file LiteralSupport.cpp.

References EncodeUCNEscape(), clang::expandUCNs(), getCharWidth(), GetNumStringChars(), clang::Lexer::getSpelling(), GetStringLength(), hadError, isAscii(), Pascal, ProcessCharEscape(), and clang::DiagnosticsEngine::Report().

Referenced by clang::CharLiteralParser::CharLiteralParser().

## ◆ StringLiteralParser() [2/2]

clang::StringLiteralParser::StringLiteralParser | ( | ArrayRef< Token > | StringToks,
|  | const SourceManager & | sm,
|  | const LangOptions & | features,
|  | const TargetInfo & | target,
|  | DiagnosticsEngine * | diags = `nullptr`
| ) |  |
| inline

Definition at line 224 of file LiteralSupport.h.

## Member Function Documentation

## ◆ GetNumStringChars()

unsigned clang::StringLiteralParser::GetNumStringChars | ( |  | ) | const
| inline

Definition at line 243 of file LiteralSupport.h.

Referenced by StringLiteralParser().

## ◆ getOffsetOfStringByte()

unsigned StringLiteralParser::getOffsetOfStringByte | ( | const Token & | Tok,
|  | unsigned | ByteNo
| ) |  | const

getOffsetOfStringByte - This function returns the offset of the specified byte of the string data represented by Token.

This handles advancing over escape sequences in the string.

If the Diagnostics pointer is non-null, then this will do semantic checking of the string literal and emit errors and warnings.

This handles advancing over escape sequences in the string.

Definition at line 1811 of file LiteralSupport.cpp.

References clang::Token::getLength(), clang::Token::getLocation(), clang::Lexer::getSpelling(), MeasureUCNEscape(), and ProcessCharEscape().

Referenced by clang::StringLiteral::getLocationOfByte().

## ◆ GetString()

StringRef clang::StringLiteralParser::GetString | ( |  | ) | const
| inline

Definition at line 238 of file LiteralSupport.h.

Referenced by clang::Preprocessor::FinishLexStringLiteral(), GetLineValue(), clang::ModuleMapParser::getLocation(), LexModuleNameComponent(), clang::Preprocessor::LexOnOffSwitch(), and ReadLineMarkerFlags().

## ◆ GetStringLength()

unsigned clang::StringLiteralParser::GetStringLength | ( |  | ) | const
| inline

Definition at line 241 of file LiteralSupport.h.

Referenced by clang::ModuleMapParser::getLocation(), clang::StringLiteral::getLocationOfByte(), and StringLiteralParser().

## ◆ getUDSuffix()

StringRef clang::StringLiteralParser::getUDSuffix | ( |  | ) | const
| inline

Definition at line 261 of file LiteralSupport.h.

## ◆ getUDSuffixOffset()

unsigned clang::StringLiteralParser::getUDSuffixOffset | ( |  | ) | const
| inline

Get the spelling offset of the first byte of the ud-suffix.

Definition at line 269 of file LiteralSupport.h.

References clang::NumericLiteralParser::isValidUDSuffix(), and clang::format::Tok.

## ◆ getUDSuffixToken()

unsigned clang::StringLiteralParser::getUDSuffixToken | ( |  | ) | const
| inline

Get the index of a token containing a ud-suffix.

Definition at line 264 of file LiteralSupport.h.

## ◆ isAscii()

bool clang::StringLiteralParser::isAscii | ( |  | ) | const
| inline

Definition at line 254 of file LiteralSupport.h.

Referenced by clang::Preprocessor::FinishLexStringLiteral(), GetLineValue(), ReadLineMarkerFlags(), resyncUTF8(), and StringLiteralParser().

## ◆ isPascal()

bool clang::StringLiteralParser::isPascal | ( |  | ) | const
| inline

Definition at line 259 of file LiteralSupport.h.

## ◆ isUTF16()

bool clang::StringLiteralParser::isUTF16 | ( |  | ) | const
| inline

Definition at line 257 of file LiteralSupport.h.

## ◆ isUTF32()

bool clang::StringLiteralParser::isUTF32 | ( |  | ) | const
| inline

Definition at line 258 of file LiteralSupport.h.

## ◆ isUTF8()

bool clang::StringLiteralParser::isUTF8 | ( |  | ) | const
| inline

Definition at line 256 of file LiteralSupport.h.

## ◆ isValidUDSuffix()

bool StringLiteralParser::isValidUDSuffix | ( | const LangOptions & | LangOpts,
|  | StringRef | Suffix
| ) |  |
| static

Determine whether a suffix is a valid ud-suffix.

We avoid treating reserved suffixes as ud-suffixes, because the diagnostic experience is better if we treat it as an invalid suffix.

Definition at line 1890 of file LiteralSupport.cpp.

References clang::NumericLiteralParser::isValidUDSuffix().

## ◆ isWide()

bool clang::StringLiteralParser::isWide | ( |  | ) | const
| inline

Definition at line 255 of file LiteralSupport.h.

## Member Data Documentation

## ◆ hadError

bool clang::StringLiteralParser::hadError

Definition at line 235 of file LiteralSupport.h.

Referenced by clang::Preprocessor::FinishLexStringLiteral(), GetLineValue(), clang::ModuleMapParser::getLocation(), LexModuleNameComponent(), clang::Preprocessor::LexOnOffSwitch(), ReadLineMarkerFlags(), and StringLiteralParser().

## ◆ Pascal

bool clang::StringLiteralParser::Pascal

Definition at line 236 of file LiteralSupport.h.

Referenced by clang::Preprocessor::FinishLexStringLiteral(), GetLineValue(), ReadLineMarkerFlags(), and StringLiteralParser().

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

- include/clang/Lex/LiteralSupport.h
- lib/Lex/LiteralSupport.cpp