clang: lib/Format/FormatToken.h Source File (original) (raw)

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15#ifndef LLVM_CLANG_LIB_FORMAT_FORMATTOKEN_H

16#define LLVM_CLANG_LIB_FORMAT_FORMATTOKEN_H

17

22#include <unordered_set>

23

26

27#define LIST_TOKEN_TYPES \

28 TYPE(AfterPPDirective) \

29 TYPE(ArrayInitializerLSquare) \

30 TYPE(ArraySubscriptLSquare) \

31 TYPE(AttributeColon) \

32 TYPE(AttributeLParen) \

33 TYPE(AttributeLSquare) \

34 TYPE(AttributeMacro) \

35 TYPE(AttributeRParen) \

36 TYPE(AttributeRSquare) \

37 TYPE(BinaryOperator) \

38 TYPE(BitFieldColon) \

39 TYPE(BlockComment) \

40 \

41 TYPE(BlockLBrace) \

42 TYPE(BracedListLBrace) \

43 TYPE(CaseLabelArrow) \

44 \

45 TYPE(CaseLabelColon) \

46 TYPE(CastRParen) \

47 TYPE(ClassLBrace) \

48 \

49 TYPE(ClassHeadName) \

50 TYPE(ClassRBrace) \

51 TYPE(CompoundRequirementLBrace) \

52 \

53 TYPE(ConditionalExpr) \

54 \

55 TYPE(ConditionLParen) \

56 TYPE(ConflictAlternative) \

57 TYPE(ConflictEnd) \

58 TYPE(ConflictStart) \

59 \

60 TYPE(ControlStatementLBrace) \

61 TYPE(ControlStatementRBrace) \

62 TYPE(CppCastLParen) \

63 TYPE(CSharpGenericTypeConstraint) \

64 TYPE(CSharpGenericTypeConstraintColon) \

65 TYPE(CSharpGenericTypeConstraintComma) \

66 TYPE(CSharpNamedArgumentColon) \

67 TYPE(CSharpNullable) \

68 TYPE(CSharpNullConditionalLSquare) \

69 TYPE(CSharpStringLiteral) \

70 TYPE(CtorInitializerColon) \

71 TYPE(CtorInitializerComma) \

72 TYPE(CtorDtorDeclName) \

73 TYPE(DesignatedInitializerLSquare) \

74 TYPE(DesignatedInitializerPeriod) \

75 TYPE(DictLiteral) \

76 TYPE(DoWhile) \

77 TYPE(ElseLBrace) \

78 TYPE(ElseRBrace) \

79 TYPE(EnumLBrace) \

80 TYPE(EnumRBrace) \

81 TYPE(FatArrow) \

82 TYPE(ForEachMacro) \

83 TYPE(FunctionAnnotationRParen) \

84 TYPE(FunctionDeclarationName) \

85 TYPE(FunctionDeclarationLParen) \

86 TYPE(FunctionLBrace) \

87 TYPE(FunctionLikeMacro) \

88 TYPE(FunctionLikeOrFreestandingMacro) \

89 TYPE(FunctionTypeLParen) \

90 \

91 TYPE(GenericSelectionColon) \

92 \

93 TYPE(GotoLabelColon) \

94 TYPE(IfMacro) \

95 TYPE(ImplicitStringLiteral) \

96 TYPE(InheritanceColon) \

97 TYPE(InheritanceComma) \

98 TYPE(InlineASMBrace) \

99 TYPE(InlineASMColon) \

100 TYPE(InlineASMSymbolicNameLSquare) \

101 TYPE(JavaAnnotation) \

102 TYPE(JsAndAndEqual) \

103 TYPE(JsComputedPropertyName) \

104 TYPE(JsExponentiation) \

105 TYPE(JsExponentiationEqual) \

106 TYPE(JsPipePipeEqual) \

107 TYPE(JsPrivateIdentifier) \

108 TYPE(JsTypeColon) \

109 TYPE(JsTypeOperator) \

110 TYPE(JsTypeOptionalQuestion) \

111 TYPE(LambdaArrow) \

112 TYPE(LambdaDefinitionLParen) \

113 TYPE(LambdaLBrace) \

114 TYPE(LambdaLSquare) \

115 TYPE(LeadingJavaAnnotation) \

116 TYPE(LineComment) \

117 TYPE(MacroBlockBegin) \

118 TYPE(MacroBlockEnd) \

119 TYPE(ModulePartitionColon) \

120 TYPE(NamespaceLBrace) \

121 TYPE(NamespaceMacro) \

122 TYPE(NamespaceRBrace) \

123 TYPE(NonNullAssertion) \

124 TYPE(NullCoalescingEqual) \

125 TYPE(NullCoalescingOperator) \

126 TYPE(NullPropagatingOperator) \

127 TYPE(ObjCBlockLBrace) \

128 TYPE(ObjCBlockLParen) \

129 TYPE(ObjCDecl) \

130 TYPE(ObjCForIn) \

131

132

133

134 \

135 TYPE(ObjCMethodExpr) \

136 \

137 TYPE(ObjCMethodSpecifier) \

138 TYPE(ObjCProperty) \

139

140 \

141 TYPE(ObjCSelector) \

142 TYPE(ObjCStringLiteral) \

143 TYPE(OverloadedOperator) \

144 TYPE(OverloadedOperatorLParen) \

145 TYPE(PointerOrReference) \

146 TYPE(ProtoExtensionLSquare) \

147 TYPE(PureVirtualSpecifier) \

148 TYPE(QtProperty) \

149 TYPE(RangeBasedForLoopColon) \

150 TYPE(RecordLBrace) \

151 TYPE(RecordRBrace) \

152 TYPE(RegexLiteral) \

153 TYPE(RequiresClause) \

154 TYPE(RequiresClauseInARequiresExpression) \

155 TYPE(RequiresExpression) \

156 TYPE(RequiresExpressionLBrace) \

157 TYPE(RequiresExpressionLParen) \

158

159

160 \

161 TYPE(SelectorName) \

162 TYPE(StartOfName) \

163 TYPE(StatementAttributeLikeMacro) \

164 TYPE(StatementMacro) \

165

166

167

168 \

169 TYPE(StringInConcatenation) \

170 TYPE(StructLBrace) \

171 TYPE(StructRBrace) \

172 TYPE(StructuredBindingLSquare) \

173 TYPE(SwitchExpressionLabel) \

174 TYPE(SwitchExpressionLBrace) \

175 TYPE(TableGenBangOperator) \

176 TYPE(TableGenCondOperator) \

177 TYPE(TableGenCondOperatorColon) \

178 TYPE(TableGenCondOperatorComma) \

179 TYPE(TableGenDAGArgCloser) \

180 TYPE(TableGenDAGArgListColon) \

181 TYPE(TableGenDAGArgListColonToAlign) \

182 TYPE(TableGenDAGArgListComma) \

183 TYPE(TableGenDAGArgListCommaToBreak) \

184 TYPE(TableGenDAGArgOpener) \

185 TYPE(TableGenDAGArgOpenerToBreak) \

186 TYPE(TableGenDAGArgOperatorID) \

187 TYPE(TableGenDAGArgOperatorToBreak) \

188 TYPE(TableGenListCloser) \

189 TYPE(TableGenListOpener) \

190 TYPE(TableGenMultiLineString) \

191 TYPE(TableGenTrailingPasteOperator) \

192 TYPE(TableGenValueSuffix) \

193 TYPE(TemplateCloser) \

194 TYPE(TemplateOpener) \

195 TYPE(TemplateString) \

196 TYPE(TrailingAnnotation) \

197 TYPE(TrailingReturnArrow) \

198 TYPE(TrailingUnaryOperator) \

199 TYPE(TypeDeclarationParen) \

200 TYPE(TemplateName) \

201 TYPE(TypeName) \

202 TYPE(TypenameMacro) \

203 TYPE(UnaryOperator) \

204 TYPE(UnionLBrace) \

205 TYPE(UnionRBrace) \

206 TYPE(UntouchableMacroFunc) \

207 TYPE(VariableTemplate) \

208 \

209 TYPE(VerilogAssignComma) \

210 \

211 TYPE(VerilogBlockLabelColon) \

212

213

214 \

215 TYPE(VerilogDimensionedTypeName) \

216 \

217 TYPE(VerilogInstancePortComma) \

218 TYPE(VerilogInstancePortLParen) \

219

220 \

221 TYPE(VerilogMultiLineListLParen) \

222 \

223 TYPE(VerilogNumberBase) \

224 \

225 TYPE(VerilogStrength) \

226 \

227 TYPE(VerilogTableItem) \

228 \

229 TYPE(VerilogTypeComma) \

230 TYPE(Unknown)

231

232

233

235#define TYPE(X) TT_##X,

237#undef TYPE

239};

240

252

253enum MacroRole {

254

255

257

258

260

261

263};

264

266

267

268

269

270

271

272

273

274

275

276

277

278

279

280

281

282

283

284

285

286

287

288

289

290

291

294

295

296

297

298

299

300

302

303

305

306

309

310

312};

313

316

317

318

330 Type(TT_Unknown) {}

331

332

334

335

337

338

341

342

343

344

345 std::shared_ptr Role;

347

349

350

351

353

354

357

360

361

362

363

366

367

370

372

373

375

376

378

379

380

382

384

385

387

390

391

392

394

395

396

397

406private:

407

408 unsigned BlockKind : 2;

409

410public:

415 BlockKind = BBK;

416 assert(getBlockKind() == BBK && "BraceBlockKind overflow!");

417 }

418

419private:

420

421 unsigned Decision : 2;

422

423public:

428 Decision = D;

429 assert(getDecision() == D && "FormatDecision overflow!");

430 }

431

432private:

433

434 unsigned PackingKind : 2;

435

436public:

439 }

441 PackingKind = K;

442 assert(getPackingKind() == K && "ParameterPackingKind overflow!");

443 }

444

445private:

446 unsigned TypeIsFinalized : 1;

448

449public:

450

451

454

455

456

458 return;

459 assert((!TypeIsFinalized || T == Type) &&

460 "Please use overwriteFixedType to change a fixed type.");

