A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://clang.llvm.org/doxygen/FormatToken_8cpp_source.html below:

clang: lib/Format/FormatToken.cpp Source File

17#include "llvm/ADT/SmallVector.h" 18#include "llvm/Support/Debug.h" 25 static const char

*

const TokNames

[] = {

33

llvm_unreachable(

"unknown TokenType"

);

39 "clock_t"

,

"int16_t"

,

"int32_t"

,

"int64_t"

,

"int8_t"

,

40 "intptr_t"

,

"ptrdiff_t"

,

"size_t"

,

"time_t"

,

"uint16_t"

,

41 "uint32_t"

,

"uint64_t"

,

"uint8_t"

,

"uintptr_t"

,

47 const bool

IsCpp = LangOpts.CXXOperatorNames;

48 return

IsCpp &&

is

(tok::identifier) &&

58

assert(

is

(tok::r_brace));

59 if

(!Style.Cpp11BracedListStyle ||

64

assert(LBrace && LBrace->is(tok::l_brace));

67 if

(LBrace->Previous && LBrace->Previous->is(tok::equal))

78 return is

(TT_ArrayInitializerLSquare) ||

is

(TT_ProtoExtensionLSquare) ||

79

(

is

(tok::l_brace) &&

82

(

is

(tok::less) && Style.isProto());

92 if

(!State.NextToken || !State.NextToken->Previous)

95 if

(Formats.size() <= 1)

100

State.NextToken->Previous->getPreviousNonComment();

101 if

(!LBrace || !LBrace->

isOneOf

(tok::l_brace, TT_ArrayInitializerLSquare) ||

102

LBrace->

is

(

BK_Block

) || LBrace->

is

(TT_DictLiteral) ||

103

LBrace->

Next

->

is

(TT_DesignatedInitializerPeriod)) {

109 unsigned

RemainingCodePoints =

110 Style

.

ColumnLimit

- State.Column + State.NextToken->Previous->ColumnWidth;

113 const

ColumnFormat *Format = getColumnFormat(RemainingCodePoints);

122 unsigned

Penalty = 0;

127 unsigned

ExtraSpaces = 0;

130 if

(Item < Commas.size() && State.NextToken->Previous == Commas[Item]) {

131 if

(!State.NextToken->isTrailingComment()) {

132

ExtraSpaces += Format->ColumnSizes[

Column

] - ItemLengths[Item];

138 if

(

Column

== Format->Columns || State.NextToken->MustBreakBefore) {

144

Penalty +=

Indenter

->addTokenToState(State,

NewLine

, DryRun, ExtraSpaces);

154 if

(Formats.size() == 1 || HasNestedBracedList)

155

State.Stack.back().AvoidBinPacking =

true

;

163

assert(End->TotalLength >=

Begin

->TotalLength);

164 return

End->TotalLength -

Begin

->TotalLength +

Begin

->ColumnWidth;

169 if

(!

Token

->MatchingParen ||

170

!

Token

->

isOneOf

(tok::l_brace, TT_ArrayInitializerLSquare)) {

178

Commas.size() < 19) {

185 if

(

Token

->

is

(TT_ArrayInitializerLSquare) && Commas.size() < 19)

194

ItemBegin = ItemBegin->

Next

;

200

MustBreakBeforeItem.reserve(Commas.size() + 1);

201

EndOfLineItemLength.reserve(Commas.size() + 1);

202

ItemLengths.reserve(Commas.size() + 1);

204 bool

HasSeparatingComment =

false

;

205 for

(

unsigned

i = 0, e = Commas.size() + 1; i != e; ++i) {

209

ItemBegin = ItemBegin->

Next

;

210

HasSeparatingComment = i > 0;

214 if

(ItemBegin->

is

(tok::l_brace))

215

HasNestedBracedList =

true

;

217 if

(i == Commas.size()) {

218

ItemEnd =

Token

->MatchingParen;

226

ItemEnd = ItemEnd->

Next

;

229

ItemEnd =

Token

->MatchingParen->Previous;

239

ItemEnd = ItemEnd->

Next

;

247

ItemBegin = ItemEnd->

Next

;

252 if

(Commas.size() < 5 || HasSeparatingComment)

255 if

(

Token

->NestingLevel != 0 &&

Token

->

is

(tok::l_brace) && Commas.size() < 19)

262

MinSizeInColumn.reserve(MaxItems);

263 for

(

unsigned

Columns = 1; Columns <= MaxItems; ++Columns) {

265

Format.Columns = Columns;

266

Format.ColumnSizes.resize(Columns);

267

MinSizeInColumn.assign(Columns,

UINT_MAX

);

268

Format.LineCount = 1;

269 bool

HasRowWithSufficientColumns =

false

;

271 for

(

unsigned

i = 0, e = ItemLengths.size(); i != e; ++i) {

272

assert(i < MustBreakBeforeItem.size());

273 if

(MustBreakBeforeItem[i] ||

Column

== Columns) {

277 if

(

Column

== Columns - 1)

278

HasRowWithSufficientColumns =

true

;

280

(

Column

== Columns - 1) ? EndOfLineItemLength[i] : ItemLengths[i];

281

Format.ColumnSizes[

Column

] = std::max(Format.ColumnSizes[

Column

], Length);

282

MinSizeInColumn[

Column

] = std::min(MinSizeInColumn[

Column

], Length);

287 if

(!HasRowWithSufficientColumns)

289

Format.TotalWidth = Columns - 1;

291 for

(

unsigned

i = 0; i < Columns; ++i)

292

Format.TotalWidth += Format.ColumnSizes[i];

297 for

(

unsigned

i = 0; i < Columns - 1; ++i)

298 if

(Format.ColumnSizes[i] - MinSizeInColumn[i] > 10)

309

Formats.push_back(Format);

313const

CommaSeparatedList::ColumnFormat *

314

CommaSeparatedList::getColumnFormat(

unsigned

RemainingCharacters)

const

{

315 const

ColumnFormat *BestFormat =

nullptr

;

316 for

(

const

ColumnFormat &Format : llvm::reverse(Formats)) {

317 if

(Format.TotalWidth <= RemainingCharacters || Format.Columns == 1) {

318 if

(BestFormat && Format.LineCount > BestFormat->LineCount)

320

BestFormat = &Format;

329 if

(Current.

is

(TT_CtorInitializerComma) &&

336

((

Previous

.isNot(TT_CtorInitializerComma) ||

339

(

Previous

.isNot(TT_InheritanceComma) ||

This file implements an indenter that manages the indentation of continuations.

This file contains the declaration of the FormatToken, a wrapper around Token with additional informa...

static constexpr bool isOneOf()

static const char *const TokNames[]

ContinuationIndenter * Indenter

Keeps track of the various options that can be enabled, which controls the dialect of C or C++ that i...

Token - This structure provides full information about a lexed token.

bool is(tok::TokenKind K) const

is/isNot - Predicates to check if this token is a specific kind, as in "if (Tok.is(tok::l_brace)) {....

bool isOneOf(tok::TokenKind K1, tok::TokenKind K2) const

bool isSimpleTypeSpecifier(const LangOptions &LangOpts) const

Determine whether the token kind starts a simple-type-specifier.

The base class of the type hierarchy.

unsigned formatFromToken(LineState &State, ContinuationIndenter *Indenter, bool DryRun) override

Apply the special formatting that the given role demands.

unsigned formatAfterToken(LineState &State, ContinuationIndenter *Indenter, bool DryRun) override

Same as formatFromToken, but assumes that the first token has already been set thereby deciding on th...

void precomputeFormattingInfos(const FormatToken *Token) override

After the TokenAnnotator has finished annotating all the tokens, this function precomputes required i...

virtual void precomputeFormattingInfos(const FormatToken *Token)

After the TokenAnnotator has finished annotating all the tokens, this function precomputes required i...

const FormatStyle & Style

const char * getTokenTypeName(TokenType Type)

Determines the name of a token type.

static SmallVector< StringRef > CppNonKeywordTypes

static unsigned CodePointsBetween(const FormatToken *Begin, const FormatToken *End)

TokenType

Determines the semantic type of a syntactic token, e.g.

bool startsNextParameter(const FormatToken &Current, const FormatStyle &Style)

The JSON file list parser is used to communicate input to InstallAPI.

if(T->getSizeExpr()) TRY_TO(TraverseStmt(const_cast< Expr * >(T -> getSizeExpr())))

The FormatStyle is used to configure the formatting to follow specific guidelines.

@ LK_Proto

Should be used for Protocol Buffers (https://developers.google.com/protocol-buffers/).

bool Cpp11BracedListStyle

If true, format braced lists as best suited for C++11 braced lists.

BreakInheritanceListStyle BreakInheritanceList

The inheritance list style to use.

@ BCIS_BeforeComma

Break constructor initializers before the colon and commas, and align the commas with the colon.

LanguageKind Language

Language, this format style is targeted at.

@ BAS_DontAlign

Don't align, instead use ContinuationIndentWidth, e.g.:

@ BAS_BlockIndent

Always break after an open bracket, if the parameters don't fit on a single line.

BreakConstructorInitializersStyle BreakConstructorInitializers

The break constructor initializers style to use.

@ BILS_BeforeComma

Break inheritance list before the colon and commas, and align the commas with the colon.

bool BinPackArguments

If false, a function call's arguments will either be all on the same line or will have one line each.

BracketAlignmentStyle AlignAfterOpenBracket

If true, horizontally aligns arguments after an open bracket.

unsigned ColumnLimit

The column limit.

A wrapper around a Token storing information about the whitespace characters preceding it.

unsigned NestingLevel

The nesting level of this token, i.e.

bool isTypeName(const LangOptions &LangOpts) const

unsigned CanBreakBefore

true if it is allowed to break before this token.

StringRef TokenText

The raw text of the token.

bool opensScope() const

Returns whether Tok is ([{ or an opening < of a template or in protos.

FormatToken * getNextNonComment() const

Returns the next token ignoring comments.

FormatToken * getPreviousNonComment() const

Returns the previous token ignoring comments.

BraceBlockKind getBlockKind() const

FormatToken * Next

The next token in the unwrapped line.

unsigned MustBreakBefore

Whether there must be a line break before this token.

unsigned HasUnescapedNewline

Whether there is at least one unescaped newline before the Token.

bool isBlockIndentedInitRBrace(const FormatStyle &Style) const

Returns true if this token ends a block indented initializer list.

bool is(tok::TokenKind Kind) const

bool opensBlockOrBlockTypeList(const FormatStyle &Style) const

Returns true if this tokens starts a block-type list, i.e.

bool isOneOf(A K1, B K2) const

bool isTrailingComment() const

bool isTypeOrIdentifier(const LangOptions &LangOpts) const

FormatToken * MatchingParen

If this is a bracket, this points to the matching one.

FormatToken * Previous

The previous token in the unwrapped line.

The current state when indenting a unwrapped line.


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4