469 return;

471 TypeIsFinalized = true;

472 }

475 return;

476 TypeIsFinalized = false;

478 }

480

481

483

484

485

486

487

489

490

492

493

496

497

499

500

501

502

504

505

506

508

509

511

512

514

515

516

518

519

520

522

523

524

527

528

531

532

534

535

536

537

539

540

541

544

546

547

549

550

551

552

553

554

556

557

558

559

561

562

563

564

567

568

569

570

571

573

575

576

577

580

581

583

584

586

587

589

590

592

593

595

596

598

599

601

602

604

605

607

608

611

613

614

615

616

617

619

620

621

624

625

629

639 return Tok.getObjCKeywordID() == Kind;

643 return II && II == Tok.getIdentifierInfo();

646 return Tok.getIdentifierInfo() &&

647 Tok.getIdentifierInfo()->getPPKeywordID() == Kind;

651

652 template <typename A, typename B> bool isOneOf(A K1, B K2) const {

653 return is(K1) || is(K2);

654 }

655 template <typename A, typename B, typename... Ts>

656 bool isOneOf(A K1, B K2, Ts... Ks) const {

658 }

659 template bool isNot(T Kind) const { return is(Kind); }

660 template <typename... Ts> bool isNoneOf(Ts... Ks) const {

662 }

664 bool isIf(bool AllowConstexprMacro = true) const {

665 return is(tok::kw_if) || endsSequence(tok::kw_constexpr, tok::kw_if) ||

666 (endsSequence(tok::identifier, tok::kw_if) && AllowConstexprMacro);

667 }

668

669 bool isLoop(const FormatStyle &Style) const {

670 return isOneOf(tok::kw_for, tok::kw_while) ||

671 (Style.isJavaScript() && isNot(tok::l_paren) && Previous &&

673 }

674

677 return true;

678 if (closesScope())

679 return Previous->closesScopeAfterBlock();

680 return false;

681 }

682

683

684

685 template <typename A, typename... Ts>

686 bool startsSequence(A K1, Ts... Tokens) const {

687 return startsSequenceInternal(K1, Tokens...);

688 }

689

690

691

692

693

694

695

696 template <typename A, typename... Ts>

697 bool endsSequence(A K1, Ts... Tokens) const {

698 return endsSequenceInternal(K1, Tokens...);

699 }

700

702

703 bool isAttribute() const {

704 return isOneOf(tok::kw___attribute, tok::kw___declspec, TT_AttributeMacro);

705 }

706

707 bool isAccessSpecifierKeyword() const {

708 return isOneOf(tok::kw_public, tok::kw_protected, tok::kw_private);

709 }

710

711 bool isAccessSpecifier(bool ColonRequired = true) const {

712 if (!isAccessSpecifierKeyword())

713 return false;

714 if (!ColonRequired)

715 return true;

717 return NextNonComment && NextNonComment->is(tok::colon);

718 }

719

720 bool canBePointerOrReferenceQualifier() const {

721 return isOneOf(tok::kw_const, tok::kw_restrict, tok::kw_volatile,

722 tok::kw__Nonnull, tok::kw__Nullable,

723 tok::kw__Null_unspecified, tok::kw___ptr32, tok::kw___ptr64,

724 tok::kw___funcref) ||

725 isAttribute();

726 }

727

728 [[nodiscard]] bool isQtProperty() const;

729 [[nodiscard]] bool isTypeName(const LangOptions &LangOpts) const;

730 [[nodiscard]] bool isTypeOrIdentifier(const LangOptions &LangOpts) const;

731

732 bool isObjCAccessSpecifier() const {

733 return is(tok::at) && Next &&

734 Next->isOneOf(tok::objc_public, tok::objc_protected,

735 tok::objc_package, tok::objc_private);

736 }

737

738 bool isObjCLifetimeQualifier(const FormatStyle &Style) const {

739 if (Style.Language != FormatStyle::LK_ObjC || isNot(tok::identifier) ||

741 return false;

742 }

746 }

747

748

749

750 bool opensScope() const {

751 if (is(TT_TemplateString) && TokenText.ends_with("${"))

752 return true;

753 if (is(TT_DictLiteral) && is(tok::less))

754 return true;

755 return isOneOf(tok::l_paren, tok::l_brace, tok::l_square,

756 TT_TemplateOpener);

757 }

758

759

760 bool closesScope() const {

761 if (is(TT_TemplateString) && TokenText.starts_with("}"))

762 return true;

763 if (is(TT_DictLiteral) && is(tok::greater))

764 return true;

765 return isOneOf(tok::r_paren, tok::r_brace, tok::r_square,

766 TT_TemplateCloser);

767 }

768

769

770 bool isMemberAccess() const {

771 return isOneOf(tok::arrow, tok::period, tok::arrowstar) &&

772 isNoneOf(TT_DesignatedInitializerPeriod, TT_TrailingReturnArrow,

773 TT_LambdaArrow, TT_LeadingJavaAnnotation);

774 }

775

776 bool isPointerOrReference() const {

777 return isOneOf(tok::star, tok::amp, tok::ampamp);

778 }

779

780 bool isPlacementOperator() const {

781 return isOneOf(tok::kw_new, tok::kw_delete);

782 }

783

784 bool isUnaryOperator() const {

785 switch (Tok.getKind()) {

786 case tok:➕

787 case tok::plusplus:

788 case tok:➖

789 case tok::minusminus:

790 case tok::exclaim:

791 case tok::tilde:

792 case tok::kw_sizeof:

793 case tok::kw_alignof:

794 return true;

795 default:

796 return false;

797 }

798 }

799

800 bool isBinaryOperator() const {

801

803 }

804

805 bool isTrailingComment() const {

806 return is(tok::comment) &&

807 (is(TT_LineComment) || Next || Next->NewlinesBefore > 0);

808 }

809

810

811

812 bool isFunctionLikeKeyword() const {

813 if (isAttribute())

814 return true;

815

816 return isOneOf(tok::kw_throw, tok::kw_typeid, tok::kw_return,

817 tok::kw_sizeof, tok::kw_alignof, tok::kw_alignas,

818 tok::kw_decltype, tok::kw_noexcept, tok::kw_static_assert,

819 tok::kw__Atomic,

821#include "clang/Basic/TransformTypeTraits.def"

822 tok::kw_requires);

823 }

824

825

826

827 bool isLabelString() const {

828 if (isNot(tok::string_literal))

829 return false;

831 if (Content.starts_with("\"") || Content.starts_with("'"))

832 Content = Content.drop_front(1);

833 if (Content.ends_with("\"") || Content.ends_with("'"))

834 Content = Content.drop_back(1);

835 Content = Content.trim();

836 return Content.size() > 1 &&

837 (Content.back() == ':' || Content.back() == '=');

838 }

839

840

841

842

843

844

845 SourceLocation getStartOfNonWhitespace() const {

847 }

848

849

850

851 bool hasWhitespaceBefore() const {

853 }

854

865 while (Tok && Tok->is(tok::comment))

867 return Tok;

868 }

869

870

873 while (Tok && Tok->is(tok::comment))

885

886

888 if (!IsCpp || isNot(tok::l_square))

889 return false;

891 do {

892 T = T->getPreviousNonComment();

893 } while (T && T->isOneOf(tok::kw_const, tok::kw_volatile, tok::amp,

894 tok::ampamp));

895 return T && T->is(tok::kw_auto);

897

898

900 if (is(TT_TemplateString) && closesScope())

901 return true;

904

905

906

909 if (is(tok::comment))

910 NamespaceTok = NamespaceTok->getNextNonComment();

911

912 if (NamespaceTok && NamespaceTok->isOneOf(tok::kw_inline, tok::kw_export))

913 NamespaceTok = NamespaceTok->getNextNonComment();

914 return NamespaceTok &&

915 NamespaceTok->isOneOf(tok::kw_namespace, TT_NamespaceMacro)

916 ? NamespaceTok

917 : nullptr;

918 }

919

921

922private:

923

926

927 template <typename A, typename... Ts>

928 bool startsSequenceInternal(A K1, Ts... Tokens) const {

929 if (is(tok::comment) && Next)

930 return Next->startsSequenceInternal(K1, Tokens...);

931 return is(K1) && Next && Next->startsSequenceInternal(Tokens...);

932 }

934 template bool startsSequenceInternal(A K1) const {

935 if (is(tok::comment) && Next)

936 return Next->startsSequenceInternal(K1);

937 return is(K1);

938 }

939

940 template <typename A, typename... Ts> bool endsSequenceInternal(A K1) const {

942 return Previous->endsSequenceInternal(K1);

946 template <typename A, typename... Ts>

947 bool endsSequenceInternal(A K1, Ts... Tokens) const {

949 return Previous->endsSequenceInternal(K1, Tokens...);

950 return is(K1) && Previous && Previous->endsSequenceInternal(Tokens...);

951 }

952};

953

954class ContinuationIndenter;

955struct LineState;

957class TokenRole {

958public:

959 TokenRole(const FormatStyle &Style) : Style(Style) {}

965

966

967

968

972 virtual unsigned formatFromToken(LineState &State,

973 ContinuationIndenter *Indenter,

974 bool DryRun) {

975 return 0;

976 }

978

979

981 ContinuationIndenter *Indenter,

982 bool DryRun) {

983 return 0;

988

989 virtual const FormatToken *lastComma() { return nullptr; }

990

991protected:

992 const FormatStyle &Style;

993};

994

995class CommaSeparatedList : public TokenRole {

996public:

1000 void precomputeFormattingInfos(const FormatToken *Token) override;

1002 unsigned formatAfterToken(LineState &State, ContinuationIndenter *Indenter,

1003 bool DryRun) override;

1004

1005 unsigned formatFromToken(LineState &State, ContinuationIndenter *Indenter,

1006 bool DryRun) override;

1007

1008

1009 void CommaFound(const FormatToken *Token) override {

1010 Commas.push_back(Token);

1012

1013 const FormatToken *lastComma() override {

1014 if (Commas.empty())

1015 return nullptr;

1016 return Commas.back();

1017 }

1018

1019private:

1020

1021

1022 struct ColumnFormat {

1023

1024 unsigned Columns;

1025

1026

1027 unsigned TotalWidth;

1028

1029

1030 unsigned LineCount;

1031

1032

1034 };

1036

1037

1038 const ColumnFormat *getColumnFormat(unsigned RemainingCharacters) const;

1040

1043

1044

1046

1047

1050 bool HasNestedBracedList;

1051};

1052

1053

1054

1055struct AdditionalKeywords {

1056 AdditionalKeywords(IdentifierTable &IdentTable) {

1057 kw_final = &IdentTable.get("final");

1058 kw_override = &IdentTable.get("override");

1059 kw_in = &IdentTable.get("in");

1060 kw_of = &IdentTable.get("of");

1061 kw_CF_CLOSED_ENUM = &IdentTable.get("CF_CLOSED_ENUM");

1062 kw_CF_ENUM = &IdentTable.get("CF_ENUM");

1063 kw_CF_OPTIONS = &IdentTable.get("CF_OPTIONS");

1064 kw_NS_CLOSED_ENUM = &IdentTable.get("NS_CLOSED_ENUM");

1065 kw_NS_ENUM = &IdentTable.get("NS_ENUM");

1066 kw_NS_ERROR_ENUM = &IdentTable.get("NS_ERROR_ENUM");

1067 kw_NS_OPTIONS = &IdentTable.get("NS_OPTIONS");

1068

1069 kw_as = &IdentTable.get("as");

1070 kw_async = &IdentTable.get("async");

1071 kw_await = &IdentTable.get("await");

1072 kw_declare = &IdentTable.get("declare");

1073 kw_finally = &IdentTable.get("finally");

1074 kw_from = &IdentTable.get("from");

1075 kw_function = &IdentTable.get("function");

1076 kw_get = &IdentTable.get("get");

1077 kw_import = &IdentTable.get("import");

1078 kw_infer = &IdentTable.get("infer");

1079 kw_is = &IdentTable.get("is");

1080 kw_let = &IdentTable.get("let");

1081 kw_module = &IdentTable.get("module");

1082 kw_readonly = &IdentTable.get("readonly");

1083 kw_set = &IdentTable.get("set");

1084 kw_type = &IdentTable.get("type");

1085 kw_typeof = &IdentTable.get("typeof");

1086 kw_var = &IdentTable.get("var");

1087 kw_yield = &IdentTable.get("yield");

1088

1089 kw_abstract = &IdentTable.get("abstract");

1090 kw_assert = &IdentTable.get("assert");

1091 kw_extends = &IdentTable.get("extends");

1092 kw_implements = &IdentTable.get("implements");

1093 kw_instanceof = &IdentTable.get("instanceof");

1094 kw_interface = &IdentTable.get("interface");

1095 kw_native = &IdentTable.get("native");

1096 kw_package = &IdentTable.get("package");

1097 kw_record = &IdentTable.get("record");

1098 kw_synchronized = &IdentTable.get("synchronized");

1099 kw_throws = &IdentTable.get("throws");

1100 kw___except = &IdentTable.get("__except");

1101 kw___has_include = &IdentTable.get("__has_include");

1102 kw___has_include_next = &IdentTable.get("__has_include_next");

1103

1104 kw_mark = &IdentTable.get("mark");

1105 kw_region = &IdentTable.get("region");

1107 kw_extend = &IdentTable.get("extend");

1108 kw_option = &IdentTable.get("option");

1109 kw_optional = &IdentTable.get("optional");

1110 kw_repeated = &IdentTable.get("repeated");

1111 kw_required = &IdentTable.get("required");

1112 kw_returns = &IdentTable.get("returns");

1113

1114 kw_signals = &IdentTable.get("signals");

1115 kw_qsignals = &IdentTable.get("Q_SIGNALS");

1116 kw_slots = &IdentTable.get("slots");

1117 kw_qslots = &IdentTable.get("Q_SLOTS");

1118

1119

1120 kw_internal_ident_after_define =

1121 &IdentTable.get("__CLANG_FORMAT_INTERNAL_IDENT_AFTER_DEFINE__");

1122

1123

1124 kw_dollar = &IdentTable.get("dollar");

1125 kw_base = &IdentTable.get("base");

1126 kw_byte = &IdentTable.get("byte");

1127 kw_checked = &IdentTable.get("checked");

1128 kw_decimal = &IdentTable.get("decimal");

1129 kw_delegate = &IdentTable.get("delegate");

1130 kw_event = &IdentTable.get("event");

1131 kw_fixed = &IdentTable.get("fixed");

1132 kw_foreach = &IdentTable.get("foreach");

1133 kw_init = &IdentTable.get("init");

1134 kw_implicit = &IdentTable.get("implicit");

1135 kw_internal = &IdentTable.get("internal");

1136 kw_lock = &IdentTable.get("lock");

1137 kw_null = &IdentTable.get("null");

1138 kw_object = &IdentTable.get("object");

1139 kw_out = &IdentTable.get("out");

1140 kw_params = &IdentTable.get("params");

1141 kw_ref = &IdentTable.get("ref");

1142 kw_string = &IdentTable.get("string");

1143 kw_stackalloc = &IdentTable.get("stackalloc");

1144 kw_sbyte = &IdentTable.get("sbyte");

1145 kw_sealed = &IdentTable.get("sealed");

1146 kw_uint = &IdentTable.get("uint");

1147 kw_ulong = &IdentTable.get("ulong");

1148 kw_unchecked = &IdentTable.get("unchecked");

1149 kw_unsafe = &IdentTable.get("unsafe");

1150 kw_ushort = &IdentTable.get("ushort");

1151 kw_when = &IdentTable.get("when");

1152 kw_where = &IdentTable.get("where");

1153

1154

1155 kw_always = &IdentTable.get("always");

1156 kw_always_comb = &IdentTable.get("always_comb");

1157 kw_always_ff = &IdentTable.get("always_ff");

1158 kw_always_latch = &IdentTable.get("always_latch");

1159 kw_assign = &IdentTable.get("assign");

1160 kw_assume = &IdentTable.get("assume");

1161 kw_automatic = &IdentTable.get("automatic");

1162 kw_before = &IdentTable.get("before");

1163 kw_begin = &IdentTable.get("begin");

1164 kw_begin_keywords = &IdentTable.get("begin_keywords");

1165 kw_bins = &IdentTable.get("bins");

1166 kw_binsof = &IdentTable.get("binsof");

1167 kw_casex = &IdentTable.get("casex");

1168 kw_casez = &IdentTable.get("casez");

1169 kw_celldefine = &IdentTable.get("celldefine");

1170 kw_checker = &IdentTable.get("checker");

1171 kw_clocking = &IdentTable.get("clocking");

1172 kw_constraint = &IdentTable.get("constraint");

1173 kw_context = &IdentTable.get("context");

1174 kw_cover = &IdentTable.get("cover");

1175 kw_covergroup = &IdentTable.get("covergroup");

1176 kw_coverpoint = &IdentTable.get("coverpoint");

1177 kw_default_decay_time = &IdentTable.get("default_decay_time");

1178 kw_default_nettype = &IdentTable.get("default_nettype");

1179 kw_default_trireg_strength = &IdentTable.get("default_trireg_strength");

1180 kw_delay_mode_distributed = &IdentTable.get("delay_mode_distributed");

1181 kw_delay_mode_path = &IdentTable.get("delay_mode_path");

1182 kw_delay_mode_unit = &IdentTable.get("delay_mode_unit");

1183 kw_delay_mode_zero = &IdentTable.get("delay_mode_zero");

1184 kw_disable = &IdentTable.get("disable");

1185 kw_dist = &IdentTable.get("dist");

1186 kw_edge = &IdentTable.get("edge");

1187 kw_elsif = &IdentTable.get("elsif");

1188 kw_end = &IdentTable.get("end");

1189 kw_end_keywords = &IdentTable.get("end_keywords");

1190 kw_endcase = &IdentTable.get("endcase");

1191 kw_endcelldefine = &IdentTable.get("endcelldefine");

1192 kw_endchecker = &IdentTable.get("endchecker");

1193 kw_endclass = &IdentTable.get("endclass");

1194 kw_endclocking = &IdentTable.get("endclocking");

1195 kw_endfunction = &IdentTable.get("endfunction");

1196 kw_endgenerate = &IdentTable.get("endgenerate");

1197 kw_endgroup = &IdentTable.get("endgroup");

1198 kw_endinterface = &IdentTable.get("endinterface");

1199 kw_endmodule = &IdentTable.get("endmodule");

1200 kw_endpackage = &IdentTable.get("endpackage");

1201 kw_endprimitive = &IdentTable.get("endprimitive");

1202 kw_endprogram = &IdentTable.get("endprogram");

1203 kw_endproperty = &IdentTable.get("endproperty");

1204 kw_endsequence = &IdentTable.get("endsequence");

1205 kw_endspecify = &IdentTable.get("endspecify");

1206 kw_endtable = &IdentTable.get("endtable");

1207 kw_endtask = &IdentTable.get("endtask");

1208 kw_forever = &IdentTable.get("forever");

1209 kw_fork = &IdentTable.get("fork");

1210 kw_generate = &IdentTable.get("generate");

1211 kw_highz0 = &IdentTable.get("highz0");

1212 kw_highz1 = &IdentTable.get("highz1");

1213 kw_iff = &IdentTable.get("iff");

1214 kw_ifnone = &IdentTable.get("ifnone");

1215 kw_ignore_bins = &IdentTable.get("ignore_bins");

1216 kw_illegal_bins = &IdentTable.get("illegal_bins");

1217 kw_initial = &IdentTable.get("initial");

1218 kw_inout = &IdentTable.get("inout");

1219 kw_input = &IdentTable.get("input");

1220 kw_inside = &IdentTable.get("inside");

1221 kw_interconnect = &IdentTable.get("interconnect");

1222 kw_intersect = &IdentTable.get("intersect");

1223 kw_join = &IdentTable.get("join");

1224 kw_join_any = &IdentTable.get("join_any");

1225 kw_join_none = &IdentTable.get("join_none");

1226 kw_large = &IdentTable.get("large");

1227 kw_local = &IdentTable.get("local");

1228 kw_localparam = &IdentTable.get("localparam");

1229 kw_macromodule = &IdentTable.get("macromodule");

1230 kw_matches = &IdentTable.get("matches");

1231 kw_medium = &IdentTable.get("medium");

1232 kw_negedge = &IdentTable.get("negedge");

1233 kw_nounconnected_drive = &IdentTable.get("nounconnected_drive");

1234 kw_output = &IdentTable.get("output");

1235 kw_packed = &IdentTable.get("packed");

1236 kw_parameter = &IdentTable.get("parameter");

1237 kw_posedge = &IdentTable.get("posedge");

1238 kw_primitive = &IdentTable.get("primitive");

1239 kw_priority = &IdentTable.get("priority");

1240 kw_program = &IdentTable.get("program");

1241 kw_property = &IdentTable.get("property");

1242 kw_pull0 = &IdentTable.get("pull0");

1243 kw_pull1 = &IdentTable.get("pull1");

1244 kw_pure = &IdentTable.get("pure");

1245 kw_rand = &IdentTable.get("rand");

1246 kw_randc = &IdentTable.get("randc");

1247 kw_randcase = &IdentTable.get("randcase");

1248 kw_randsequence = &IdentTable.get("randsequence");

1249 kw_repeat = &IdentTable.get("repeat");

1250 kw_resetall = &IdentTable.get("resetall");

1251 kw_sample = &IdentTable.get("sample");

1252 kw_scalared = &IdentTable.get("scalared");

1253 kw_sequence = &IdentTable.get("sequence");

1254 kw_small = &IdentTable.get("small");

1255 kw_soft = &IdentTable.get("soft");

1256 kw_solve = &IdentTable.get("solve");

1257 kw_specify = &IdentTable.get("specify");

1258 kw_specparam = &IdentTable.get("specparam");

1259 kw_strong0 = &IdentTable.get("strong0");

1260 kw_strong1 = &IdentTable.get("strong1");

1261 kw_supply0 = &IdentTable.get("supply0");

1262 kw_supply1 = &IdentTable.get("supply1");

1263 kw_table = &IdentTable.get("table");

1264 kw_tagged = &IdentTable.get("tagged");

1265 kw_task = &IdentTable.get("task");

1266 kw_timescale = &IdentTable.get("timescale");

1267 kw_tri = &IdentTable.get("tri");

1268 kw_tri0 = &IdentTable.get("tri0");

1269 kw_tri1 = &IdentTable.get("tri1");

1270 kw_triand = &IdentTable.get("triand");

1271 kw_trior = &IdentTable.get("trior");

1272 kw_trireg = &IdentTable.get("trireg");

1273 kw_unconnected_drive = &IdentTable.get("unconnected_drive");

1274 kw_undefineall = &IdentTable.get("undefineall");

1275 kw_unique = &IdentTable.get("unique");

1276 kw_unique0 = &IdentTable.get("unique0");

1277 kw_uwire = &IdentTable.get("uwire");

1278 kw_vectored = &IdentTable.get("vectored");

1279 kw_wait = &IdentTable.get("wait");

1280 kw_wand = &IdentTable.get("wand");

1281 kw_weak0 = &IdentTable.get("weak0");

1282 kw_weak1 = &IdentTable.get("weak1");

1283 kw_wildcard = &IdentTable.get("wildcard");

1284 kw_wire = &IdentTable.get("wire");

1285 kw_with = &IdentTable.get("with");

1286 kw_wor = &IdentTable.get("wor");

1287

1288

1289 kw_verilogHash = &IdentTable.get("#");

1290 kw_verilogHashHash = &IdentTable.get("##");

1291 kw_apostrophe = &IdentTable.get("\'");

1292

1293

1294 kw_bit = &IdentTable.get("bit");

1295 kw_bits = &IdentTable.get("bits");

1296 kw_code = &IdentTable.get("code");

1297 kw_dag = &IdentTable.get("dag");

1298 kw_def = &IdentTable.get("def");

1299 kw_defm = &IdentTable.get("defm");

1300 kw_defset = &IdentTable.get("defset");

1301 kw_defvar = &IdentTable.get("defvar");

1302 kw_dump = &IdentTable.get("dump");

1303 kw_include = &IdentTable.get("include");

1304 kw_list = &IdentTable.get("list");

1305 kw_multiclass = &IdentTable.get("multiclass");

1306 kw_then = &IdentTable.get("then");

1307

1308

1309

1310 JsExtraKeywords = std::unordered_set<IdentifierInfo *>(

1311 {kw_as, kw_async, kw_await, kw_declare, kw_finally, kw_from,

1312 kw_function, kw_get, kw_import, kw_is, kw_let, kw_module, kw_override,

1313 kw_readonly, kw_set, kw_type, kw_typeof, kw_var, kw_yield,

1314

1315 kw_abstract, kw_extends, kw_implements, kw_instanceof, kw_interface});

1316

1317 CSharpExtraKeywords = JsExtraKeywords;

1318 CSharpExtraKeywords.insert(

1319 {kw_base, kw_byte, kw_checked, kw_decimal, kw_delegate,

1320 kw_event, kw_fixed, kw_foreach, kw_implicit, kw_in,

1321 kw_init, kw_internal, kw_lock, kw_null, kw_object,

1322 kw_out, kw_params, kw_ref, kw_string, kw_stackalloc,

1323 kw_sbyte, kw_sealed, kw_uint, kw_ulong, kw_unchecked,

1324 kw_unsafe, kw_ushort, kw_when, kw_where});

1325

1326

1327

1328

1329 VerilogExtraKeywords =

1330 std::unordered_set<IdentifierInfo *>({kw_always,

1331 kw_always_comb,

1332 kw_always_ff,

1333 kw_always_latch,

1334 kw_assert,

1335 kw_assign,

1336 kw_assume,

1337 kw_automatic,

1338 kw_before,

1339 kw_begin,

1340 kw_bins,

1341 kw_binsof,

1342 kw_casex,

1343 kw_casez,

1344 kw_celldefine,

1345 kw_checker,

1346 kw_clocking,

1347 kw_constraint,

1348 kw_context,

1349 kw_cover,

1350 kw_covergroup,

1351 kw_coverpoint,

1352 kw_disable,

1353 kw_dist,

1354 kw_edge,

1355 kw_end,

1356 kw_endcase,

1357 kw_endchecker,

1358 kw_endclass,

1359 kw_endclocking,

1360 kw_endfunction,

1361 kw_endgenerate,

1362 kw_endgroup,

1363 kw_endinterface,

1364 kw_endmodule,

1365 kw_endpackage,

1366 kw_endprimitive,

1367 kw_endprogram,

1368 kw_endproperty,

1369 kw_endsequence,

1370 kw_endspecify,

1371 kw_endtable,

1372 kw_endtask,

1373 kw_extends,

1374 kw_final,

1375 kw_foreach,

1376 kw_forever,

1377 kw_fork,

1378 kw_function,

1379 kw_generate,

1380 kw_highz0,

1381 kw_highz1,

1382 kw_iff,

1383 kw_ifnone,

1384 kw_ignore_bins,

1385 kw_illegal_bins,

1386 kw_implements,

1387 kw_import,

1388 kw_initial,

1389 kw_inout,

1391 kw_inside,

1392 kw_interconnect,

1393 kw_interface,

1394 kw_intersect,

1395 kw_join,

1396 kw_join_any,

1397 kw_join_none,

1398 kw_large,

1399 kw_let,

1400 kw_local,

1401 kw_localparam,

1402 kw_macromodule,

1403 kw_matches,

1404 kw_medium,

1405 kw_module,

1406 kw_negedge,

1407 kw_output,

1408 kw_package,

1409 kw_packed,

1410 kw_parameter,

1411 kw_posedge,

1412 kw_primitive,

1413 kw_priority,

1414 kw_program,

1415 kw_property,

1416 kw_pull0,

1417 kw_pull1,

1418 kw_pure,

1419 kw_rand,

1420 kw_randc,

1421 kw_randcase,

1422 kw_randsequence,

1423 kw_ref,

1424 kw_repeat,

1425 kw_sample,

1426 kw_scalared,

1427 kw_sequence,

1428 kw_small,

1429 kw_soft,

1430 kw_solve,

1431 kw_specify,

1432 kw_specparam,

1433 kw_strong0,

1434 kw_strong1,

1435 kw_supply0,

1436 kw_supply1,

1437 kw_table,

1438 kw_tagged,

1439 kw_task,

1440 kw_tri,

1441 kw_tri0,

1442 kw_tri1,

1443 kw_triand,

1444 kw_trior,

1445 kw_trireg,

1446 kw_unique,

1447 kw_unique0,

1448 kw_uwire,

1449 kw_var,

1450 kw_vectored,

1451 kw_wait,

1452 kw_wand,

1453 kw_weak0,

1454 kw_weak1,

1455 kw_wildcard,

1456 kw_wire,

1457 kw_with,

1458 kw_wor,

1459 kw_verilogHash,

1460 kw_verilogHashHash});

1461

1462 TableGenExtraKeywords = std::unordered_set<IdentifierInfo *>({

1463 kw_assert,

1464 kw_bit,

1465 kw_bits,

1466 kw_code,

1467 kw_dag,

1468 kw_def,

1469 kw_defm,

1470 kw_defset,

1471 kw_defvar,

1472 kw_dump,

1484

1500

1521

1533

1534

1538

1546

1552

1555

1589

1723

1727

1730

1744

1745

1747

1748 return Tok.Tok.getIdentifierInfo() &&

1750 }

1751

1752

1753

1754

1755

1756

1758 bool AcceptIdentifierName = true) const {

1759

1760

1761 if (Tok.isAccessSpecifierKeyword())

1762 return false;

1763 switch (Tok.Tok.getKind()) {

1764 case tok::kw_break:

1765 case tok::kw_case:

1766 case tok::kw_catch:

1767 case tok::kw_class:

1768 case tok::kw_continue:

1769 case tok::kw_const:

1770 case tok::kw_default:

1771 case tok::kw_delete:

1772 case tok::kw_do:

1773 case tok::kw_else:

1774 case tok::kw_enum:

1775 case tok::kw_export:

1776 case tok::kw_false:

1777 case tok::kw_for:

1778 case tok::kw_if:

1779 case tok::kw_import:

1780 case tok::kw_module:

1781 case tok::kw_new:

1782 case tok::kw_return:

1783 case tok::kw_static:

1784 case tok::kw_switch:

1785 case tok::kw_this:

1786 case tok::kw_throw:

1787 case tok::kw_true:

1788 case tok::kw_try:

1789 case tok::kw_typeof:

1790 case tok::kw_void:

1791 case tok::kw_while:

1792

1793 return false;

1794 case tok::identifier: {

1795

1796

1797 bool IsPseudoKeyword =

1798 JsExtraKeywords.find(Tok.Tok.getIdentifierInfo()) !=

1799 JsExtraKeywords.end();

1800 return AcceptIdentifierName || !IsPseudoKeyword;

1801 }

1802 default:

1803

1804

1805 break;

1806 }

1807

1808 switch (Tok.Tok.getKind()) {

1809

1810#define KEYWORD(X, Y) case tok::kw_##X:

1811#include "clang/Basic/TokenKinds.def"

1812

1813

1814 return true;

1815 default:

1816

1817 return false;

1818 }

1819 }

1820

1821

1822

1823 bool isCSharpKeyword(const FormatToken &Tok) const {

1824 if (Tok.isAccessSpecifierKeyword())

1825 return true;

1826 switch (Tok.Tok.getKind()) {

1827 case tok::kw_bool:

1828 case tok::kw_break:

1829 case tok::kw_case:

1830 case tok::kw_catch:

1831 case tok::kw_char:

1832 case tok::kw_class:

1833 case tok::kw_const:

1834 case tok::kw_continue:

1835 case tok::kw_default:

1836 case tok::kw_do:

1837 case tok::kw_double:

1838 case tok::kw_else:

1839 case tok::kw_enum:

1840 case tok::kw_explicit:

1841 case tok::kw_extern:

1842 case tok::kw_false:

1843 case tok::kw_float:

1844 case tok::kw_for:

1845 case tok::kw_goto:

1846 case tok::kw_if:

1847 case tok::kw_int:

1848 case tok::kw_long:

1849 case tok::kw_namespace:

1850 case tok::kw_new:

1851 case tok::kw_operator:

1852 case tok::kw_return:

1853 case tok::kw_short:

1854 case tok::kw_sizeof:

1855 case tok::kw_static:

1856 case tok::kw_struct:

1857 case tok::kw_switch:

1858 case tok::kw_this:

1859 case tok::kw_throw:

1860 case tok::kw_true:

1861 case tok::kw_try:

1862 case tok::kw_typeof:

1863 case tok::kw_using:

1864 case tok::kw_virtual:

1865 case tok::kw_void:

1866 case tok::kw_volatile:

1867 case tok::kw_while:

1868 return true;

1869 default:

1870 return Tok.is(tok::identifier) &&

1871 CSharpExtraKeywords.find(Tok.Tok.getIdentifierInfo()) ==

1872 CSharpExtraKeywords.end();

1874 }

1875

1876 bool isVerilogKeywordSymbol(const FormatToken &Tok) const {

1877 return Tok.isOneOf(kw_verilogHash, kw_verilogHashHash, kw_apostrophe);

1878 }

1879

1880 bool isVerilogWordOperator(const FormatToken &Tok) const {

1881 return Tok.isOneOf(kw_before, kw_intersect, kw_dist, kw_iff, kw_inside,

1882 kw_with);

1883 }

1884

1885 bool isVerilogIdentifier(const FormatToken &Tok) const {

1886 switch (Tok.Tok.getKind()) {

1887 case tok::kw_case:

1888 case tok::kw_class:

1889 case tok::kw_const:

1890 case tok::kw_continue:

1891 case tok::kw_default:

1892 case tok::kw_do:

1893 case tok::kw_else:

1894 case tok::kw_enum:

1895 case tok::kw_export:

1896 case tok::kw_extern:

1897 case tok::kw_for:

1898 case tok::kw_if:

1899 case tok::kw_import:

1900 case tok::kw_restrict:

1901 case tok::kw_signed:

1902 case tok::kw_static:

1903 case tok::kw_struct:

1904 case tok::kw_typedef:

1905 case tok::kw_union:

1906 case tok::kw_unsigned:

1907 case tok::kw_virtual:

1908 case tok::kw_while:

1909 return false;

1910 case tok::identifier:

1912 VerilogExtraKeywords.find(Tok.Tok.getIdentifierInfo()) ==

1913 VerilogExtraKeywords.end();

1914 default:

1915

1916 return Tok.Tok.getIdentifierInfo();

1917 }

1918 }

1919

1920

1921

1922

1923 bool isVerilogPPDirective(const FormatToken &Tok) const {

1924 auto Info = Tok.Tok.getIdentifierInfo();

1925 if (!Info)

1926 return false;

1927 switch (Info->getPPKeywordID()) {

1928 case tok::pp_define:

1929 case tok::pp_else:

1930 case tok::pp_endif:

1931 case tok::pp_ifdef:

1932 case tok::pp_ifndef:

1933 case tok::pp_include:

1934 case tok::pp_line:

1935 case tok::pp_pragma:

1936 case tok::pp_undef:

1937 return true;

1947 }

1948

1949

1951

1953 return true;

1955 return false;

1956 const auto *Prev = Tok.getPreviousNonComment();

1958 }

1959

1960

1970 }

1971

1972

1973 bool isVerilogHierarchy(const FormatToken &Tok) const {

1974 if (Tok.endsSequence(kw_function, kw_with))

1975 return false;

1977 const FormatToken *Prev = Tok.getPreviousNonComment();

1978 return !(Prev &&

1980 }

1981 return Tok.isOneOf(tok::kw_case, tok::kw_class, kw_function, kw_module,

1982 kw_interface, kw_package, kw_casex, kw_casez, kw_checker,

1983 kw_clocking, kw_covergroup, kw_macromodule, kw_primitive,

1984 kw_program, kw_property, kw_randcase, kw_randsequence,

1985 kw_task);

1986 }

1991 return Tok.is(TT_CaseLabelColon) ||

1992 (Tok.is(tok::kw_default) &&

1995 }

1996

1997

1998

1999 bool isVerilogStructuredProcedure(const FormatToken &Tok) const {

2000 return Tok.isOneOf(kw_always, kw_always_comb, kw_always_ff, kw_always_latch,

2001 kw_final, kw_forever, kw_initial);

2002 }

2003

2004 bool isVerilogQualifier(const FormatToken &Tok) const {

2005 switch (Tok.Tok.getKind()) {

2006 case tok::kw_extern:

2007 case tok::kw_signed:

2008 case tok::kw_static:

2009 case tok::kw_unsigned:

2010 case tok::kw_virtual:

2011 return true;

2012 case tok::identifier:

2020 default:

2021 return false;

2022 }

2023 }

2024

2025 bool isTableGenDefinition(const FormatToken &Tok) const {

2026 return Tok.isOneOf(kw_def, kw_defm, kw_defset, kw_defvar, kw_multiclass,

2027 kw_let, tok::kw_class);

2028 }

2029

2030 bool isTableGenKeyword(const FormatToken &Tok) const {

2031 switch (Tok.Tok.getKind()) {

2032 case tok::kw_class:

2033 case tok::kw_else:

2034 case tok::kw_false:

2035 case tok::kw_if:

2036 case tok::kw_int:

2037 case tok::kw_true:

2038 return true;

2039 default:

2040 return Tok.is(tok::identifier) &&

2041 TableGenExtraKeywords.find(Tok.Tok.getIdentifierInfo()) !=

2042 TableGenExtraKeywords.end();

2043 }

2044 }

2045

2046private:

2047

2048 std::unordered_set<IdentifierInfo *> JsExtraKeywords;

2049

2050

2051 std::unordered_set<IdentifierInfo *> CSharpExtraKeywords;

2052

2053

2054 std::unordered_set<IdentifierInfo *> VerilogExtraKeywords;

2056

2057 std::unordered_set<IdentifierInfo *> TableGenExtraKeywords;

2058};

2059

2061 return FormatTok.is(tok::comment) && !FormatTok.TokenText.starts_with("/*");

2062}

2063

2064

2065

2066

2070 if (Previous || !MinColumnToken)

2071 return false;

2072 unsigned MinContinueColumn =

2073 MinColumnToken->OriginalColumn + (isLineComment(*MinColumnToken) ? 0 : 1);

2074 return isLineComment(FormatTok) && FormatTok.NewlinesBefore == 1 &&

2076 FormatTok.OriginalColumn >= MinContinueColumn;

2077}

2078

2079

2081

2082}

2083}

2084

2085#endif

#define LIST_TOKEN_TYPES

Definition FormatToken.h:27

FormatToken()

Definition FormatToken.h:852

Token Tok

The Token.

Definition FormatToken.h:865

std::optional< MacroExpansion > MacroCtx

Definition FormatToken.h:1158

FormatToken * MatchingParen

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

Definition FormatToken.h:1117

SourceRange WhitespaceRange

The range of the whitespace immediately preceding the Token.

Definition FormatToken.h:880

FormatToken * Previous

The previous token in the unwrapped line.

Definition FormatToken.h:1120

FormatToken * Next

The next token in the unwrapped line.

Definition FormatToken.h:1123

Various functions to configurably format source code.

Defines the clang::IdentifierInfo, clang::IdentifierTable, and clang::Selector interfaces.

Defines and computes precedence levels for binary/ternary operators.

static unsigned getPrecedence(tok::TokenKind Kind)

getPrecedence - Return the precedence of the specified binary operator token.

static constexpr bool isOneOf()

#define TRANSFORM_TYPE_TRAIT_DEF(Enum, _)

void CommaFound(const FormatToken *Token) override

Adds Token as the next comma to the CommaSeparated list.

Definition FormatToken.h:997

CommaSeparatedList(const FormatStyle &Style)

Definition FormatToken.h:985

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...

One of these records is kept for each identifier that is lexed.

A trivial tuple used to represent a source range.

Definition FormatToken.h:945

virtual void precomputeFormattingInfos(const FormatToken *Token)

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

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

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

Definition FormatToken.h:968

TokenRole(const FormatStyle &Style)

Definition FormatToken.h:947

const FormatStyle & Style

Definition FormatToken.h:980

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

The base class of the type hierarchy.

const FormatToken * getNamespaceToken() const

Return the actual namespace token, if this token starts a namespace block.

Definition FormatToken.h:895

const char * getTokenTypeName(TokenType Type)

Determines the name of a token type.

MacroRole

Roles a token can take in a configured macro expansion.

Definition FormatToken.h:241

@ MR_UnexpandedArg

The token is part of a macro argument that was previously formatted as expansion when formatting the ...

Definition FormatToken.h:247

@ MR_Hidden

The token was expanded from a macro definition, and is not visible as part of the macro call.

Definition FormatToken.h:250

@ MR_ExpandedArg

The token was expanded from a macro argument when formatting the expanded token sequence.

Definition FormatToken.h:244

bool closesBlockOrBlockTypeList(const FormatStyle &Style) const

Same as opensBlockOrBlockTypeList, but for the closing token.

Definition FormatToken.h:887

FormatDecision

Definition FormatToken.h:238

@ FD_Break

Definition FormatToken.h:238

@ FD_Unformatted

Definition FormatToken.h:238

@ FD_Continue

Definition FormatToken.h:238

void copyFrom(const FormatToken &Tok)

Definition FormatToken.h:908

ParameterPackingKind

Definition FormatToken.h:236

@ PPK_BinPacked

Definition FormatToken.h:236

@ PPK_Inconclusive

Definition FormatToken.h:236

@ PPK_OnePerLine

Definition FormatToken.h:236

struct clang::format::FormatToken getPreviousNonComment() const

Returns the previous token ignoring comments.

Definition FormatToken.h:851

bool isBlockIndentedInitRBrace(const FormatStyle &Style) const

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

bool opensBlockOrBlockTypeList(const FormatStyle &Style) const

Returns true if this tokens starts a block-type list, i.e. a list that should be indented with a bloc...

bool isCppStructuredBinding(bool IsCpp) const

Returns whether the token is the left square bracket of a C++ structured binding declaration.

Definition FormatToken.h:875

TokenType

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

Definition FormatToken.h:222

@ NUM_TOKEN_TYPES

Definition FormatToken.h:226

FormatToken * getNextNonComment() const

Returns the next token ignoring comments.

Definition FormatToken.h:859

BraceBlockKind

Definition FormatToken.h:233

@ BK_Unknown

Definition FormatToken.h:233

@ BK_Block

Definition FormatToken.h:233

@ BK_BracedInit

Definition FormatToken.h:233

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

bool isStringLiteral(TokenKind K)

Return true if this is a C or C++ string-literal (or C++11 user-defined-string-literal) token.

ObjCKeywordKind

Provides a namespace for Objective-C keywords which start with an '@'.

TokenKind

Provides a simple uniform namespace for tokens from all C languages.

PPKeywordKind

Provides a namespace for preprocessor keywords which start with a '#' at the beginning of the line.

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

bool isLineComment(const FormatToken &FormatTok)

Definition FormatToken.h:2048

const FunctionProtoType * T

prec::Level getBinOpPrecedence(tok::TokenKind Kind, bool GreaterThanIsOperator, bool CPlusPlus11)

Return the precedence of the specified binary operator token.

bool continuesLineComment(const FormatToken &FormatTok, const FormatToken *Previous, const FormatToken *MinColumnToken)

Definition FormatToken.h:2055

IdentifierInfo * kw_signals

Definition FormatToken.h:1535

IdentifierInfo * kw_celldefine

Definition FormatToken.h:1592

IdentifierInfo * kw_delay_mode_distributed

Definition FormatToken.h:1603

IdentifierInfo * kw_pull0

Definition FormatToken.h:1665

IdentifierInfo * kw_instanceof

Definition FormatToken.h:1514

IdentifierInfo * kw_readonly

Definition FormatToken.h:1502

IdentifierInfo * kw___has_include

Definition FormatToken.h:1485

IdentifierInfo * kw_supply1

Definition FormatToken.h:1685

IdentifierInfo * kw_sealed

Definition FormatToken.h:1568

IdentifierInfo * kw_implements

Definition FormatToken.h:1513

IdentifierInfo * kw_infer

Definition FormatToken.h:1498

IdentifierInfo * kw_output

Definition FormatToken.h:1657

IdentifierInfo * kw_join

Definition FormatToken.h:1646

IdentifierInfo * kw_sbyte

Definition FormatToken.h:1567

IdentifierInfo * kw_override

Definition FormatToken.h:1474

IdentifierInfo * kw_always

Definition FormatToken.h:1578

IdentifierInfo * kw_endchecker

Definition FormatToken.h:1615

IdentifierInfo * kw___except

Definition FormatToken.h:1484

IdentifierInfo * kw_unchecked

Definition FormatToken.h:1571

IdentifierInfo * kw_vectored

Definition FormatToken.h:1701

IdentifierInfo * kw_specparam

Definition FormatToken.h:1681

IdentifierInfo * kw_decimal

Definition FormatToken.h:1548

IdentifierInfo * kw_default_decay_time

Definition FormatToken.h:1600

IdentifierInfo * kw_binsof

Definition FormatToken.h:1589

IdentifierInfo * kw_extend

Definition FormatToken.h:1527

IdentifierInfo * kw_await

Definition FormatToken.h:1491

IdentifierInfo * kw_def

Definition FormatToken.h:1723

IdentifierInfo * kw_extends

Definition FormatToken.h:1512

IdentifierInfo * kw_base

Definition FormatToken.h:1545

IdentifierInfo * kw_coverpoint

Definition FormatToken.h:1599

IdentifierInfo * kw_begin_keywords

Definition FormatToken.h:1587

IdentifierInfo * kw_is

Definition FormatToken.h:1499

IdentifierInfo * kw_assert

Definition FormatToken.h:1511

IdentifierInfo * kw_as

Definition FormatToken.h:1489

IdentifierInfo * kw_async

Definition FormatToken.h:1490

IdentifierInfo * kw_CF_ENUM

Definition FormatToken.h:1478

IdentifierInfo * kw_qslots

Definition FormatToken.h:1538

IdentifierInfo * kw_null

Definition FormatToken.h:1558

IdentifierInfo * kw_nounconnected_drive

Definition FormatToken.h:1656

IdentifierInfo * kw_trireg

Definition FormatToken.h:1695

IdentifierInfo * kw_join_any

Definition FormatToken.h:1647

IdentifierInfo * kw_from

Definition FormatToken.h:1494

IdentifierInfo * kw_solve

Definition FormatToken.h:1679

IdentifierInfo * kw_abstract

Definition FormatToken.h:1510

IdentifierInfo * kw_default_nettype

Definition FormatToken.h:1601

IdentifierInfo * kw_task

Definition FormatToken.h:1688

IdentifierInfo * kw_ifnone

Definition FormatToken.h:1637

IdentifierInfo * kw_highz1

Definition FormatToken.h:1635

IdentifierInfo * kw_unique0

Definition FormatToken.h:1699

IdentifierInfo * kw_input

Definition FormatToken.h:1642

IdentifierInfo * kw_randc

Definition FormatToken.h:1669

IdentifierInfo * kw_always_ff

Definition FormatToken.h:1580

IdentifierInfo * kw_byte

Definition FormatToken.h:1546

IdentifierInfo * kw_medium

Definition FormatToken.h:1654

IdentifierInfo * kw_weak0

Definition FormatToken.h:1704

IdentifierInfo * kw_undefineall

Definition FormatToken.h:1697

IdentifierInfo * kw_sequence

Definition FormatToken.h:1676

IdentifierInfo * kw_event

Definition FormatToken.h:1550

IdentifierInfo * kw_foreach

Definition FormatToken.h:1552

IdentifierInfo * kw_apostrophe

Definition FormatToken.h:1716

IdentifierInfo * kw_weak1

Definition FormatToken.h:1705

IdentifierInfo * kw_program

Definition FormatToken.h:1663

IdentifierInfo * kw_required

Definition FormatToken.h:1531

IdentifierInfo * kw_fixed

Definition FormatToken.h:1551

IdentifierInfo * kw_assign

Definition FormatToken.h:1582

IdentifierInfo * kw_dist

Definition FormatToken.h:1608

IdentifierInfo * kw_var

Definition FormatToken.h:1506

IdentifierInfo * kw_initial

Definition FormatToken.h:1640

IdentifierInfo * kw_macromodule

Definition FormatToken.h:1652

IdentifierInfo * kw_code

Definition FormatToken.h:1721

bool isVerilogKeywordSymbol(const FormatToken &Tok) const

Definition FormatToken.h:1864

IdentifierInfo * kw_ref

Definition FormatToken.h:1564

IdentifierInfo * kw_property

Definition FormatToken.h:1664

bool isVerilogBegin(const FormatToken &Tok) const

Returns whether Tok is a Verilog keyword that opens a block.

Definition FormatToken.h:1938

IdentifierInfo * kw_CF_OPTIONS

Definition FormatToken.h:1479

IdentifierInfo * kw_tagged

Definition FormatToken.h:1687

IdentifierInfo * kw_interface

Definition FormatToken.h:1515

IdentifierInfo * kw_before

Definition FormatToken.h:1585

IdentifierInfo * kw_local

Definition FormatToken.h:1650

IdentifierInfo * kw___has_include_next

Definition FormatToken.h:1486

IdentifierInfo * kw_tri

Definition FormatToken.h:1692

IdentifierInfo * kw_synchronized

Definition FormatToken.h:1519

IdentifierInfo * kw_params

Definition FormatToken.h:1562

IdentifierInfo * kw_endtable

Definition FormatToken.h:1629

IdentifierInfo * kw_endpackage

Definition FormatToken.h:1623

IdentifierInfo * kw_function

Definition FormatToken.h:1495

IdentifierInfo * kw_list

Definition FormatToken.h:1729

IdentifierInfo * kw_yield

Definition FormatToken.h:1507

IdentifierInfo * kw_automatic

Definition FormatToken.h:1584

IdentifierInfo * kw_declare

Definition FormatToken.h:1492

IdentifierInfo * kw_endcelldefine

Definition FormatToken.h:1614

IdentifierInfo * kw_checker

Definition FormatToken.h:1593

IdentifierInfo * kw_verilogHash

Definition FormatToken.h:1712

IdentifierInfo * kw_multiclass

Definition FormatToken.h:1730

IdentifierInfo * kw_internal

Definition FormatToken.h:1555

IdentifierInfo * kw_soft

Definition FormatToken.h:1678

IdentifierInfo * kw_returns

Definition FormatToken.h:1532

IdentifierInfo * kw_supply0

Definition FormatToken.h:1684

IdentifierInfo * kw_when

Definition FormatToken.h:1574

IdentifierInfo * kw_large

Definition FormatToken.h:1649

IdentifierInfo * kw_endclocking

Definition FormatToken.h:1617

IdentifierInfo * kw_endfunction

Definition FormatToken.h:1618

IdentifierInfo * kw_endprimitive

Definition FormatToken.h:1624

IdentifierInfo * kw_implicit

Definition FormatToken.h:1553

IdentifierInfo * kw_where

Definition FormatToken.h:1575

IdentifierInfo * kw_randcase

Definition FormatToken.h:1670

IdentifierInfo * kw_rand

Definition FormatToken.h:1668

IdentifierInfo * kw_NS_OPTIONS

Definition FormatToken.h:1483

IdentifierInfo * kw_triand

Definition FormatToken.h:1693

IdentifierInfo * kw_inside

Definition FormatToken.h:1643

IdentifierInfo * kw_defm

Definition FormatToken.h:1724

bool isVerilogEndOfLabel(const FormatToken &Tok) const

Definition FormatToken.h:1976

IdentifierInfo * kw_native

Definition FormatToken.h:1516

IdentifierInfo * kw_get

Definition FormatToken.h:1496

IdentifierInfo * kw_clocking

Definition FormatToken.h:1594

IdentifierInfo * kw_of

Definition FormatToken.h:1476

IdentifierInfo * kw_typeof

Definition FormatToken.h:1505

IdentifierInfo * kw_join_none

Definition FormatToken.h:1648

IdentifierInfo * kw_wand

Definition FormatToken.h:1703

IdentifierInfo * kw_endcase

Definition FormatToken.h:1613

IdentifierInfo * kw_intersect

Definition FormatToken.h:1645

IdentifierInfo * kw_include

Definition FormatToken.h:1728

IdentifierInfo * kw_tri0

Definition FormatToken.h:1690

IdentifierInfo * kw_then

Definition FormatToken.h:1731

IdentifierInfo * kw_primitive

Definition FormatToken.h:1661

IdentifierInfo * kw_record

Definition FormatToken.h:1518

IdentifierInfo * kw_string

Definition FormatToken.h:1565

IdentifierInfo * kw_begin

Definition FormatToken.h:1586

IdentifierInfo * kw_throws

Definition FormatToken.h:1520

IdentifierInfo * kw_slots

Definition FormatToken.h:1537

IdentifierInfo * kw_elsif

Definition FormatToken.h:1609

IdentifierInfo * kw_NS_ENUM

Definition FormatToken.h:1481

IdentifierInfo * kw_end

Definition FormatToken.h:1611

IdentifierInfo * kw_set

Definition FormatToken.h:1503

IdentifierInfo * kw_parameter

Definition FormatToken.h:1659

IdentifierInfo * kw_fork

Definition FormatToken.h:1632

IdentifierInfo * kw_endtask

Definition FormatToken.h:1630

IdentifierInfo * kw_NS_CLOSED_ENUM

Definition FormatToken.h:1480

IdentifierInfo * kw_mark

Definition FormatToken.h:1523

IdentifierInfo * kw_unconnected_drive

Definition FormatToken.h:1696

IdentifierInfo * kw_option

Definition FormatToken.h:1528

IdentifierInfo * kw_negedge

Definition FormatToken.h:1655

IdentifierInfo * kw_unique

Definition FormatToken.h:1698

IdentifierInfo * kw_wire

Definition FormatToken.h:1707

IdentifierInfo * kw_timescale

Definition FormatToken.h:1689

IdentifierInfo * kw_package

Definition FormatToken.h:1517

IdentifierInfo * kw_generate

Definition FormatToken.h:1633

IdentifierInfo * kw_constraint

Definition FormatToken.h:1595

IdentifierInfo * kw_endprogram

Definition FormatToken.h:1625

IdentifierInfo * kw_iff

Definition FormatToken.h:1636

IdentifierInfo * kw_delay_mode_unit

Definition FormatToken.h:1605

IdentifierInfo * kw_always_comb

Definition FormatToken.h:1579

IdentifierInfo * kw_in

Definition FormatToken.h:1475

IdentifierInfo * kw_module

Definition FormatToken.h:1501

IdentifierInfo * kw_stackalloc

Definition FormatToken.h:1566

IdentifierInfo * kw_bins

Definition FormatToken.h:1588

IdentifierInfo * kw_delay_mode_path

Definition FormatToken.h:1604

IdentifierInfo * kw_let

Definition FormatToken.h:1500

bool isWordLike(const FormatToken &Tok, bool IsVerilog=true) const

Returns true if Tok is a keyword or an identifier.

Definition FormatToken.h:1734

IdentifierInfo * kw_trior

Definition FormatToken.h:1694

IdentifierInfo * kw_qsignals

Definition FormatToken.h:1536

IdentifierInfo * kw_dump

Definition FormatToken.h:1727

IdentifierInfo * kw_specify

Definition FormatToken.h:1680

IdentifierInfo * kw_out

Definition FormatToken.h:1560

IdentifierInfo * kw_endproperty

Definition FormatToken.h:1626

IdentifierInfo * kw_endclass

Definition FormatToken.h:1616

IdentifierInfo * kw_uint

Definition FormatToken.h:1569

IdentifierInfo * kw_internal_ident_after_define

Definition FormatToken.h:1541

IdentifierInfo * kw_randsequence

Definition FormatToken.h:1671

IdentifierInfo * kw_checked

Definition FormatToken.h:1547

IdentifierInfo * kw_endmodule

Definition FormatToken.h:1622

IdentifierInfo * kw_ulong

Definition FormatToken.h:1570

IdentifierInfo * kw_casex

Definition FormatToken.h:1590

IdentifierInfo * kw_defvar

Definition FormatToken.h:1726

IdentifierInfo * kw_scalared

Definition FormatToken.h:1675

IdentifierInfo * kw_strong1

Definition FormatToken.h:1683

IdentifierInfo * kw_wor

Definition FormatToken.h:1709

IdentifierInfo * kw_wait

Definition FormatToken.h:1702

IdentifierInfo * kw_delegate

Definition FormatToken.h:1549

IdentifierInfo * kw_ignore_bins

Definition FormatToken.h:1638

IdentifierInfo * kw_type

Definition FormatToken.h:1504

IdentifierInfo * kw_lock

Definition FormatToken.h:1557

IdentifierInfo * kw_small

Definition FormatToken.h:1677

IdentifierInfo * kw_cover

Definition FormatToken.h:1597

IdentifierInfo * kw_disable

Definition FormatToken.h:1607

IdentifierInfo * kw_always_latch

Definition FormatToken.h:1581

IdentifierInfo * kw_final

Definition FormatToken.h:1473

IdentifierInfo * kw_posedge

Definition FormatToken.h:1660

IdentifierInfo * kw_region

Definition FormatToken.h:1524

IdentifierInfo * kw_wildcard

Definition FormatToken.h:1706

IdentifierInfo * kw_with

Definition FormatToken.h:1708

IdentifierInfo * kw_bits

Definition FormatToken.h:1720

IdentifierInfo * kw_edge

Definition FormatToken.h:1610

IdentifierInfo * kw_forever

Definition FormatToken.h:1631

IdentifierInfo * kw_optional

Definition FormatToken.h:1529

IdentifierInfo * kw_default_trireg_strength

Definition FormatToken.h:1602

IdentifierInfo * kw_assume

Definition FormatToken.h:1583

IdentifierInfo * kw_dollar

Definition FormatToken.h:1544

IdentifierInfo * kw_verilogHashHash

Definition FormatToken.h:1713

IdentifierInfo * kw_casez

Definition FormatToken.h:1591

IdentifierInfo * kw_init

Definition FormatToken.h:1554

IdentifierInfo * kw_pure

Definition FormatToken.h:1667

IdentifierInfo * kw_dag

Definition FormatToken.h:1722

IdentifierInfo * kw_endgroup

Definition FormatToken.h:1620

IdentifierInfo * kw_delay_mode_zero

Definition FormatToken.h:1606

IdentifierInfo * kw_strong0

Definition FormatToken.h:1682

IdentifierInfo * kw_illegal_bins

Definition FormatToken.h:1639

IdentifierInfo * kw_priority

Definition FormatToken.h:1662

IdentifierInfo * kw_ushort

Definition FormatToken.h:1573

IdentifierInfo * kw_localparam

Definition FormatToken.h:1651

IdentifierInfo * kw_object

Definition FormatToken.h:1559

IdentifierInfo * kw_context

Definition FormatToken.h:1596

IdentifierInfo * kw_endsequence

Definition FormatToken.h:1627

IdentifierInfo * kw_inout

Definition FormatToken.h:1641

IdentifierInfo * kw_defset

Definition FormatToken.h:1725

IdentifierInfo * kw_end_keywords

Definition FormatToken.h:1612

IdentifierInfo * kw_matches

Definition FormatToken.h:1653

IdentifierInfo * kw_uwire

Definition FormatToken.h:1700

IdentifierInfo * kw_endspecify

Definition FormatToken.h:1628

IdentifierInfo * kw_CF_CLOSED_ENUM

Definition FormatToken.h:1477

IdentifierInfo * kw_sample

Definition FormatToken.h:1674

IdentifierInfo * kw_packed

Definition FormatToken.h:1658

IdentifierInfo * kw_unsafe

Definition FormatToken.h:1572

IdentifierInfo * kw_interconnect

Definition FormatToken.h:1644

IdentifierInfo * kw_tri1

Definition FormatToken.h:1691

IdentifierInfo * kw_pull1

Definition FormatToken.h:1666

IdentifierInfo * kw_NS_ERROR_ENUM

Definition FormatToken.h:1482

IdentifierInfo * kw_covergroup

Definition FormatToken.h:1598

IdentifierInfo * kw_repeat

Definition FormatToken.h:1672

bool isVerilogEnd(const FormatToken &Tok) const

Returns whether Tok is a Verilog keyword that closes a block.

Definition FormatToken.h:1949

IdentifierInfo * kw_endinterface

Definition FormatToken.h:1621

IdentifierInfo * kw_highz0

Definition FormatToken.h:1634

IdentifierInfo * kw_repeated

Definition FormatToken.h:1530

IdentifierInfo * kw_endgenerate

Definition FormatToken.h:1619

IdentifierInfo * kw_bit

Definition FormatToken.h:1719

IdentifierInfo * kw_table

Definition FormatToken.h:1686

IdentifierInfo * kw_import

Definition FormatToken.h:1497

IdentifierInfo * kw_resetall

Definition FormatToken.h:1673

IdentifierInfo * kw_finally

Definition FormatToken.h:1493

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

Definition FormatToken.h:307

unsigned NestingLevel

The nesting level of this token, i.e.

Definition FormatToken.h:530

unsigned MustBreakBeforeFinalized

Whether MustBreakBefore is finalized during parsing and must not be reset between runs.

Definition FormatToken.h:356

unsigned FakeRParens

Insert this many fake ) after this token for correct indentation.

Definition FormatToken.h:562

bool ArrayInitializerLineStart

This notes the start of the line of an array initializer.

Definition FormatToken.h:585

bool isTypeFinalized() const

Definition FormatToken.h:467

bool Optional

Is optional and can be removed.

Definition FormatToken.h:591

bool MacroParent

When macro expansion introduces nodes with children, those are marked as MacroParent.

Definition FormatToken.h:623

bool is(ParameterPackingKind PPK) const

Definition FormatToken.h:638

int Newlines

The number of newlines immediately before the Token after formatting.

Definition FormatToken.h:482

SmallVector< AnnotatedLine *, 1 > Children

If this token starts a block, this contains all the unwrapped lines in it.

Definition FormatToken.h:610

bool closesScopeAfterBlock() const

Definition FormatToken.h:663

prec::Level ForcedPrecedence

Used to set an operator precedence explicitly.

Definition FormatToken.h:470

unsigned BindingStrength

The binding strength of a token.

Definition FormatToken.h:526

unsigned StartsBinaryExpression

true if this token starts a binary expression, i.e.

Definition FormatToken.h:369

void setPackingKind(ParameterPackingKind K)

Definition FormatToken.h:428

unsigned ClosesTemplateDeclaration

true if this is the ">" of "template<..>".

Definition FormatToken.h:365

unsigned OperatorIndex

If this is an operator (or "."/"->") in a sequence of operators with the same precedence,...

Definition FormatToken.h:566

bool MightBeFunctionDeclParen

Might be function declaration open/closing paren.

Definition FormatToken.h:594

unsigned OriginalColumn

The original 0-based column of this token, including expanded tabs.

Definition FormatToken.h:517

unsigned ContinuesLineCommentSection

Does this line comment continue a line comment section?

Definition FormatToken.h:381

unsigned CanBreakBefore

true if it is allowed to break before this token.

Definition FormatToken.h:362

bool isNot(T Kind) const

Definition FormatToken.h:647

StringRef TokenText

The raw text of the token.

Definition FormatToken.h:327

unsigned LongestObjCSelectorName

If this is the first ObjC selector name in an ObjC method definition or call, this contains the lengt...

Definition FormatToken.h:543

ParameterPackingKind getPackingKind() const

Definition FormatToken.h:425

tok::TokenKind ParentBracket

If this is a bracket ("<", "(", "[" or "{"), contains the kind of the surrounding bracket.

Definition FormatToken.h:509

unsigned LastNewlineOffset

The offset just past the last ' ' in this token's leading whitespace (relative to WhiteSpaceStart).

Definition FormatToken.h:486

unsigned SplitPenalty

Penalty for inserting a line break before this token.

Definition FormatToken.h:536

void setDecision(FormatDecision D)

Definition FormatToken.h:415

SmallVector< prec::Level, 4 > FakeLParens

Stores the number of required fake parentheses and the corresponding operator precedence.

Definition FormatToken.h:560

unsigned Finalized

If true, this token has been fully formatted (indented and potentially re-formatted inside),...

Definition FormatToken.h:386

std::optional< MacroExpansion > MacroCtx

Definition FormatToken.h:614

BraceBlockKind getBlockKind() const

Definition FormatToken.h:399

bool isNoneOf(Ts... Ks) const

Definition FormatToken.h:648

FormatToken * Next

The next token in the unwrapped line.

Definition FormatToken.h:579

unsigned IsMultiline

Whether the token text contains newlines (escaped or not).

Definition FormatToken.h:343

unsigned EndsCppAttributeGroup

true if this token ends a group of C++ attributes.

Definition FormatToken.h:392

unsigned NewlinesBefore

The number of newlines immediately before the Token.

Definition FormatToken.h:476

void setBlockKind(BraceBlockKind BBK)

Definition FormatToken.h:402

bool isIf(bool AllowConstexprMacro=true) const

Definition FormatToken.h:652

unsigned SpacesRequiredBefore

The number of spaces that should be inserted before this token.

Definition FormatToken.h:498

std::shared_ptr< TokenRole > Role

A token can have a special role that can carry extra information about the token's formatting.

Definition FormatToken.h:333

unsigned MustBreakBefore

Whether there must be a line break before this token.

Definition FormatToken.h:352

unsigned HasUnescapedNewline

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

Definition FormatToken.h:340

unsigned PartOfMultiVariableDeclStmt

Is this token part of a DeclStmt defining multiple variables?

Definition FormatToken.h:376

unsigned ColumnWidth

The width of the non-whitespace parts of the token (or its first line for multi-line tokens) in colum...

Definition FormatToken.h:491

unsigned ObjCSelectorNameParts

If this is the first ObjC selector name in an ObjC method definition or call, this contains the numbe...

Definition FormatToken.h:548

bool FirstAfterPPLine

Is the first token after a preprocessor line.

Definition FormatToken.h:600

void setType(TokenType T)

Definition FormatToken.h:441

bool HasFormFeedBefore

Has "\n\f\n" or "\n\f\r\n" before TokenText.

Definition FormatToken.h:597

bool IsArrayInitializer

This starts an array initializer.

Definition FormatToken.h:588

unsigned EndsBinaryExpression

true if this token ends a binary expression.

Definition FormatToken.h:371

unsigned UnbreakableTailLength

The length of following tokens until the next natural split point, or the next token that can be brok...

Definition FormatToken.h:521

FormatDecision getDecision() const

Definition FormatToken.h:412

bool is(tok::TokenKind Kind) const

Definition FormatToken.h:625

unsigned LastLineColumnWidth

Contains the width in columns of the last line of a multi-line token.

Definition FormatToken.h:495

unsigned IndentLevel

The indent level of this token. Copied from the surrounding line.

Definition FormatToken.h:533

unsigned BlockParameterCount

Number of parameters that are nested blocks, if this is "(", "[" or "<".

Definition FormatToken.h:505

FormatToken()

Definition FormatToken.h:308

unsigned TotalLength

The total length of the unwrapped line up to and including this token.

Definition FormatToken.h:513

bool isOneOf(A K1, B K2) const

Definition FormatToken.h:640

TokenType getType() const

Returns the token's type, e.g.

Definition FormatToken.h:440

unsigned IsFirst

Indicates that this is the first token of the file.

Definition FormatToken.h:346

bool is(BraceBlockKind BBK) const

Definition FormatToken.h:637

Token Tok

The Token.

Definition FormatToken.h:321

unsigned IsUnterminatedLiteral

Set to true if this token is an unterminated literal.

Definition FormatToken.h:359

unsigned ClosesRequiresClause

true if this is the last token within requires clause.

Definition FormatToken.h:389

unsigned ParameterIndex

The 0-based index of the parameter/argument.

Definition FormatToken.h:553

int8_t BraceCount

Number of optional braces to be inserted after this token: -1: a single left brace 0: no braces >0: n...

Definition FormatToken.h:606

unsigned ParameterCount

Number of parameters, if this is "(", "[" or "<".

Definition FormatToken.h:501

bool StartsColumn

The first token in set of column elements.

Definition FormatToken.h:582

SourceRange WhitespaceRange

The range of the whitespace immediately preceding the Token.

Definition FormatToken.h:336

FormatToken * NextOperator

If this is an operator (or "."/"->") in a sequence of operators with the same precedence,...

Definition FormatToken.h:570

bool isLoop(const FormatStyle &Style) const

Definition FormatToken.h:657

FormatToken * MatchingParen

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

Definition FormatToken.h:573

void overwriteFixedType(TokenType T)

Definition FormatToken.h:461

FormatToken * Previous

The previous token in the unwrapped line.

Definition FormatToken.h:576

void setFinalizedType(TokenType T)

Sets the type and also the finalized flag.

Definition FormatToken.h:455

llvm::SmallVector< FormatToken *, 1 > ExpandedFrom

The stack of macro call identifier tokens this token was expanded from.

Definition FormatToken.h:292

unsigned StartOfExpansion

The number of expansions of which this macro is the first entry.

Definition FormatToken.h:295

MacroExpansion(MacroRole Role)

Definition FormatToken.h:281

MacroRole Role

The token's role in the macro expansion.

Definition FormatToken.h:289

unsigned EndOfExpansion

The number of currently open expansions in ExpandedFrom this macro is the last token in.

Definition FormatToken.h:299