Format.h 136 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291
  1. #pragma once
  2. #ifdef __GNUC__
  3. #pragma GCC diagnostic push
  4. #pragma GCC diagnostic ignored "-Wunused-parameter"
  5. #endif
  6. //===--- Format.h - Format C++ code -----------------------------*- C++ -*-===//
  7. //
  8. // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
  9. // See https://llvm.org/LICENSE.txt for license information.
  10. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  11. //
  12. //===----------------------------------------------------------------------===//
  13. ///
  14. /// \file
  15. /// Various functions to configurably format source code.
  16. ///
  17. //===----------------------------------------------------------------------===//
  18. #ifndef LLVM_CLANG_FORMAT_FORMAT_H
  19. #define LLVM_CLANG_FORMAT_FORMAT_H
  20. #include "clang/Basic/LangOptions.h"
  21. #include "clang/Tooling/Core/Replacement.h"
  22. #include "clang/Tooling/Inclusions/IncludeStyle.h"
  23. #include "llvm/ADT/ArrayRef.h"
  24. #include "llvm/Support/Regex.h"
  25. #include "llvm/Support/SourceMgr.h"
  26. #include <system_error>
  27. namespace llvm {
  28. namespace vfs {
  29. class FileSystem;
  30. }
  31. } // namespace llvm
  32. namespace clang {
  33. namespace format {
  34. enum class ParseError {
  35. Success = 0,
  36. Error,
  37. Unsuitable,
  38. BinPackTrailingCommaConflict,
  39. InvalidQualifierSpecified,
  40. DuplicateQualifierSpecified,
  41. MissingQualifierType,
  42. MissingQualifierOrder
  43. };
  44. class ParseErrorCategory final : public std::error_category {
  45. public:
  46. const char *name() const noexcept override;
  47. std::string message(int EV) const override;
  48. };
  49. const std::error_category &getParseCategory();
  50. std::error_code make_error_code(ParseError e);
  51. /// The ``FormatStyle`` is used to configure the formatting to follow
  52. /// specific guidelines.
  53. struct FormatStyle {
  54. // If the BasedOn: was InheritParentConfig and this style needs the file from
  55. // the parent directories. It is not part of the actual style for formatting.
  56. // Thus the // instead of ///.
  57. bool InheritsParentConfig;
  58. /// The extra indent or outdent of access modifiers, e.g. ``public:``.
  59. /// \version 3.3
  60. int AccessModifierOffset;
  61. /// Different styles for aligning after open brackets.
  62. enum BracketAlignmentStyle : unsigned char {
  63. /// Align parameters on the open bracket, e.g.:
  64. /// \code
  65. /// someLongFunction(argument1,
  66. /// argument2);
  67. /// \endcode
  68. BAS_Align,
  69. /// Don't align, instead use ``ContinuationIndentWidth``, e.g.:
  70. /// \code
  71. /// someLongFunction(argument1,
  72. /// argument2);
  73. /// \endcode
  74. BAS_DontAlign,
  75. /// Always break after an open bracket, if the parameters don't fit
  76. /// on a single line, e.g.:
  77. /// \code
  78. /// someLongFunction(
  79. /// argument1, argument2);
  80. /// \endcode
  81. BAS_AlwaysBreak,
  82. /// Always break after an open bracket, if the parameters don't fit
  83. /// on a single line. Closing brackets will be placed on a new line.
  84. /// E.g.:
  85. /// \code
  86. /// someLongFunction(
  87. /// argument1, argument2
  88. /// )
  89. /// \endcode
  90. ///
  91. /// \warning
  92. /// Note: This currently only applies to parentheses.
  93. /// \endwarning
  94. BAS_BlockIndent,
  95. };
  96. /// If ``true``, horizontally aligns arguments after an open bracket.
  97. ///
  98. /// This applies to round brackets (parentheses), angle brackets and square
  99. /// brackets.
  100. /// \version 3.8
  101. BracketAlignmentStyle AlignAfterOpenBracket;
  102. /// Different style for aligning array initializers.
  103. enum ArrayInitializerAlignmentStyle {
  104. /// Align array column and left justify the columns e.g.:
  105. /// \code
  106. /// struct test demo[] =
  107. /// {
  108. /// {56, 23, "hello"},
  109. /// {-1, 93463, "world"},
  110. /// {7, 5, "!!" }
  111. /// };
  112. /// \endcode
  113. AIAS_Left,
  114. /// Align array column and right justify the columns e.g.:
  115. /// \code
  116. /// struct test demo[] =
  117. /// {
  118. /// {56, 23, "hello"},
  119. /// {-1, 93463, "world"},
  120. /// { 7, 5, "!!"}
  121. /// };
  122. /// \endcode
  123. AIAS_Right,
  124. /// Don't align array initializer columns.
  125. AIAS_None
  126. };
  127. /// if not ``None``, when using initialization for an array of structs
  128. /// aligns the fields into columns.
  129. /// \version 13
  130. ArrayInitializerAlignmentStyle AlignArrayOfStructures;
  131. /// Styles for alignment of consecutive tokens. Tokens can be assignment signs
  132. /// (see
  133. /// ``AlignConsecutiveAssignments``), bitfield member separators (see
  134. /// ``AlignConsecutiveBitFields``), names in declarations (see
  135. /// ``AlignConsecutiveDeclarations``) or macro definitions (see
  136. /// ``AlignConsecutiveMacros``).
  137. enum AlignConsecutiveStyle {
  138. ACS_None,
  139. ACS_Consecutive,
  140. ACS_AcrossEmptyLines,
  141. ACS_AcrossComments,
  142. ACS_AcrossEmptyLinesAndComments
  143. };
  144. /// Style of aligning consecutive macro definitions.
  145. ///
  146. /// ``Consecutive`` will result in formattings like:
  147. /// \code
  148. /// #define SHORT_NAME 42
  149. /// #define LONGER_NAME 0x007f
  150. /// #define EVEN_LONGER_NAME (2)
  151. /// #define foo(x) (x * x)
  152. /// #define bar(y, z) (y + z)
  153. /// \endcode
  154. ///
  155. /// Possible values:
  156. ///
  157. /// * ``ACS_None`` (in configuration: ``None``)
  158. /// Do not align macro definitions on consecutive lines.
  159. ///
  160. /// * ``ACS_Consecutive`` (in configuration: ``Consecutive``)
  161. /// Align macro definitions on consecutive lines. This will result in
  162. /// formattings like:
  163. /// \code
  164. /// #define SHORT_NAME 42
  165. /// #define LONGER_NAME 0x007f
  166. /// #define EVEN_LONGER_NAME (2)
  167. ///
  168. /// #define foo(x) (x * x)
  169. /// /* some comment */
  170. /// #define bar(y, z) (y + z)
  171. /// \endcode
  172. ///
  173. /// * ``ACS_AcrossEmptyLines`` (in configuration: ``AcrossEmptyLines``)
  174. /// Same as ACS_Consecutive, but also spans over empty lines, e.g.
  175. /// \code
  176. /// #define SHORT_NAME 42
  177. /// #define LONGER_NAME 0x007f
  178. /// #define EVEN_LONGER_NAME (2)
  179. ///
  180. /// #define foo(x) (x * x)
  181. /// /* some comment */
  182. /// #define bar(y, z) (y + z)
  183. /// \endcode
  184. ///
  185. /// * ``ACS_AcrossComments`` (in configuration: ``AcrossComments``)
  186. /// Same as ACS_Consecutive, but also spans over lines only containing
  187. /// comments, e.g.
  188. /// \code
  189. /// #define SHORT_NAME 42
  190. /// #define LONGER_NAME 0x007f
  191. /// #define EVEN_LONGER_NAME (2)
  192. ///
  193. /// #define foo(x) (x * x)
  194. /// /* some comment */
  195. /// #define bar(y, z) (y + z)
  196. /// \endcode
  197. ///
  198. /// * ``ACS_AcrossEmptyLinesAndComments``
  199. /// (in configuration: ``AcrossEmptyLinesAndComments``)
  200. ///
  201. /// Same as ACS_Consecutive, but also spans over lines only containing
  202. /// comments and empty lines, e.g.
  203. /// \code
  204. /// #define SHORT_NAME 42
  205. /// #define LONGER_NAME 0x007f
  206. /// #define EVEN_LONGER_NAME (2)
  207. ///
  208. /// #define foo(x) (x * x)
  209. /// /* some comment */
  210. /// #define bar(y, z) (y + z)
  211. /// \endcode
  212. /// \version 9
  213. AlignConsecutiveStyle AlignConsecutiveMacros;
  214. /// Style of aligning consecutive assignments.
  215. ///
  216. /// ``Consecutive`` will result in formattings like:
  217. /// \code
  218. /// int a = 1;
  219. /// int somelongname = 2;
  220. /// double c = 3;
  221. /// \endcode
  222. ///
  223. /// Possible values:
  224. ///
  225. /// * ``ACS_None`` (in configuration: ``None``)
  226. /// Do not align assignments on consecutive lines.
  227. ///
  228. /// * ``ACS_Consecutive`` (in configuration: ``Consecutive``)
  229. /// Align assignments on consecutive lines. This will result in
  230. /// formattings like:
  231. /// \code
  232. /// int a = 1;
  233. /// int somelongname = 2;
  234. /// double c = 3;
  235. ///
  236. /// int d = 3;
  237. /// /* A comment. */
  238. /// double e = 4;
  239. /// \endcode
  240. ///
  241. /// * ``ACS_AcrossEmptyLines`` (in configuration: ``AcrossEmptyLines``)
  242. /// Same as ACS_Consecutive, but also spans over empty lines, e.g.
  243. /// \code
  244. /// int a = 1;
  245. /// int somelongname = 2;
  246. /// double c = 3;
  247. ///
  248. /// int d = 3;
  249. /// /* A comment. */
  250. /// double e = 4;
  251. /// \endcode
  252. ///
  253. /// * ``ACS_AcrossComments`` (in configuration: ``AcrossComments``)
  254. /// Same as ACS_Consecutive, but also spans over lines only containing
  255. /// comments, e.g.
  256. /// \code
  257. /// int a = 1;
  258. /// int somelongname = 2;
  259. /// double c = 3;
  260. ///
  261. /// int d = 3;
  262. /// /* A comment. */
  263. /// double e = 4;
  264. /// \endcode
  265. ///
  266. /// * ``ACS_AcrossEmptyLinesAndComments``
  267. /// (in configuration: ``AcrossEmptyLinesAndComments``)
  268. ///
  269. /// Same as ACS_Consecutive, but also spans over lines only containing
  270. /// comments and empty lines, e.g.
  271. /// \code
  272. /// int a = 1;
  273. /// int somelongname = 2;
  274. /// double c = 3;
  275. ///
  276. /// int d = 3;
  277. /// /* A comment. */
  278. /// double e = 4;
  279. /// \endcode
  280. /// \version 3.8
  281. AlignConsecutiveStyle AlignConsecutiveAssignments;
  282. /// Style of aligning consecutive bit field.
  283. ///
  284. /// ``Consecutive`` will align the bitfield separators of consecutive lines.
  285. /// This will result in formattings like:
  286. /// \code
  287. /// int aaaa : 1;
  288. /// int b : 12;
  289. /// int ccc : 8;
  290. /// \endcode
  291. ///
  292. /// Possible values:
  293. ///
  294. /// * ``ACS_None`` (in configuration: ``None``)
  295. /// Do not align bit fields on consecutive lines.
  296. ///
  297. /// * ``ACS_Consecutive`` (in configuration: ``Consecutive``)
  298. /// Align bit fields on consecutive lines. This will result in
  299. /// formattings like:
  300. /// \code
  301. /// int aaaa : 1;
  302. /// int b : 12;
  303. /// int ccc : 8;
  304. ///
  305. /// int d : 2;
  306. /// /* A comment. */
  307. /// int ee : 3;
  308. /// \endcode
  309. ///
  310. /// * ``ACS_AcrossEmptyLines`` (in configuration: ``AcrossEmptyLines``)
  311. /// Same as ACS_Consecutive, but also spans over empty lines, e.g.
  312. /// \code
  313. /// int aaaa : 1;
  314. /// int b : 12;
  315. /// int ccc : 8;
  316. ///
  317. /// int d : 2;
  318. /// /* A comment. */
  319. /// int ee : 3;
  320. /// \endcode
  321. ///
  322. /// * ``ACS_AcrossComments`` (in configuration: ``AcrossComments``)
  323. /// Same as ACS_Consecutive, but also spans over lines only containing
  324. /// comments, e.g.
  325. /// \code
  326. /// int aaaa : 1;
  327. /// int b : 12;
  328. /// int ccc : 8;
  329. ///
  330. /// int d : 2;
  331. /// /* A comment. */
  332. /// int ee : 3;
  333. /// \endcode
  334. ///
  335. /// * ``ACS_AcrossEmptyLinesAndComments``
  336. /// (in configuration: ``AcrossEmptyLinesAndComments``)
  337. ///
  338. /// Same as ACS_Consecutive, but also spans over lines only containing
  339. /// comments and empty lines, e.g.
  340. /// \code
  341. /// int aaaa : 1;
  342. /// int b : 12;
  343. /// int ccc : 8;
  344. ///
  345. /// int d : 2;
  346. /// /* A comment. */
  347. /// int ee : 3;
  348. /// \endcode
  349. /// \version 11
  350. AlignConsecutiveStyle AlignConsecutiveBitFields;
  351. /// Style of aligning consecutive declarations.
  352. ///
  353. /// ``Consecutive`` will align the declaration names of consecutive lines.
  354. /// This will result in formattings like:
  355. /// \code
  356. /// int aaaa = 12;
  357. /// float b = 23;
  358. /// std::string ccc;
  359. /// \endcode
  360. ///
  361. /// Possible values:
  362. ///
  363. /// * ``ACS_None`` (in configuration: ``None``)
  364. /// Do not align bit declarations on consecutive lines.
  365. ///
  366. /// * ``ACS_Consecutive`` (in configuration: ``Consecutive``)
  367. /// Align declarations on consecutive lines. This will result in
  368. /// formattings like:
  369. /// \code
  370. /// int aaaa = 12;
  371. /// float b = 23;
  372. /// std::string ccc;
  373. ///
  374. /// int a = 42;
  375. /// /* A comment. */
  376. /// bool c = false;
  377. /// \endcode
  378. ///
  379. /// * ``ACS_AcrossEmptyLines`` (in configuration: ``AcrossEmptyLines``)
  380. /// Same as ACS_Consecutive, but also spans over empty lines, e.g.
  381. /// \code
  382. /// int aaaa = 12;
  383. /// float b = 23;
  384. /// std::string ccc;
  385. ///
  386. /// int a = 42;
  387. /// /* A comment. */
  388. /// bool c = false;
  389. /// \endcode
  390. ///
  391. /// * ``ACS_AcrossComments`` (in configuration: ``AcrossComments``)
  392. /// Same as ACS_Consecutive, but also spans over lines only containing
  393. /// comments, e.g.
  394. /// \code
  395. /// int aaaa = 12;
  396. /// float b = 23;
  397. /// std::string ccc;
  398. ///
  399. /// int a = 42;
  400. /// /* A comment. */
  401. /// bool c = false;
  402. /// \endcode
  403. ///
  404. /// * ``ACS_AcrossEmptyLinesAndComments``
  405. /// (in configuration: ``AcrossEmptyLinesAndComments``)
  406. ///
  407. /// Same as ACS_Consecutive, but also spans over lines only containing
  408. /// comments and empty lines, e.g.
  409. /// \code
  410. /// int aaaa = 12;
  411. /// float b = 23;
  412. /// std::string ccc;
  413. ///
  414. /// int a = 42;
  415. /// /* A comment. */
  416. /// bool c = false;
  417. /// \endcode
  418. /// \version 3.8
  419. AlignConsecutiveStyle AlignConsecutiveDeclarations;
  420. /// Different styles for aligning escaped newlines.
  421. enum EscapedNewlineAlignmentStyle : unsigned char {
  422. /// Don't align escaped newlines.
  423. /// \code
  424. /// #define A \
  425. /// int aaaa; \
  426. /// int b; \
  427. /// int dddddddddd;
  428. /// \endcode
  429. ENAS_DontAlign,
  430. /// Align escaped newlines as far left as possible.
  431. /// \code
  432. /// true:
  433. /// #define A \
  434. /// int aaaa; \
  435. /// int b; \
  436. /// int dddddddddd;
  437. ///
  438. /// false:
  439. /// \endcode
  440. ENAS_Left,
  441. /// Align escaped newlines in the right-most column.
  442. /// \code
  443. /// #define A \
  444. /// int aaaa; \
  445. /// int b; \
  446. /// int dddddddddd;
  447. /// \endcode
  448. ENAS_Right,
  449. };
  450. /// Options for aligning backslashes in escaped newlines.
  451. /// \version 5
  452. EscapedNewlineAlignmentStyle AlignEscapedNewlines;
  453. /// Different styles for aligning operands.
  454. enum OperandAlignmentStyle : unsigned char {
  455. /// Do not align operands of binary and ternary expressions.
  456. /// The wrapped lines are indented ``ContinuationIndentWidth`` spaces from
  457. /// the start of the line.
  458. OAS_DontAlign,
  459. /// Horizontally align operands of binary and ternary expressions.
  460. ///
  461. /// Specifically, this aligns operands of a single expression that needs
  462. /// to be split over multiple lines, e.g.:
  463. /// \code
  464. /// int aaa = bbbbbbbbbbbbbbb +
  465. /// ccccccccccccccc;
  466. /// \endcode
  467. ///
  468. /// When ``BreakBeforeBinaryOperators`` is set, the wrapped operator is
  469. /// aligned with the operand on the first line.
  470. /// \code
  471. /// int aaa = bbbbbbbbbbbbbbb
  472. /// + ccccccccccccccc;
  473. /// \endcode
  474. OAS_Align,
  475. /// Horizontally align operands of binary and ternary expressions.
  476. ///
  477. /// This is similar to ``AO_Align``, except when
  478. /// ``BreakBeforeBinaryOperators`` is set, the operator is un-indented so
  479. /// that the wrapped operand is aligned with the operand on the first line.
  480. /// \code
  481. /// int aaa = bbbbbbbbbbbbbbb
  482. /// + ccccccccccccccc;
  483. /// \endcode
  484. OAS_AlignAfterOperator,
  485. };
  486. /// If ``true``, horizontally align operands of binary and ternary
  487. /// expressions.
  488. /// \version 12
  489. OperandAlignmentStyle AlignOperands;
  490. /// If ``true``, aligns trailing comments.
  491. /// \code
  492. /// true: false:
  493. /// int a; // My comment a vs. int a; // My comment a
  494. /// int b = 2; // comment b int b = 2; // comment about b
  495. /// \endcode
  496. /// \version 3.7
  497. bool AlignTrailingComments;
  498. /// \brief If a function call or braced initializer list doesn't fit on a
  499. /// line, allow putting all arguments onto the next line, even if
  500. /// ``BinPackArguments`` is ``false``.
  501. /// \code
  502. /// true:
  503. /// callFunction(
  504. /// a, b, c, d);
  505. ///
  506. /// false:
  507. /// callFunction(a,
  508. /// b,
  509. /// c,
  510. /// d);
  511. /// \endcode
  512. /// \version 9
  513. bool AllowAllArgumentsOnNextLine;
  514. /// This option is **deprecated**. See ``NextLine`` of
  515. /// ``PackConstructorInitializers``.
  516. /// \version 9
  517. bool AllowAllConstructorInitializersOnNextLine;
  518. /// If the function declaration doesn't fit on a line,
  519. /// allow putting all parameters of a function declaration onto
  520. /// the next line even if ``BinPackParameters`` is ``false``.
  521. /// \code
  522. /// true:
  523. /// void myFunction(
  524. /// int a, int b, int c, int d, int e);
  525. ///
  526. /// false:
  527. /// void myFunction(int a,
  528. /// int b,
  529. /// int c,
  530. /// int d,
  531. /// int e);
  532. /// \endcode
  533. /// \version 3.3
  534. bool AllowAllParametersOfDeclarationOnNextLine;
  535. /// Allow short enums on a single line.
  536. /// \code
  537. /// true:
  538. /// enum { A, B } myEnum;
  539. ///
  540. /// false:
  541. /// enum {
  542. /// A,
  543. /// B
  544. /// } myEnum;
  545. /// \endcode
  546. /// \version 12
  547. bool AllowShortEnumsOnASingleLine;
  548. /// Different styles for merging short blocks containing at most one
  549. /// statement.
  550. enum ShortBlockStyle : unsigned char {
  551. /// Never merge blocks into a single line.
  552. /// \code
  553. /// while (true) {
  554. /// }
  555. /// while (true) {
  556. /// continue;
  557. /// }
  558. /// \endcode
  559. SBS_Never,
  560. /// Only merge empty blocks.
  561. /// \code
  562. /// while (true) {}
  563. /// while (true) {
  564. /// continue;
  565. /// }
  566. /// \endcode
  567. SBS_Empty,
  568. /// Always merge short blocks into a single line.
  569. /// \code
  570. /// while (true) {}
  571. /// while (true) { continue; }
  572. /// \endcode
  573. SBS_Always,
  574. };
  575. /// Dependent on the value, ``while (true) { continue; }`` can be put on a
  576. /// single line.
  577. /// \version 11
  578. ShortBlockStyle AllowShortBlocksOnASingleLine;
  579. /// If ``true``, short case labels will be contracted to a single line.
  580. /// \code
  581. /// true: false:
  582. /// switch (a) { vs. switch (a) {
  583. /// case 1: x = 1; break; case 1:
  584. /// case 2: return; x = 1;
  585. /// } break;
  586. /// case 2:
  587. /// return;
  588. /// }
  589. /// \endcode
  590. /// \version 3.6
  591. bool AllowShortCaseLabelsOnASingleLine;
  592. /// Different styles for merging short functions containing at most one
  593. /// statement.
  594. enum ShortFunctionStyle : unsigned char {
  595. /// Never merge functions into a single line.
  596. SFS_None,
  597. /// Only merge functions defined inside a class. Same as "inline",
  598. /// except it does not implies "empty": i.e. top level empty functions
  599. /// are not merged either.
  600. /// \code
  601. /// class Foo {
  602. /// void f() { foo(); }
  603. /// };
  604. /// void f() {
  605. /// foo();
  606. /// }
  607. /// void f() {
  608. /// }
  609. /// \endcode
  610. SFS_InlineOnly,
  611. /// Only merge empty functions.
  612. /// \code
  613. /// void f() {}
  614. /// void f2() {
  615. /// bar2();
  616. /// }
  617. /// \endcode
  618. SFS_Empty,
  619. /// Only merge functions defined inside a class. Implies "empty".
  620. /// \code
  621. /// class Foo {
  622. /// void f() { foo(); }
  623. /// };
  624. /// void f() {
  625. /// foo();
  626. /// }
  627. /// void f() {}
  628. /// \endcode
  629. SFS_Inline,
  630. /// Merge all functions fitting on a single line.
  631. /// \code
  632. /// class Foo {
  633. /// void f() { foo(); }
  634. /// };
  635. /// void f() { bar(); }
  636. /// \endcode
  637. SFS_All,
  638. };
  639. /// Dependent on the value, ``int f() { return 0; }`` can be put on a
  640. /// single line.
  641. /// \version 3.5
  642. ShortFunctionStyle AllowShortFunctionsOnASingleLine;
  643. /// Different styles for handling short if statements.
  644. enum ShortIfStyle : unsigned char {
  645. /// Never put short ifs on the same line.
  646. /// \code
  647. /// if (a)
  648. /// return;
  649. ///
  650. /// if (b)
  651. /// return;
  652. /// else
  653. /// return;
  654. ///
  655. /// if (c)
  656. /// return;
  657. /// else {
  658. /// return;
  659. /// }
  660. /// \endcode
  661. SIS_Never,
  662. /// Put short ifs on the same line only if there is no else statement.
  663. /// \code
  664. /// if (a) return;
  665. ///
  666. /// if (b)
  667. /// return;
  668. /// else
  669. /// return;
  670. ///
  671. /// if (c)
  672. /// return;
  673. /// else {
  674. /// return;
  675. /// }
  676. /// \endcode
  677. SIS_WithoutElse,
  678. /// Put short ifs, but not else ifs nor else statements, on the same line.
  679. /// \code
  680. /// if (a) return;
  681. ///
  682. /// if (b) return;
  683. /// else if (b)
  684. /// return;
  685. /// else
  686. /// return;
  687. ///
  688. /// if (c) return;
  689. /// else {
  690. /// return;
  691. /// }
  692. /// \endcode
  693. SIS_OnlyFirstIf,
  694. /// Always put short ifs, else ifs and else statements on the same
  695. /// line.
  696. /// \code
  697. /// if (a) return;
  698. ///
  699. /// if (b) return;
  700. /// else return;
  701. ///
  702. /// if (c) return;
  703. /// else {
  704. /// return;
  705. /// }
  706. /// \endcode
  707. SIS_AllIfsAndElse,
  708. };
  709. /// Dependent on the value, ``if (a) return;`` can be put on a single line.
  710. /// \version 9
  711. ShortIfStyle AllowShortIfStatementsOnASingleLine;
  712. /// Different styles for merging short lambdas containing at most one
  713. /// statement.
  714. enum ShortLambdaStyle : unsigned char {
  715. /// Never merge lambdas into a single line.
  716. SLS_None,
  717. /// Only merge empty lambdas.
  718. /// \code
  719. /// auto lambda = [](int a) {}
  720. /// auto lambda2 = [](int a) {
  721. /// return a;
  722. /// };
  723. /// \endcode
  724. SLS_Empty,
  725. /// Merge lambda into a single line if argument of a function.
  726. /// \code
  727. /// auto lambda = [](int a) {
  728. /// return a;
  729. /// };
  730. /// sort(a.begin(), a.end(), ()[] { return x < y; })
  731. /// \endcode
  732. SLS_Inline,
  733. /// Merge all lambdas fitting on a single line.
  734. /// \code
  735. /// auto lambda = [](int a) {}
  736. /// auto lambda2 = [](int a) { return a; };
  737. /// \endcode
  738. SLS_All,
  739. };
  740. /// Dependent on the value, ``auto lambda []() { return 0; }`` can be put on a
  741. /// single line.
  742. /// \version 9
  743. ShortLambdaStyle AllowShortLambdasOnASingleLine;
  744. /// If ``true``, ``while (true) continue;`` can be put on a single
  745. /// line.
  746. /// \version 3.7
  747. bool AllowShortLoopsOnASingleLine;
  748. /// Different ways to break after the function definition return type.
  749. /// This option is **deprecated** and is retained for backwards compatibility.
  750. enum DefinitionReturnTypeBreakingStyle : unsigned char {
  751. /// Break after return type automatically.
  752. /// ``PenaltyReturnTypeOnItsOwnLine`` is taken into account.
  753. DRTBS_None,
  754. /// Always break after the return type.
  755. DRTBS_All,
  756. /// Always break after the return types of top-level functions.
  757. DRTBS_TopLevel,
  758. };
  759. /// Different ways to break after the function definition or
  760. /// declaration return type.
  761. enum ReturnTypeBreakingStyle : unsigned char {
  762. /// Break after return type automatically.
  763. /// ``PenaltyReturnTypeOnItsOwnLine`` is taken into account.
  764. /// \code
  765. /// class A {
  766. /// int f() { return 0; };
  767. /// };
  768. /// int f();
  769. /// int f() { return 1; }
  770. /// \endcode
  771. RTBS_None,
  772. /// Always break after the return type.
  773. /// \code
  774. /// class A {
  775. /// int
  776. /// f() {
  777. /// return 0;
  778. /// };
  779. /// };
  780. /// int
  781. /// f();
  782. /// int
  783. /// f() {
  784. /// return 1;
  785. /// }
  786. /// \endcode
  787. RTBS_All,
  788. /// Always break after the return types of top-level functions.
  789. /// \code
  790. /// class A {
  791. /// int f() { return 0; };
  792. /// };
  793. /// int
  794. /// f();
  795. /// int
  796. /// f() {
  797. /// return 1;
  798. /// }
  799. /// \endcode
  800. RTBS_TopLevel,
  801. /// Always break after the return type of function definitions.
  802. /// \code
  803. /// class A {
  804. /// int
  805. /// f() {
  806. /// return 0;
  807. /// };
  808. /// };
  809. /// int f();
  810. /// int
  811. /// f() {
  812. /// return 1;
  813. /// }
  814. /// \endcode
  815. RTBS_AllDefinitions,
  816. /// Always break after the return type of top-level definitions.
  817. /// \code
  818. /// class A {
  819. /// int f() { return 0; };
  820. /// };
  821. /// int f();
  822. /// int
  823. /// f() {
  824. /// return 1;
  825. /// }
  826. /// \endcode
  827. RTBS_TopLevelDefinitions,
  828. };
  829. /// The function definition return type breaking style to use. This
  830. /// option is **deprecated** and is retained for backwards compatibility.
  831. /// \version 3.7
  832. DefinitionReturnTypeBreakingStyle AlwaysBreakAfterDefinitionReturnType;
  833. /// The function declaration return type breaking style to use.
  834. /// \version 3.8
  835. ReturnTypeBreakingStyle AlwaysBreakAfterReturnType;
  836. /// If ``true``, always break before multiline string literals.
  837. ///
  838. /// This flag is mean to make cases where there are multiple multiline strings
  839. /// in a file look more consistent. Thus, it will only take effect if wrapping
  840. /// the string at that point leads to it being indented
  841. /// ``ContinuationIndentWidth`` spaces from the start of the line.
  842. /// \code
  843. /// true: false:
  844. /// aaaa = vs. aaaa = "bbbb"
  845. /// "bbbb" "cccc";
  846. /// "cccc";
  847. /// \endcode
  848. /// \version 3.4
  849. bool AlwaysBreakBeforeMultilineStrings;
  850. /// Different ways to break after the template declaration.
  851. enum BreakTemplateDeclarationsStyle : unsigned char {
  852. /// Do not force break before declaration.
  853. /// ``PenaltyBreakTemplateDeclaration`` is taken into account.
  854. /// \code
  855. /// template <typename T> T foo() {
  856. /// }
  857. /// template <typename T> T foo(int aaaaaaaaaaaaaaaaaaaaa,
  858. /// int bbbbbbbbbbbbbbbbbbbbb) {
  859. /// }
  860. /// \endcode
  861. BTDS_No,
  862. /// Force break after template declaration only when the following
  863. /// declaration spans multiple lines.
  864. /// \code
  865. /// template <typename T> T foo() {
  866. /// }
  867. /// template <typename T>
  868. /// T foo(int aaaaaaaaaaaaaaaaaaaaa,
  869. /// int bbbbbbbbbbbbbbbbbbbbb) {
  870. /// }
  871. /// \endcode
  872. BTDS_MultiLine,
  873. /// Always break after template declaration.
  874. /// \code
  875. /// template <typename T>
  876. /// T foo() {
  877. /// }
  878. /// template <typename T>
  879. /// T foo(int aaaaaaaaaaaaaaaaaaaaa,
  880. /// int bbbbbbbbbbbbbbbbbbbbb) {
  881. /// }
  882. /// \endcode
  883. BTDS_Yes
  884. };
  885. /// The template declaration breaking style to use.
  886. /// \version 7
  887. BreakTemplateDeclarationsStyle AlwaysBreakTemplateDeclarations;
  888. /// A vector of strings that should be interpreted as attributes/qualifiers
  889. /// instead of identifiers. This can be useful for language extensions or
  890. /// static analyzer annotations.
  891. ///
  892. /// For example:
  893. /// \code
  894. /// x = (char *__capability)&y;
  895. /// int function(void) __ununsed;
  896. /// void only_writes_to_buffer(char *__output buffer);
  897. /// \endcode
  898. ///
  899. /// In the .clang-format configuration file, this can be configured like:
  900. /// \code{.yaml}
  901. /// AttributeMacros: ['__capability', '__output', '__ununsed']
  902. /// \endcode
  903. ///
  904. /// \version 12
  905. std::vector<std::string> AttributeMacros;
  906. /// If ``false``, a function call's arguments will either be all on the
  907. /// same line or will have one line each.
  908. /// \code
  909. /// true:
  910. /// void f() {
  911. /// f(aaaaaaaaaaaaaaaaaaaa, aaaaaaaaaaaaaaaaaaaa,
  912. /// aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa);
  913. /// }
  914. ///
  915. /// false:
  916. /// void f() {
  917. /// f(aaaaaaaaaaaaaaaaaaaa,
  918. /// aaaaaaaaaaaaaaaaaaaa,
  919. /// aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa);
  920. /// }
  921. /// \endcode
  922. /// \version 3.7
  923. bool BinPackArguments;
  924. /// The style of inserting trailing commas into container literals.
  925. enum TrailingCommaStyle : unsigned char {
  926. /// Do not insert trailing commas.
  927. TCS_None,
  928. /// Insert trailing commas in container literals that were wrapped over
  929. /// multiple lines. Note that this is conceptually incompatible with
  930. /// bin-packing, because the trailing comma is used as an indicator
  931. /// that a container should be formatted one-per-line (i.e. not bin-packed).
  932. /// So inserting a trailing comma counteracts bin-packing.
  933. TCS_Wrapped,
  934. };
  935. /// If set to ``TCS_Wrapped`` will insert trailing commas in container
  936. /// literals (arrays and objects) that wrap across multiple lines.
  937. /// It is currently only available for JavaScript
  938. /// and disabled by default ``TCS_None``.
  939. /// ``InsertTrailingCommas`` cannot be used together with ``BinPackArguments``
  940. /// as inserting the comma disables bin-packing.
  941. /// \code
  942. /// TSC_Wrapped:
  943. /// const someArray = [
  944. /// aaaaaaaaaaaaaaaaaaaaaaaaaa,
  945. /// aaaaaaaaaaaaaaaaaaaaaaaaaa,
  946. /// aaaaaaaaaaaaaaaaaaaaaaaaaa,
  947. /// // ^ inserted
  948. /// ]
  949. /// \endcode
  950. /// \version 12
  951. TrailingCommaStyle InsertTrailingCommas;
  952. /// If ``false``, a function declaration's or function definition's
  953. /// parameters will either all be on the same line or will have one line each.
  954. /// \code
  955. /// true:
  956. /// void f(int aaaaaaaaaaaaaaaaaaaa, int aaaaaaaaaaaaaaaaaaaa,
  957. /// int aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa) {}
  958. ///
  959. /// false:
  960. /// void f(int aaaaaaaaaaaaaaaaaaaa,
  961. /// int aaaaaaaaaaaaaaaaaaaa,
  962. /// int aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa) {}
  963. /// \endcode
  964. /// \version 3.7
  965. bool BinPackParameters;
  966. /// The style of wrapping parameters on the same line (bin-packed) or
  967. /// on one line each.
  968. enum BinPackStyle : unsigned char {
  969. /// Automatically determine parameter bin-packing behavior.
  970. BPS_Auto,
  971. /// Always bin-pack parameters.
  972. BPS_Always,
  973. /// Never bin-pack parameters.
  974. BPS_Never,
  975. };
  976. /// The style of breaking before or after binary operators.
  977. enum BinaryOperatorStyle : unsigned char {
  978. /// Break after operators.
  979. /// \code
  980. /// LooooooooooongType loooooooooooooooooooooongVariable =
  981. /// someLooooooooooooooooongFunction();
  982. ///
  983. /// bool value = aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa +
  984. /// aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa ==
  985. /// aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa &&
  986. /// aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa >
  987. /// ccccccccccccccccccccccccccccccccccccccccc;
  988. /// \endcode
  989. BOS_None,
  990. /// Break before operators that aren't assignments.
  991. /// \code
  992. /// LooooooooooongType loooooooooooooooooooooongVariable =
  993. /// someLooooooooooooooooongFunction();
  994. ///
  995. /// bool value = aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
  996. /// + aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
  997. /// == aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
  998. /// && aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
  999. /// > ccccccccccccccccccccccccccccccccccccccccc;
  1000. /// \endcode
  1001. BOS_NonAssignment,
  1002. /// Break before operators.
  1003. /// \code
  1004. /// LooooooooooongType loooooooooooooooooooooongVariable
  1005. /// = someLooooooooooooooooongFunction();
  1006. ///
  1007. /// bool value = aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
  1008. /// + aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
  1009. /// == aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
  1010. /// && aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
  1011. /// > ccccccccccccccccccccccccccccccccccccccccc;
  1012. /// \endcode
  1013. BOS_All,
  1014. };
  1015. /// The way to wrap binary operators.
  1016. /// \version 3.6
  1017. BinaryOperatorStyle BreakBeforeBinaryOperators;
  1018. /// Different ways to attach braces to their surrounding context.
  1019. enum BraceBreakingStyle : unsigned char {
  1020. /// Always attach braces to surrounding context.
  1021. /// \code
  1022. /// namespace N {
  1023. /// enum E {
  1024. /// E1,
  1025. /// E2,
  1026. /// };
  1027. ///
  1028. /// class C {
  1029. /// public:
  1030. /// C();
  1031. /// };
  1032. ///
  1033. /// bool baz(int i) {
  1034. /// try {
  1035. /// do {
  1036. /// switch (i) {
  1037. /// case 1: {
  1038. /// foobar();
  1039. /// break;
  1040. /// }
  1041. /// default: {
  1042. /// break;
  1043. /// }
  1044. /// }
  1045. /// } while (--i);
  1046. /// return true;
  1047. /// } catch (...) {
  1048. /// handleError();
  1049. /// return false;
  1050. /// }
  1051. /// }
  1052. ///
  1053. /// void foo(bool b) {
  1054. /// if (b) {
  1055. /// baz(2);
  1056. /// } else {
  1057. /// baz(5);
  1058. /// }
  1059. /// }
  1060. ///
  1061. /// void bar() { foo(true); }
  1062. /// } // namespace N
  1063. /// \endcode
  1064. BS_Attach,
  1065. /// Like ``Attach``, but break before braces on function, namespace and
  1066. /// class definitions.
  1067. /// \code
  1068. /// namespace N
  1069. /// {
  1070. /// enum E {
  1071. /// E1,
  1072. /// E2,
  1073. /// };
  1074. ///
  1075. /// class C
  1076. /// {
  1077. /// public:
  1078. /// C();
  1079. /// };
  1080. ///
  1081. /// bool baz(int i)
  1082. /// {
  1083. /// try {
  1084. /// do {
  1085. /// switch (i) {
  1086. /// case 1: {
  1087. /// foobar();
  1088. /// break;
  1089. /// }
  1090. /// default: {
  1091. /// break;
  1092. /// }
  1093. /// }
  1094. /// } while (--i);
  1095. /// return true;
  1096. /// } catch (...) {
  1097. /// handleError();
  1098. /// return false;
  1099. /// }
  1100. /// }
  1101. ///
  1102. /// void foo(bool b)
  1103. /// {
  1104. /// if (b) {
  1105. /// baz(2);
  1106. /// } else {
  1107. /// baz(5);
  1108. /// }
  1109. /// }
  1110. ///
  1111. /// void bar() { foo(true); }
  1112. /// } // namespace N
  1113. /// \endcode
  1114. BS_Linux,
  1115. /// Like ``Attach``, but break before braces on enum, function, and record
  1116. /// definitions.
  1117. /// \code
  1118. /// namespace N {
  1119. /// enum E
  1120. /// {
  1121. /// E1,
  1122. /// E2,
  1123. /// };
  1124. ///
  1125. /// class C
  1126. /// {
  1127. /// public:
  1128. /// C();
  1129. /// };
  1130. ///
  1131. /// bool baz(int i)
  1132. /// {
  1133. /// try {
  1134. /// do {
  1135. /// switch (i) {
  1136. /// case 1: {
  1137. /// foobar();
  1138. /// break;
  1139. /// }
  1140. /// default: {
  1141. /// break;
  1142. /// }
  1143. /// }
  1144. /// } while (--i);
  1145. /// return true;
  1146. /// } catch (...) {
  1147. /// handleError();
  1148. /// return false;
  1149. /// }
  1150. /// }
  1151. ///
  1152. /// void foo(bool b)
  1153. /// {
  1154. /// if (b) {
  1155. /// baz(2);
  1156. /// } else {
  1157. /// baz(5);
  1158. /// }
  1159. /// }
  1160. ///
  1161. /// void bar() { foo(true); }
  1162. /// } // namespace N
  1163. /// \endcode
  1164. BS_Mozilla,
  1165. /// Like ``Attach``, but break before function definitions, ``catch``, and
  1166. /// ``else``.
  1167. /// \code
  1168. /// namespace N {
  1169. /// enum E {
  1170. /// E1,
  1171. /// E2,
  1172. /// };
  1173. ///
  1174. /// class C {
  1175. /// public:
  1176. /// C();
  1177. /// };
  1178. ///
  1179. /// bool baz(int i)
  1180. /// {
  1181. /// try {
  1182. /// do {
  1183. /// switch (i) {
  1184. /// case 1: {
  1185. /// foobar();
  1186. /// break;
  1187. /// }
  1188. /// default: {
  1189. /// break;
  1190. /// }
  1191. /// }
  1192. /// } while (--i);
  1193. /// return true;
  1194. /// }
  1195. /// catch (...) {
  1196. /// handleError();
  1197. /// return false;
  1198. /// }
  1199. /// }
  1200. ///
  1201. /// void foo(bool b)
  1202. /// {
  1203. /// if (b) {
  1204. /// baz(2);
  1205. /// }
  1206. /// else {
  1207. /// baz(5);
  1208. /// }
  1209. /// }
  1210. ///
  1211. /// void bar() { foo(true); }
  1212. /// } // namespace N
  1213. /// \endcode
  1214. BS_Stroustrup,
  1215. /// Always break before braces.
  1216. /// \code
  1217. /// namespace N
  1218. /// {
  1219. /// enum E
  1220. /// {
  1221. /// E1,
  1222. /// E2,
  1223. /// };
  1224. ///
  1225. /// class C
  1226. /// {
  1227. /// public:
  1228. /// C();
  1229. /// };
  1230. ///
  1231. /// bool baz(int i)
  1232. /// {
  1233. /// try
  1234. /// {
  1235. /// do
  1236. /// {
  1237. /// switch (i)
  1238. /// {
  1239. /// case 1:
  1240. /// {
  1241. /// foobar();
  1242. /// break;
  1243. /// }
  1244. /// default:
  1245. /// {
  1246. /// break;
  1247. /// }
  1248. /// }
  1249. /// } while (--i);
  1250. /// return true;
  1251. /// }
  1252. /// catch (...)
  1253. /// {
  1254. /// handleError();
  1255. /// return false;
  1256. /// }
  1257. /// }
  1258. ///
  1259. /// void foo(bool b)
  1260. /// {
  1261. /// if (b)
  1262. /// {
  1263. /// baz(2);
  1264. /// }
  1265. /// else
  1266. /// {
  1267. /// baz(5);
  1268. /// }
  1269. /// }
  1270. ///
  1271. /// void bar() { foo(true); }
  1272. /// } // namespace N
  1273. /// \endcode
  1274. BS_Allman,
  1275. /// Like ``Allman`` but always indent braces and line up code with braces.
  1276. /// \code
  1277. /// namespace N
  1278. /// {
  1279. /// enum E
  1280. /// {
  1281. /// E1,
  1282. /// E2,
  1283. /// };
  1284. ///
  1285. /// class C
  1286. /// {
  1287. /// public:
  1288. /// C();
  1289. /// };
  1290. ///
  1291. /// bool baz(int i)
  1292. /// {
  1293. /// try
  1294. /// {
  1295. /// do
  1296. /// {
  1297. /// switch (i)
  1298. /// {
  1299. /// case 1:
  1300. /// {
  1301. /// foobar();
  1302. /// break;
  1303. /// }
  1304. /// default:
  1305. /// {
  1306. /// break;
  1307. /// }
  1308. /// }
  1309. /// } while (--i);
  1310. /// return true;
  1311. /// }
  1312. /// catch (...)
  1313. /// {
  1314. /// handleError();
  1315. /// return false;
  1316. /// }
  1317. /// }
  1318. ///
  1319. /// void foo(bool b)
  1320. /// {
  1321. /// if (b)
  1322. /// {
  1323. /// baz(2);
  1324. /// }
  1325. /// else
  1326. /// {
  1327. /// baz(5);
  1328. /// }
  1329. /// }
  1330. ///
  1331. /// void bar() { foo(true); }
  1332. /// } // namespace N
  1333. /// \endcode
  1334. BS_Whitesmiths,
  1335. /// Always break before braces and add an extra level of indentation to
  1336. /// braces of control statements, not to those of class, function
  1337. /// or other definitions.
  1338. /// \code
  1339. /// namespace N
  1340. /// {
  1341. /// enum E
  1342. /// {
  1343. /// E1,
  1344. /// E2,
  1345. /// };
  1346. ///
  1347. /// class C
  1348. /// {
  1349. /// public:
  1350. /// C();
  1351. /// };
  1352. ///
  1353. /// bool baz(int i)
  1354. /// {
  1355. /// try
  1356. /// {
  1357. /// do
  1358. /// {
  1359. /// switch (i)
  1360. /// {
  1361. /// case 1:
  1362. /// {
  1363. /// foobar();
  1364. /// break;
  1365. /// }
  1366. /// default:
  1367. /// {
  1368. /// break;
  1369. /// }
  1370. /// }
  1371. /// }
  1372. /// while (--i);
  1373. /// return true;
  1374. /// }
  1375. /// catch (...)
  1376. /// {
  1377. /// handleError();
  1378. /// return false;
  1379. /// }
  1380. /// }
  1381. ///
  1382. /// void foo(bool b)
  1383. /// {
  1384. /// if (b)
  1385. /// {
  1386. /// baz(2);
  1387. /// }
  1388. /// else
  1389. /// {
  1390. /// baz(5);
  1391. /// }
  1392. /// }
  1393. ///
  1394. /// void bar() { foo(true); }
  1395. /// } // namespace N
  1396. /// \endcode
  1397. BS_GNU,
  1398. /// Like ``Attach``, but break before functions.
  1399. /// \code
  1400. /// namespace N {
  1401. /// enum E {
  1402. /// E1,
  1403. /// E2,
  1404. /// };
  1405. ///
  1406. /// class C {
  1407. /// public:
  1408. /// C();
  1409. /// };
  1410. ///
  1411. /// bool baz(int i)
  1412. /// {
  1413. /// try {
  1414. /// do {
  1415. /// switch (i) {
  1416. /// case 1: {
  1417. /// foobar();
  1418. /// break;
  1419. /// }
  1420. /// default: {
  1421. /// break;
  1422. /// }
  1423. /// }
  1424. /// } while (--i);
  1425. /// return true;
  1426. /// } catch (...) {
  1427. /// handleError();
  1428. /// return false;
  1429. /// }
  1430. /// }
  1431. ///
  1432. /// void foo(bool b)
  1433. /// {
  1434. /// if (b) {
  1435. /// baz(2);
  1436. /// } else {
  1437. /// baz(5);
  1438. /// }
  1439. /// }
  1440. ///
  1441. /// void bar() { foo(true); }
  1442. /// } // namespace N
  1443. /// \endcode
  1444. BS_WebKit,
  1445. /// Configure each individual brace in `BraceWrapping`.
  1446. BS_Custom
  1447. };
  1448. /// The brace breaking style to use.
  1449. /// \version 3.7
  1450. BraceBreakingStyle BreakBeforeBraces;
  1451. /// Different ways to wrap braces after control statements.
  1452. enum BraceWrappingAfterControlStatementStyle : unsigned char {
  1453. /// Never wrap braces after a control statement.
  1454. /// \code
  1455. /// if (foo()) {
  1456. /// } else {
  1457. /// }
  1458. /// for (int i = 0; i < 10; ++i) {
  1459. /// }
  1460. /// \endcode
  1461. BWACS_Never,
  1462. /// Only wrap braces after a multi-line control statement.
  1463. /// \code
  1464. /// if (foo && bar &&
  1465. /// baz)
  1466. /// {
  1467. /// quux();
  1468. /// }
  1469. /// while (foo || bar) {
  1470. /// }
  1471. /// \endcode
  1472. BWACS_MultiLine,
  1473. /// Always wrap braces after a control statement.
  1474. /// \code
  1475. /// if (foo())
  1476. /// {
  1477. /// } else
  1478. /// {}
  1479. /// for (int i = 0; i < 10; ++i)
  1480. /// {}
  1481. /// \endcode
  1482. BWACS_Always
  1483. };
  1484. /// Precise control over the wrapping of braces.
  1485. /// \code
  1486. /// # Should be declared this way:
  1487. /// BreakBeforeBraces: Custom
  1488. /// BraceWrapping:
  1489. /// AfterClass: true
  1490. /// \endcode
  1491. struct BraceWrappingFlags {
  1492. /// Wrap case labels.
  1493. /// \code
  1494. /// false: true:
  1495. /// switch (foo) { vs. switch (foo) {
  1496. /// case 1: { case 1:
  1497. /// bar(); {
  1498. /// break; bar();
  1499. /// } break;
  1500. /// default: { }
  1501. /// plop(); default:
  1502. /// } {
  1503. /// } plop();
  1504. /// }
  1505. /// }
  1506. /// \endcode
  1507. bool AfterCaseLabel;
  1508. /// Wrap class definitions.
  1509. /// \code
  1510. /// true:
  1511. /// class foo {};
  1512. ///
  1513. /// false:
  1514. /// class foo
  1515. /// {};
  1516. /// \endcode
  1517. bool AfterClass;
  1518. /// Wrap control statements (``if``/``for``/``while``/``switch``/..).
  1519. BraceWrappingAfterControlStatementStyle AfterControlStatement;
  1520. /// Wrap enum definitions.
  1521. /// \code
  1522. /// true:
  1523. /// enum X : int
  1524. /// {
  1525. /// B
  1526. /// };
  1527. ///
  1528. /// false:
  1529. /// enum X : int { B };
  1530. /// \endcode
  1531. bool AfterEnum;
  1532. /// Wrap function definitions.
  1533. /// \code
  1534. /// true:
  1535. /// void foo()
  1536. /// {
  1537. /// bar();
  1538. /// bar2();
  1539. /// }
  1540. ///
  1541. /// false:
  1542. /// void foo() {
  1543. /// bar();
  1544. /// bar2();
  1545. /// }
  1546. /// \endcode
  1547. bool AfterFunction;
  1548. /// Wrap namespace definitions.
  1549. /// \code
  1550. /// true:
  1551. /// namespace
  1552. /// {
  1553. /// int foo();
  1554. /// int bar();
  1555. /// }
  1556. ///
  1557. /// false:
  1558. /// namespace {
  1559. /// int foo();
  1560. /// int bar();
  1561. /// }
  1562. /// \endcode
  1563. bool AfterNamespace;
  1564. /// Wrap ObjC definitions (interfaces, implementations...).
  1565. /// \note @autoreleasepool and @synchronized blocks are wrapped
  1566. /// according to `AfterControlStatement` flag.
  1567. bool AfterObjCDeclaration;
  1568. /// Wrap struct definitions.
  1569. /// \code
  1570. /// true:
  1571. /// struct foo
  1572. /// {
  1573. /// int x;
  1574. /// };
  1575. ///
  1576. /// false:
  1577. /// struct foo {
  1578. /// int x;
  1579. /// };
  1580. /// \endcode
  1581. bool AfterStruct;
  1582. /// Wrap union definitions.
  1583. /// \code
  1584. /// true:
  1585. /// union foo
  1586. /// {
  1587. /// int x;
  1588. /// }
  1589. ///
  1590. /// false:
  1591. /// union foo {
  1592. /// int x;
  1593. /// }
  1594. /// \endcode
  1595. bool AfterUnion;
  1596. /// Wrap extern blocks.
  1597. /// \code
  1598. /// true:
  1599. /// extern "C"
  1600. /// {
  1601. /// int foo();
  1602. /// }
  1603. ///
  1604. /// false:
  1605. /// extern "C" {
  1606. /// int foo();
  1607. /// }
  1608. /// \endcode
  1609. bool AfterExternBlock; // Partially superseded by IndentExternBlock
  1610. /// Wrap before ``catch``.
  1611. /// \code
  1612. /// true:
  1613. /// try {
  1614. /// foo();
  1615. /// }
  1616. /// catch () {
  1617. /// }
  1618. ///
  1619. /// false:
  1620. /// try {
  1621. /// foo();
  1622. /// } catch () {
  1623. /// }
  1624. /// \endcode
  1625. bool BeforeCatch;
  1626. /// Wrap before ``else``.
  1627. /// \code
  1628. /// true:
  1629. /// if (foo()) {
  1630. /// }
  1631. /// else {
  1632. /// }
  1633. ///
  1634. /// false:
  1635. /// if (foo()) {
  1636. /// } else {
  1637. /// }
  1638. /// \endcode
  1639. bool BeforeElse;
  1640. /// Wrap lambda block.
  1641. /// \code
  1642. /// true:
  1643. /// connect(
  1644. /// []()
  1645. /// {
  1646. /// foo();
  1647. /// bar();
  1648. /// });
  1649. ///
  1650. /// false:
  1651. /// connect([]() {
  1652. /// foo();
  1653. /// bar();
  1654. /// });
  1655. /// \endcode
  1656. bool BeforeLambdaBody;
  1657. /// Wrap before ``while``.
  1658. /// \code
  1659. /// true:
  1660. /// do {
  1661. /// foo();
  1662. /// }
  1663. /// while (1);
  1664. ///
  1665. /// false:
  1666. /// do {
  1667. /// foo();
  1668. /// } while (1);
  1669. /// \endcode
  1670. bool BeforeWhile;
  1671. /// Indent the wrapped braces themselves.
  1672. bool IndentBraces;
  1673. /// If ``false``, empty function body can be put on a single line.
  1674. /// This option is used only if the opening brace of the function has
  1675. /// already been wrapped, i.e. the `AfterFunction` brace wrapping mode is
  1676. /// set, and the function could/should not be put on a single line (as per
  1677. /// `AllowShortFunctionsOnASingleLine` and constructor formatting options).
  1678. /// \code
  1679. /// int f() vs. int f()
  1680. /// {} {
  1681. /// }
  1682. /// \endcode
  1683. ///
  1684. bool SplitEmptyFunction;
  1685. /// If ``false``, empty record (e.g. class, struct or union) body
  1686. /// can be put on a single line. This option is used only if the opening
  1687. /// brace of the record has already been wrapped, i.e. the `AfterClass`
  1688. /// (for classes) brace wrapping mode is set.
  1689. /// \code
  1690. /// class Foo vs. class Foo
  1691. /// {} {
  1692. /// }
  1693. /// \endcode
  1694. ///
  1695. bool SplitEmptyRecord;
  1696. /// If ``false``, empty namespace body can be put on a single line.
  1697. /// This option is used only if the opening brace of the namespace has
  1698. /// already been wrapped, i.e. the `AfterNamespace` brace wrapping mode is
  1699. /// set.
  1700. /// \code
  1701. /// namespace Foo vs. namespace Foo
  1702. /// {} {
  1703. /// }
  1704. /// \endcode
  1705. ///
  1706. bool SplitEmptyNamespace;
  1707. };
  1708. /// Control of individual brace wrapping cases.
  1709. ///
  1710. /// If ``BreakBeforeBraces`` is set to ``BS_Custom``, use this to specify how
  1711. /// each individual brace case should be handled. Otherwise, this is ignored.
  1712. /// \code{.yaml}
  1713. /// # Example of usage:
  1714. /// BreakBeforeBraces: Custom
  1715. /// BraceWrapping:
  1716. /// AfterEnum: true
  1717. /// AfterStruct: false
  1718. /// SplitEmptyFunction: false
  1719. /// \endcode
  1720. /// \version 3.8
  1721. BraceWrappingFlags BraceWrapping;
  1722. /// If ``true``, concept will be placed on a new line.
  1723. /// \code
  1724. /// true:
  1725. /// template<typename T>
  1726. /// concept ...
  1727. ///
  1728. /// false:
  1729. /// template<typename T> concept ...
  1730. /// \endcode
  1731. /// \version 13
  1732. bool BreakBeforeConceptDeclarations;
  1733. /// If ``true``, ternary operators will be placed after line breaks.
  1734. /// \code
  1735. /// true:
  1736. /// veryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryLongDescription
  1737. /// ? firstValue
  1738. /// : SecondValueVeryVeryVeryVeryLong;
  1739. ///
  1740. /// false:
  1741. /// veryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryLongDescription ?
  1742. /// firstValue :
  1743. /// SecondValueVeryVeryVeryVeryLong;
  1744. /// \endcode
  1745. /// \version 3.7
  1746. bool BreakBeforeTernaryOperators;
  1747. /// Different ways to break initializers.
  1748. enum BreakConstructorInitializersStyle : unsigned char {
  1749. /// Break constructor initializers before the colon and after the commas.
  1750. /// \code
  1751. /// Constructor()
  1752. /// : initializer1(),
  1753. /// initializer2()
  1754. /// \endcode
  1755. BCIS_BeforeColon,
  1756. /// Break constructor initializers before the colon and commas, and align
  1757. /// the commas with the colon.
  1758. /// \code
  1759. /// Constructor()
  1760. /// : initializer1()
  1761. /// , initializer2()
  1762. /// \endcode
  1763. BCIS_BeforeComma,
  1764. /// Break constructor initializers after the colon and commas.
  1765. /// \code
  1766. /// Constructor() :
  1767. /// initializer1(),
  1768. /// initializer2()
  1769. /// \endcode
  1770. BCIS_AfterColon
  1771. };
  1772. /// The break constructor initializers style to use.
  1773. /// \version 5
  1774. BreakConstructorInitializersStyle BreakConstructorInitializers;
  1775. /// Break after each annotation on a field in Java files.
  1776. /// \code{.java}
  1777. /// true: false:
  1778. /// @Partial vs. @Partial @Mock DataLoad loader;
  1779. /// @Mock
  1780. /// DataLoad loader;
  1781. /// \endcode
  1782. /// \version 3.8
  1783. bool BreakAfterJavaFieldAnnotations;
  1784. /// Allow breaking string literals when formatting.
  1785. /// \code
  1786. /// true:
  1787. /// const char* x = "veryVeryVeryVeryVeryVe"
  1788. /// "ryVeryVeryVeryVeryVery"
  1789. /// "VeryLongString";
  1790. ///
  1791. /// false:
  1792. /// const char* x =
  1793. /// "veryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryLongString";
  1794. /// \endcode
  1795. /// \version 3.9
  1796. bool BreakStringLiterals;
  1797. /// The column limit.
  1798. ///
  1799. /// A column limit of ``0`` means that there is no column limit. In this case,
  1800. /// clang-format will respect the input's line breaking decisions within
  1801. /// statements unless they contradict other rules.
  1802. /// \version 3.7
  1803. unsigned ColumnLimit;
  1804. /// A regular expression that describes comments with special meaning,
  1805. /// which should not be split into lines or otherwise changed.
  1806. /// \code
  1807. /// // CommentPragmas: '^ FOOBAR pragma:'
  1808. /// // Will leave the following line unaffected
  1809. /// #include <vector> // FOOBAR pragma: keep
  1810. /// \endcode
  1811. /// \version 3.7
  1812. std::string CommentPragmas;
  1813. /// Different specifiers and qualifiers alignment styles.
  1814. enum QualifierAlignmentStyle {
  1815. /// Don't change specifiers/qualifiers to either Left or Right alignment
  1816. /// (default).
  1817. /// \code
  1818. /// int const a;
  1819. /// const int *a;
  1820. /// \endcode
  1821. QAS_Leave,
  1822. /// Change specifiers/qualifiers to be left-aligned.
  1823. /// \code
  1824. /// const int a;
  1825. /// const int *a;
  1826. /// \endcode
  1827. QAS_Left,
  1828. /// Change specifiers/qualifiers to be right-aligned.
  1829. /// \code
  1830. /// int const a;
  1831. /// int const *a;
  1832. /// \endcode
  1833. QAS_Right,
  1834. /// Change specifiers/qualifiers to be aligned based on ``QualifierOrder``.
  1835. /// With:
  1836. /// \code{.yaml}
  1837. /// QualifierOrder: ['inline', 'static' , 'type', 'const']
  1838. /// \endcode
  1839. ///
  1840. /// \code
  1841. ///
  1842. /// int const a;
  1843. /// int const *a;
  1844. /// \endcode
  1845. QAS_Custom
  1846. };
  1847. /// Different ways to arrange specifiers and qualifiers (e.g. const/volatile).
  1848. /// \warning
  1849. /// Setting ``QualifierAlignment`` to something other than `Leave`, COULD
  1850. /// lead to incorrect code formatting due to incorrect decisions made due to
  1851. /// clang-formats lack of complete semantic information.
  1852. /// As such extra care should be taken to review code changes made by the use
  1853. /// of this option.
  1854. /// \endwarning
  1855. /// \version 14
  1856. QualifierAlignmentStyle QualifierAlignment;
  1857. /// The order in which the qualifiers appear.
  1858. /// Order is an array that can contain any of the following:
  1859. ///
  1860. /// * const
  1861. /// * inline
  1862. /// * static
  1863. /// * constexpr
  1864. /// * volatile
  1865. /// * restrict
  1866. /// * type
  1867. ///
  1868. /// Note: it MUST contain 'type'.
  1869. /// Items to the left of 'type' will be placed to the left of the type and
  1870. /// aligned in the order supplied. Items to the right of 'type' will be placed
  1871. /// to the right of the type and aligned in the order supplied.
  1872. ///
  1873. /// \code{.yaml}
  1874. /// QualifierOrder: ['inline', 'static', 'type', 'const', 'volatile' ]
  1875. /// \endcode
  1876. /// \version 14
  1877. std::vector<std::string> QualifierOrder;
  1878. /// Different ways to break inheritance list.
  1879. enum BreakInheritanceListStyle : unsigned char {
  1880. /// Break inheritance list before the colon and after the commas.
  1881. /// \code
  1882. /// class Foo
  1883. /// : Base1,
  1884. /// Base2
  1885. /// {};
  1886. /// \endcode
  1887. BILS_BeforeColon,
  1888. /// Break inheritance list before the colon and commas, and align
  1889. /// the commas with the colon.
  1890. /// \code
  1891. /// class Foo
  1892. /// : Base1
  1893. /// , Base2
  1894. /// {};
  1895. /// \endcode
  1896. BILS_BeforeComma,
  1897. /// Break inheritance list after the colon and commas.
  1898. /// \code
  1899. /// class Foo :
  1900. /// Base1,
  1901. /// Base2
  1902. /// {};
  1903. /// \endcode
  1904. BILS_AfterColon,
  1905. /// Break inheritance list only after the commas.
  1906. /// \code
  1907. /// class Foo : Base1,
  1908. /// Base2
  1909. /// {};
  1910. /// \endcode
  1911. BILS_AfterComma,
  1912. };
  1913. /// The inheritance list style to use.
  1914. /// \version 7
  1915. BreakInheritanceListStyle BreakInheritanceList;
  1916. /// If ``true``, consecutive namespace declarations will be on the same
  1917. /// line. If ``false``, each namespace is declared on a new line.
  1918. /// \code
  1919. /// true:
  1920. /// namespace Foo { namespace Bar {
  1921. /// }}
  1922. ///
  1923. /// false:
  1924. /// namespace Foo {
  1925. /// namespace Bar {
  1926. /// }
  1927. /// }
  1928. /// \endcode
  1929. ///
  1930. /// If it does not fit on a single line, the overflowing namespaces get
  1931. /// wrapped:
  1932. /// \code
  1933. /// namespace Foo { namespace Bar {
  1934. /// namespace Extra {
  1935. /// }}}
  1936. /// \endcode
  1937. /// \version 5
  1938. bool CompactNamespaces;
  1939. /// This option is **deprecated**. See ``CurrentLine`` of
  1940. /// ``PackConstructorInitializers``.
  1941. /// \version 3.7
  1942. bool ConstructorInitializerAllOnOneLineOrOnePerLine;
  1943. /// The number of characters to use for indentation of constructor
  1944. /// initializer lists as well as inheritance lists.
  1945. /// \version 3.7
  1946. unsigned ConstructorInitializerIndentWidth;
  1947. /// Indent width for line continuations.
  1948. /// \code
  1949. /// ContinuationIndentWidth: 2
  1950. ///
  1951. /// int i = // VeryVeryVeryVeryVeryLongComment
  1952. /// longFunction( // Again a long comment
  1953. /// arg);
  1954. /// \endcode
  1955. /// \version 3.7
  1956. unsigned ContinuationIndentWidth;
  1957. /// If ``true``, format braced lists as best suited for C++11 braced
  1958. /// lists.
  1959. ///
  1960. /// Important differences:
  1961. /// - No spaces inside the braced list.
  1962. /// - No line break before the closing brace.
  1963. /// - Indentation with the continuation indent, not with the block indent.
  1964. ///
  1965. /// Fundamentally, C++11 braced lists are formatted exactly like function
  1966. /// calls would be formatted in their place. If the braced list follows a name
  1967. /// (e.g. a type or variable name), clang-format formats as if the ``{}`` were
  1968. /// the parentheses of a function call with that name. If there is no name,
  1969. /// a zero-length name is assumed.
  1970. /// \code
  1971. /// true: false:
  1972. /// vector<int> x{1, 2, 3, 4}; vs. vector<int> x{ 1, 2, 3, 4 };
  1973. /// vector<T> x{{}, {}, {}, {}}; vector<T> x{ {}, {}, {}, {} };
  1974. /// f(MyMap[{composite, key}]); f(MyMap[{ composite, key }]);
  1975. /// new int[3]{1, 2, 3}; new int[3]{ 1, 2, 3 };
  1976. /// \endcode
  1977. /// \version 3.4
  1978. bool Cpp11BracedListStyle;
  1979. /// \brief Analyze the formatted file for the most used line ending (``\r\n``
  1980. /// or ``\n``). ``UseCRLF`` is only used as a fallback if none can be derived.
  1981. /// \version 11
  1982. bool DeriveLineEnding;
  1983. /// If ``true``, analyze the formatted file for the most common
  1984. /// alignment of ``&`` and ``*``.
  1985. /// Pointer and reference alignment styles are going to be updated according
  1986. /// to the preferences found in the file.
  1987. /// ``PointerAlignment`` is then used only as fallback.
  1988. /// \version 3.7
  1989. bool DerivePointerAlignment;
  1990. /// Disables formatting completely.
  1991. /// \version 3.7
  1992. bool DisableFormat;
  1993. /// Different styles for empty line after access modifiers.
  1994. /// ``EmptyLineBeforeAccessModifier`` configuration handles the number of
  1995. /// empty lines between two access modifiers.
  1996. enum EmptyLineAfterAccessModifierStyle : unsigned char {
  1997. /// Remove all empty lines after access modifiers.
  1998. /// \code
  1999. /// struct foo {
  2000. /// private:
  2001. /// int i;
  2002. /// protected:
  2003. /// int j;
  2004. /// /* comment */
  2005. /// public:
  2006. /// foo() {}
  2007. /// private:
  2008. /// protected:
  2009. /// };
  2010. /// \endcode
  2011. ELAAMS_Never,
  2012. /// Keep existing empty lines after access modifiers.
  2013. /// MaxEmptyLinesToKeep is applied instead.
  2014. ELAAMS_Leave,
  2015. /// Always add empty line after access modifiers if there are none.
  2016. /// MaxEmptyLinesToKeep is applied also.
  2017. /// \code
  2018. /// struct foo {
  2019. /// private:
  2020. ///
  2021. /// int i;
  2022. /// protected:
  2023. ///
  2024. /// int j;
  2025. /// /* comment */
  2026. /// public:
  2027. ///
  2028. /// foo() {}
  2029. /// private:
  2030. ///
  2031. /// protected:
  2032. ///
  2033. /// };
  2034. /// \endcode
  2035. ELAAMS_Always,
  2036. };
  2037. /// Defines when to put an empty line after access modifiers.
  2038. /// ``EmptyLineBeforeAccessModifier`` configuration handles the number of
  2039. /// empty lines between two access modifiers.
  2040. /// \version 14
  2041. EmptyLineAfterAccessModifierStyle EmptyLineAfterAccessModifier;
  2042. /// Different styles for empty line before access modifiers.
  2043. enum EmptyLineBeforeAccessModifierStyle : unsigned char {
  2044. /// Remove all empty lines before access modifiers.
  2045. /// \code
  2046. /// struct foo {
  2047. /// private:
  2048. /// int i;
  2049. /// protected:
  2050. /// int j;
  2051. /// /* comment */
  2052. /// public:
  2053. /// foo() {}
  2054. /// private:
  2055. /// protected:
  2056. /// };
  2057. /// \endcode
  2058. ELBAMS_Never,
  2059. /// Keep existing empty lines before access modifiers.
  2060. ELBAMS_Leave,
  2061. /// Add empty line only when access modifier starts a new logical block.
  2062. /// Logical block is a group of one or more member fields or functions.
  2063. /// \code
  2064. /// struct foo {
  2065. /// private:
  2066. /// int i;
  2067. ///
  2068. /// protected:
  2069. /// int j;
  2070. /// /* comment */
  2071. /// public:
  2072. /// foo() {}
  2073. ///
  2074. /// private:
  2075. /// protected:
  2076. /// };
  2077. /// \endcode
  2078. ELBAMS_LogicalBlock,
  2079. /// Always add empty line before access modifiers unless access modifier
  2080. /// is at the start of struct or class definition.
  2081. /// \code
  2082. /// struct foo {
  2083. /// private:
  2084. /// int i;
  2085. ///
  2086. /// protected:
  2087. /// int j;
  2088. /// /* comment */
  2089. ///
  2090. /// public:
  2091. /// foo() {}
  2092. ///
  2093. /// private:
  2094. ///
  2095. /// protected:
  2096. /// };
  2097. /// \endcode
  2098. ELBAMS_Always,
  2099. };
  2100. /// Defines in which cases to put empty line before access modifiers.
  2101. /// \version 13
  2102. EmptyLineBeforeAccessModifierStyle EmptyLineBeforeAccessModifier;
  2103. /// If ``true``, clang-format detects whether function calls and
  2104. /// definitions are formatted with one parameter per line.
  2105. ///
  2106. /// Each call can be bin-packed, one-per-line or inconclusive. If it is
  2107. /// inconclusive, e.g. completely on one line, but a decision needs to be
  2108. /// made, clang-format analyzes whether there are other bin-packed cases in
  2109. /// the input file and act accordingly.
  2110. ///
  2111. /// NOTE: This is an experimental flag, that might go away or be renamed. Do
  2112. /// not use this in config files, etc. Use at your own risk.
  2113. /// \version 3.7
  2114. bool ExperimentalAutoDetectBinPacking;
  2115. /// Different ways to try to fit all constructor initializers on a line.
  2116. enum PackConstructorInitializersStyle : unsigned char {
  2117. /// Always put each constructor initializer on its own line.
  2118. /// \code
  2119. /// Constructor()
  2120. /// : a(),
  2121. /// b()
  2122. /// \endcode
  2123. PCIS_Never,
  2124. /// Bin-pack constructor initializers.
  2125. /// \code
  2126. /// Constructor()
  2127. /// : aaaaaaaaaaaaaaaaaaaa(), bbbbbbbbbbbbbbbbbbbb(),
  2128. /// cccccccccccccccccccc()
  2129. /// \endcode
  2130. PCIS_BinPack,
  2131. /// Put all constructor initializers on the current line if they fit.
  2132. /// Otherwise, put each one on its own line.
  2133. /// \code
  2134. /// Constructor() : a(), b()
  2135. ///
  2136. /// Constructor()
  2137. /// : aaaaaaaaaaaaaaaaaaaa(),
  2138. /// bbbbbbbbbbbbbbbbbbbb(),
  2139. /// ddddddddddddd()
  2140. /// \endcode
  2141. PCIS_CurrentLine,
  2142. /// Same as ``PCIS_CurrentLine`` except that if all constructor initializers
  2143. /// do not fit on the current line, try to fit them on the next line.
  2144. /// \code
  2145. /// Constructor() : a(), b()
  2146. ///
  2147. /// Constructor()
  2148. /// : aaaaaaaaaaaaaaaaaaaa(), bbbbbbbbbbbbbbbbbbbb(), ddddddddddddd()
  2149. ///
  2150. /// Constructor()
  2151. /// : aaaaaaaaaaaaaaaaaaaa(),
  2152. /// bbbbbbbbbbbbbbbbbbbb(),
  2153. /// cccccccccccccccccccc()
  2154. /// \endcode
  2155. PCIS_NextLine,
  2156. };
  2157. /// The pack constructor initializers style to use.
  2158. /// \version 14;
  2159. PackConstructorInitializersStyle PackConstructorInitializers;
  2160. /// If ``true``, clang-format adds missing namespace end comments for
  2161. /// short namespaces and fixes invalid existing ones. Short ones are
  2162. /// controlled by "ShortNamespaceLines".
  2163. /// \code
  2164. /// true: false:
  2165. /// namespace a { vs. namespace a {
  2166. /// foo(); foo();
  2167. /// bar(); bar();
  2168. /// } // namespace a }
  2169. /// \endcode
  2170. /// \version 5
  2171. bool FixNamespaceComments;
  2172. /// A vector of macros that should be interpreted as foreach loops
  2173. /// instead of as function calls.
  2174. ///
  2175. /// These are expected to be macros of the form:
  2176. /// \code
  2177. /// FOREACH(<variable-declaration>, ...)
  2178. /// <loop-body>
  2179. /// \endcode
  2180. ///
  2181. /// In the .clang-format configuration file, this can be configured like:
  2182. /// \code{.yaml}
  2183. /// ForEachMacros: ['RANGES_FOR', 'FOREACH']
  2184. /// \endcode
  2185. ///
  2186. /// For example: BOOST_FOREACH.
  2187. /// \version 3.7
  2188. std::vector<std::string> ForEachMacros;
  2189. /// A vector of macros that should be interpreted as conditionals
  2190. /// instead of as function calls.
  2191. ///
  2192. /// These are expected to be macros of the form:
  2193. /// \code
  2194. /// IF(...)
  2195. /// <conditional-body>
  2196. /// else IF(...)
  2197. /// <conditional-body>
  2198. /// \endcode
  2199. ///
  2200. /// In the .clang-format configuration file, this can be configured like:
  2201. /// \code{.yaml}
  2202. /// IfMacros: ['IF']
  2203. /// \endcode
  2204. ///
  2205. /// For example: `KJ_IF_MAYBE
  2206. /// <https://github.com/capnproto/capnproto/blob/master/kjdoc/tour.md#maybes>`_
  2207. /// \version 14
  2208. std::vector<std::string> IfMacros;
  2209. /// \brief A vector of macros that should be interpreted as type declarations
  2210. /// instead of as function calls.
  2211. ///
  2212. /// These are expected to be macros of the form:
  2213. /// \code
  2214. /// STACK_OF(...)
  2215. /// \endcode
  2216. ///
  2217. /// In the .clang-format configuration file, this can be configured like:
  2218. /// \code{.yaml}
  2219. /// TypenameMacros: ['STACK_OF', 'LIST']
  2220. /// \endcode
  2221. ///
  2222. /// For example: OpenSSL STACK_OF, BSD LIST_ENTRY.
  2223. /// \version 9
  2224. std::vector<std::string> TypenameMacros;
  2225. /// A vector of macros that should be interpreted as complete
  2226. /// statements.
  2227. ///
  2228. /// Typical macros are expressions, and require a semi-colon to be
  2229. /// added; sometimes this is not the case, and this allows to make
  2230. /// clang-format aware of such cases.
  2231. ///
  2232. /// For example: Q_UNUSED
  2233. /// \version 8
  2234. std::vector<std::string> StatementMacros;
  2235. /// A vector of macros which are used to open namespace blocks.
  2236. ///
  2237. /// These are expected to be macros of the form:
  2238. /// \code
  2239. /// NAMESPACE(<namespace-name>, ...) {
  2240. /// <namespace-content>
  2241. /// }
  2242. /// \endcode
  2243. ///
  2244. /// For example: TESTSUITE
  2245. /// \version 9
  2246. std::vector<std::string> NamespaceMacros;
  2247. /// A vector of macros which are whitespace-sensitive and should not
  2248. /// be touched.
  2249. ///
  2250. /// These are expected to be macros of the form:
  2251. /// \code
  2252. /// STRINGIZE(...)
  2253. /// \endcode
  2254. ///
  2255. /// In the .clang-format configuration file, this can be configured like:
  2256. /// \code{.yaml}
  2257. /// WhitespaceSensitiveMacros: ['STRINGIZE', 'PP_STRINGIZE']
  2258. /// \endcode
  2259. ///
  2260. /// For example: BOOST_PP_STRINGIZE
  2261. /// \version 12
  2262. std::vector<std::string> WhitespaceSensitiveMacros;
  2263. tooling::IncludeStyle IncludeStyle;
  2264. /// Specify whether access modifiers should have their own indentation level.
  2265. ///
  2266. /// When ``false``, access modifiers are indented (or outdented) relative to
  2267. /// the record members, respecting the ``AccessModifierOffset``. Record
  2268. /// members are indented one level below the record.
  2269. /// When ``true``, access modifiers get their own indentation level. As a
  2270. /// consequence, record members are always indented 2 levels below the record,
  2271. /// regardless of the access modifier presence. Value of the
  2272. /// ``AccessModifierOffset`` is ignored.
  2273. /// \code
  2274. /// false: true:
  2275. /// class C { vs. class C {
  2276. /// class D { class D {
  2277. /// void bar(); void bar();
  2278. /// protected: protected:
  2279. /// D(); D();
  2280. /// }; };
  2281. /// public: public:
  2282. /// C(); C();
  2283. /// }; };
  2284. /// void foo() { void foo() {
  2285. /// return 1; return 1;
  2286. /// } }
  2287. /// \endcode
  2288. /// \version 13
  2289. bool IndentAccessModifiers;
  2290. /// Indent case labels one level from the switch statement.
  2291. ///
  2292. /// When ``false``, use the same indentation level as for the switch
  2293. /// statement. Switch statement body is always indented one level more than
  2294. /// case labels (except the first block following the case label, which
  2295. /// itself indents the code - unless IndentCaseBlocks is enabled).
  2296. /// \code
  2297. /// false: true:
  2298. /// switch (fool) { vs. switch (fool) {
  2299. /// case 1: case 1:
  2300. /// bar(); bar();
  2301. /// break; break;
  2302. /// default: default:
  2303. /// plop(); plop();
  2304. /// } }
  2305. /// \endcode
  2306. /// \version 3.3
  2307. bool IndentCaseLabels;
  2308. /// Indent case label blocks one level from the case label.
  2309. ///
  2310. /// When ``false``, the block following the case label uses the same
  2311. /// indentation level as for the case label, treating the case label the same
  2312. /// as an if-statement.
  2313. /// When ``true``, the block gets indented as a scope block.
  2314. /// \code
  2315. /// false: true:
  2316. /// switch (fool) { vs. switch (fool) {
  2317. /// case 1: { case 1:
  2318. /// bar(); {
  2319. /// } break; bar();
  2320. /// default: { }
  2321. /// plop(); break;
  2322. /// } default:
  2323. /// } {
  2324. /// plop();
  2325. /// }
  2326. /// }
  2327. /// \endcode
  2328. /// \version 11
  2329. bool IndentCaseBlocks;
  2330. /// Indent goto labels.
  2331. ///
  2332. /// When ``false``, goto labels are flushed left.
  2333. /// \code
  2334. /// true: false:
  2335. /// int f() { vs. int f() {
  2336. /// if (foo()) { if (foo()) {
  2337. /// label1: label1:
  2338. /// bar(); bar();
  2339. /// } }
  2340. /// label2: label2:
  2341. /// return 1; return 1;
  2342. /// } }
  2343. /// \endcode
  2344. /// \version 10
  2345. bool IndentGotoLabels;
  2346. /// Options for indenting preprocessor directives.
  2347. enum PPDirectiveIndentStyle : unsigned char {
  2348. /// Does not indent any directives.
  2349. /// \code
  2350. /// #if FOO
  2351. /// #if BAR
  2352. /// #include <foo>
  2353. /// #endif
  2354. /// #endif
  2355. /// \endcode
  2356. PPDIS_None,
  2357. /// Indents directives after the hash.
  2358. /// \code
  2359. /// #if FOO
  2360. /// # if BAR
  2361. /// # include <foo>
  2362. /// # endif
  2363. /// #endif
  2364. /// \endcode
  2365. PPDIS_AfterHash,
  2366. /// Indents directives before the hash.
  2367. /// \code
  2368. /// #if FOO
  2369. /// #if BAR
  2370. /// #include <foo>
  2371. /// #endif
  2372. /// #endif
  2373. /// \endcode
  2374. PPDIS_BeforeHash
  2375. };
  2376. /// The preprocessor directive indenting style to use.
  2377. /// \version 6
  2378. PPDirectiveIndentStyle IndentPPDirectives;
  2379. /// Indents extern blocks
  2380. enum IndentExternBlockStyle : unsigned char {
  2381. /// Backwards compatible with AfterExternBlock's indenting.
  2382. /// \code
  2383. /// IndentExternBlock: AfterExternBlock
  2384. /// BraceWrapping.AfterExternBlock: true
  2385. /// extern "C"
  2386. /// {
  2387. /// void foo();
  2388. /// }
  2389. /// \endcode
  2390. ///
  2391. /// \code
  2392. /// IndentExternBlock: AfterExternBlock
  2393. /// BraceWrapping.AfterExternBlock: false
  2394. /// extern "C" {
  2395. /// void foo();
  2396. /// }
  2397. /// \endcode
  2398. IEBS_AfterExternBlock,
  2399. /// Does not indent extern blocks.
  2400. /// \code
  2401. /// extern "C" {
  2402. /// void foo();
  2403. /// }
  2404. /// \endcode
  2405. IEBS_NoIndent,
  2406. /// Indents extern blocks.
  2407. /// \code
  2408. /// extern "C" {
  2409. /// void foo();
  2410. /// }
  2411. /// \endcode
  2412. IEBS_Indent,
  2413. };
  2414. /// IndentExternBlockStyle is the type of indenting of extern blocks.
  2415. /// \version 12
  2416. IndentExternBlockStyle IndentExternBlock;
  2417. /// Indent the requires clause in a template
  2418. /// \code
  2419. /// true:
  2420. /// template <typename It>
  2421. /// requires Iterator<It>
  2422. /// void sort(It begin, It end) {
  2423. /// //....
  2424. /// }
  2425. ///
  2426. /// false:
  2427. /// template <typename It>
  2428. /// requires Iterator<It>
  2429. /// void sort(It begin, It end) {
  2430. /// //....
  2431. /// }
  2432. /// \endcode
  2433. /// \version 13
  2434. bool IndentRequires;
  2435. /// The number of columns to use for indentation.
  2436. /// \code
  2437. /// IndentWidth: 3
  2438. ///
  2439. /// void f() {
  2440. /// someFunction();
  2441. /// if (true, false) {
  2442. /// f();
  2443. /// }
  2444. /// }
  2445. /// \endcode
  2446. /// \version 3.7
  2447. unsigned IndentWidth;
  2448. /// Indent if a function definition or declaration is wrapped after the
  2449. /// type.
  2450. /// \code
  2451. /// true:
  2452. /// LoooooooooooooooooooooooooooooooooooooooongReturnType
  2453. /// LoooooooooooooooooooooooooooooooongFunctionDeclaration();
  2454. ///
  2455. /// false:
  2456. /// LoooooooooooooooooooooooooooooooooooooooongReturnType
  2457. /// LoooooooooooooooooooooooooooooooongFunctionDeclaration();
  2458. /// \endcode
  2459. /// \version 3.7
  2460. bool IndentWrappedFunctionNames;
  2461. /// A vector of prefixes ordered by the desired groups for Java imports.
  2462. ///
  2463. /// One group's prefix can be a subset of another - the longest prefix is
  2464. /// always matched. Within a group, the imports are ordered lexicographically.
  2465. /// Static imports are grouped separately and follow the same group rules.
  2466. /// By default, static imports are placed before non-static imports,
  2467. /// but this behavior is changed by another option,
  2468. /// ``SortJavaStaticImport``.
  2469. ///
  2470. /// In the .clang-format configuration file, this can be configured like
  2471. /// in the following yaml example. This will result in imports being
  2472. /// formatted as in the Java example below.
  2473. /// \code{.yaml}
  2474. /// JavaImportGroups: ['com.example', 'com', 'org']
  2475. /// \endcode
  2476. ///
  2477. /// \code{.java}
  2478. /// import static com.example.function1;
  2479. ///
  2480. /// import static com.test.function2;
  2481. ///
  2482. /// import static org.example.function3;
  2483. ///
  2484. /// import com.example.ClassA;
  2485. /// import com.example.Test;
  2486. /// import com.example.a.ClassB;
  2487. ///
  2488. /// import com.test.ClassC;
  2489. ///
  2490. /// import org.example.ClassD;
  2491. /// \endcode
  2492. /// \version 8
  2493. std::vector<std::string> JavaImportGroups;
  2494. /// Quotation styles for JavaScript strings. Does not affect template
  2495. /// strings.
  2496. enum JavaScriptQuoteStyle : unsigned char {
  2497. /// Leave string quotes as they are.
  2498. /// \code{.js}
  2499. /// string1 = "foo";
  2500. /// string2 = 'bar';
  2501. /// \endcode
  2502. JSQS_Leave,
  2503. /// Always use single quotes.
  2504. /// \code{.js}
  2505. /// string1 = 'foo';
  2506. /// string2 = 'bar';
  2507. /// \endcode
  2508. JSQS_Single,
  2509. /// Always use double quotes.
  2510. /// \code{.js}
  2511. /// string1 = "foo";
  2512. /// string2 = "bar";
  2513. /// \endcode
  2514. JSQS_Double
  2515. };
  2516. /// The JavaScriptQuoteStyle to use for JavaScript strings.
  2517. /// \version 3.9
  2518. JavaScriptQuoteStyle JavaScriptQuotes;
  2519. // clang-format off
  2520. /// Whether to wrap JavaScript import/export statements.
  2521. /// \code{.js}
  2522. /// true:
  2523. /// import {
  2524. /// VeryLongImportsAreAnnoying,
  2525. /// VeryLongImportsAreAnnoying,
  2526. /// VeryLongImportsAreAnnoying,
  2527. /// } from 'some/module.js'
  2528. ///
  2529. /// false:
  2530. /// import {VeryLongImportsAreAnnoying, VeryLongImportsAreAnnoying, VeryLongImportsAreAnnoying,} from "some/module.js"
  2531. /// \endcode
  2532. /// \version 3.9
  2533. bool JavaScriptWrapImports;
  2534. // clang-format on
  2535. /// If true, the empty line at the start of blocks is kept.
  2536. /// \code
  2537. /// true: false:
  2538. /// if (foo) { vs. if (foo) {
  2539. /// bar();
  2540. /// bar(); }
  2541. /// }
  2542. /// \endcode
  2543. /// \version 3.7
  2544. bool KeepEmptyLinesAtTheStartOfBlocks;
  2545. /// Supported languages.
  2546. ///
  2547. /// When stored in a configuration file, specifies the language, that the
  2548. /// configuration targets. When passed to the ``reformat()`` function, enables
  2549. /// syntax features specific to the language.
  2550. enum LanguageKind : unsigned char {
  2551. /// Do not use.
  2552. LK_None,
  2553. /// Should be used for C, C++.
  2554. LK_Cpp,
  2555. /// Should be used for C#.
  2556. LK_CSharp,
  2557. /// Should be used for Java.
  2558. LK_Java,
  2559. /// Should be used for JavaScript.
  2560. LK_JavaScript,
  2561. /// Should be used for JSON.
  2562. LK_Json,
  2563. /// Should be used for Objective-C, Objective-C++.
  2564. LK_ObjC,
  2565. /// Should be used for Protocol Buffers
  2566. /// (https://developers.google.com/protocol-buffers/).
  2567. LK_Proto,
  2568. /// Should be used for TableGen code.
  2569. LK_TableGen,
  2570. /// Should be used for Protocol Buffer messages in text format
  2571. /// (https://developers.google.com/protocol-buffers/).
  2572. LK_TextProto
  2573. };
  2574. bool isCpp() const { return Language == LK_Cpp || Language == LK_ObjC; }
  2575. bool isCSharp() const { return Language == LK_CSharp; }
  2576. bool isJson() const { return Language == LK_Json; }
  2577. bool isJavaScript() const { return Language == LK_JavaScript; }
  2578. /// Language, this format style is targeted at.
  2579. /// \version 3.5
  2580. LanguageKind Language;
  2581. /// Indentation logic for lambda bodies.
  2582. enum LambdaBodyIndentationKind : unsigned char {
  2583. /// Align lambda body relative to the lambda signature. This is the default.
  2584. /// \code
  2585. /// someMethod(
  2586. /// [](SomeReallyLongLambdaSignatureArgument foo) {
  2587. /// return;
  2588. /// });
  2589. /// \endcode
  2590. LBI_Signature,
  2591. /// Align lambda body relative to the indentation level of the outer scope
  2592. /// the lambda signature resides in.
  2593. /// \code
  2594. /// someMethod(
  2595. /// [](SomeReallyLongLambdaSignatureArgument foo) {
  2596. /// return;
  2597. /// });
  2598. /// \endcode
  2599. LBI_OuterScope,
  2600. };
  2601. /// The indentation style of lambda bodies. ``Signature`` (the default)
  2602. /// causes the lambda body to be indented one additional level relative to
  2603. /// the indentation level of the signature. ``OuterScope`` forces the lambda
  2604. /// body to be indented one additional level relative to the parent scope
  2605. /// containing the lambda signature. For callback-heavy code, it may improve
  2606. /// readability to have the signature indented two levels and to use
  2607. /// ``OuterScope``. The KJ style guide requires ``OuterScope``.
  2608. /// `KJ style guide
  2609. /// <https://github.com/capnproto/capnproto/blob/master/style-guide.md>`_
  2610. /// \version 13
  2611. LambdaBodyIndentationKind LambdaBodyIndentation;
  2612. /// A regular expression matching macros that start a block.
  2613. /// \code
  2614. /// # With:
  2615. /// MacroBlockBegin: "^NS_MAP_BEGIN|\
  2616. /// NS_TABLE_HEAD$"
  2617. /// MacroBlockEnd: "^\
  2618. /// NS_MAP_END|\
  2619. /// NS_TABLE_.*_END$"
  2620. ///
  2621. /// NS_MAP_BEGIN
  2622. /// foo();
  2623. /// NS_MAP_END
  2624. ///
  2625. /// NS_TABLE_HEAD
  2626. /// bar();
  2627. /// NS_TABLE_FOO_END
  2628. ///
  2629. /// # Without:
  2630. /// NS_MAP_BEGIN
  2631. /// foo();
  2632. /// NS_MAP_END
  2633. ///
  2634. /// NS_TABLE_HEAD
  2635. /// bar();
  2636. /// NS_TABLE_FOO_END
  2637. /// \endcode
  2638. /// \version 3.7
  2639. std::string MacroBlockBegin;
  2640. /// A regular expression matching macros that end a block.
  2641. /// \version 3.7
  2642. std::string MacroBlockEnd;
  2643. /// The maximum number of consecutive empty lines to keep.
  2644. /// \code
  2645. /// MaxEmptyLinesToKeep: 1 vs. MaxEmptyLinesToKeep: 0
  2646. /// int f() { int f() {
  2647. /// int = 1; int i = 1;
  2648. /// i = foo();
  2649. /// i = foo(); return i;
  2650. /// }
  2651. /// return i;
  2652. /// }
  2653. /// \endcode
  2654. /// \version 3.7
  2655. unsigned MaxEmptyLinesToKeep;
  2656. /// Different ways to indent namespace contents.
  2657. enum NamespaceIndentationKind : unsigned char {
  2658. /// Don't indent in namespaces.
  2659. /// \code
  2660. /// namespace out {
  2661. /// int i;
  2662. /// namespace in {
  2663. /// int i;
  2664. /// }
  2665. /// }
  2666. /// \endcode
  2667. NI_None,
  2668. /// Indent only in inner namespaces (nested in other namespaces).
  2669. /// \code
  2670. /// namespace out {
  2671. /// int i;
  2672. /// namespace in {
  2673. /// int i;
  2674. /// }
  2675. /// }
  2676. /// \endcode
  2677. NI_Inner,
  2678. /// Indent in all namespaces.
  2679. /// \code
  2680. /// namespace out {
  2681. /// int i;
  2682. /// namespace in {
  2683. /// int i;
  2684. /// }
  2685. /// }
  2686. /// \endcode
  2687. NI_All
  2688. };
  2689. /// The indentation used for namespaces.
  2690. /// \version 3.7
  2691. NamespaceIndentationKind NamespaceIndentation;
  2692. /// Controls bin-packing Objective-C protocol conformance list
  2693. /// items into as few lines as possible when they go over ``ColumnLimit``.
  2694. ///
  2695. /// If ``Auto`` (the default), delegates to the value in
  2696. /// ``BinPackParameters``. If that is ``true``, bin-packs Objective-C
  2697. /// protocol conformance list items into as few lines as possible
  2698. /// whenever they go over ``ColumnLimit``.
  2699. ///
  2700. /// If ``Always``, always bin-packs Objective-C protocol conformance
  2701. /// list items into as few lines as possible whenever they go over
  2702. /// ``ColumnLimit``.
  2703. ///
  2704. /// If ``Never``, lays out Objective-C protocol conformance list items
  2705. /// onto individual lines whenever they go over ``ColumnLimit``.
  2706. ///
  2707. /// \code{.objc}
  2708. /// Always (or Auto, if BinPackParameters=true):
  2709. /// @interface ccccccccccccc () <
  2710. /// ccccccccccccc, ccccccccccccc,
  2711. /// ccccccccccccc, ccccccccccccc> {
  2712. /// }
  2713. ///
  2714. /// Never (or Auto, if BinPackParameters=false):
  2715. /// @interface ddddddddddddd () <
  2716. /// ddddddddddddd,
  2717. /// ddddddddddddd,
  2718. /// ddddddddddddd,
  2719. /// ddddddddddddd> {
  2720. /// }
  2721. /// \endcode
  2722. /// \version 7
  2723. BinPackStyle ObjCBinPackProtocolList;
  2724. /// The number of characters to use for indentation of ObjC blocks.
  2725. /// \code{.objc}
  2726. /// ObjCBlockIndentWidth: 4
  2727. ///
  2728. /// [operation setCompletionBlock:^{
  2729. /// [self onOperationDone];
  2730. /// }];
  2731. /// \endcode
  2732. /// \version 3.7
  2733. unsigned ObjCBlockIndentWidth;
  2734. /// Add a space after ``@property`` in Objective-C, i.e. use
  2735. /// ``@property (readonly)`` instead of ``@property(readonly)``.
  2736. /// \version 3.7
  2737. bool ObjCSpaceAfterProperty;
  2738. /// Break parameters list into lines when there is nested block
  2739. /// parameters in a function call.
  2740. /// \code
  2741. /// false:
  2742. /// - (void)_aMethod
  2743. /// {
  2744. /// [self.test1 t:self w:self callback:^(typeof(self) self, NSNumber
  2745. /// *u, NSNumber *v) {
  2746. /// u = c;
  2747. /// }]
  2748. /// }
  2749. /// true:
  2750. /// - (void)_aMethod
  2751. /// {
  2752. /// [self.test1 t:self
  2753. /// w:self
  2754. /// callback:^(typeof(self) self, NSNumber *u, NSNumber *v) {
  2755. /// u = c;
  2756. /// }]
  2757. /// }
  2758. /// \endcode
  2759. /// \version 12
  2760. bool ObjCBreakBeforeNestedBlockParam;
  2761. /// Add a space in front of an Objective-C protocol list, i.e. use
  2762. /// ``Foo <Protocol>`` instead of ``Foo<Protocol>``.
  2763. /// \version 3.7
  2764. bool ObjCSpaceBeforeProtocolList;
  2765. /// The penalty for breaking around an assignment operator.
  2766. /// \version 5
  2767. unsigned PenaltyBreakAssignment;
  2768. /// The penalty for breaking a function call after ``call(``.
  2769. /// \version 3.7
  2770. unsigned PenaltyBreakBeforeFirstCallParameter;
  2771. /// The penalty for each line break introduced inside a comment.
  2772. /// \version 3.7
  2773. unsigned PenaltyBreakComment;
  2774. /// The penalty for breaking before the first ``<<``.
  2775. /// \version 3.7
  2776. unsigned PenaltyBreakFirstLessLess;
  2777. /// The penalty for breaking after ``(``.
  2778. /// \version 14
  2779. unsigned PenaltyBreakOpenParenthesis;
  2780. /// The penalty for each line break introduced inside a string literal.
  2781. /// \version 3.7
  2782. unsigned PenaltyBreakString;
  2783. /// The penalty for breaking after template declaration.
  2784. /// \version 7
  2785. unsigned PenaltyBreakTemplateDeclaration;
  2786. /// The penalty for each character outside of the column limit.
  2787. /// \version 3.7
  2788. unsigned PenaltyExcessCharacter;
  2789. /// Penalty for putting the return type of a function onto its own
  2790. /// line.
  2791. /// \version 3.7
  2792. unsigned PenaltyReturnTypeOnItsOwnLine;
  2793. /// Penalty for each character of whitespace indentation
  2794. /// (counted relative to leading non-whitespace column).
  2795. /// \version 12
  2796. unsigned PenaltyIndentedWhitespace;
  2797. /// The ``&``, ``&&`` and ``*`` alignment style.
  2798. enum PointerAlignmentStyle : unsigned char {
  2799. /// Align pointer to the left.
  2800. /// \code
  2801. /// int* a;
  2802. /// \endcode
  2803. PAS_Left,
  2804. /// Align pointer to the right.
  2805. /// \code
  2806. /// int *a;
  2807. /// \endcode
  2808. PAS_Right,
  2809. /// Align pointer in the middle.
  2810. /// \code
  2811. /// int * a;
  2812. /// \endcode
  2813. PAS_Middle
  2814. };
  2815. /// Pointer and reference alignment style.
  2816. /// \version 3.7
  2817. PointerAlignmentStyle PointerAlignment;
  2818. /// The number of columns to use for indentation of preprocessor statements.
  2819. /// When set to -1 (default) ``IndentWidth`` is used also for preprocessor
  2820. /// statements.
  2821. /// \code
  2822. /// PPIndentWidth: 1
  2823. ///
  2824. /// #ifdef __linux__
  2825. /// # define FOO
  2826. /// #else
  2827. /// # define BAR
  2828. /// #endif
  2829. /// \endcode
  2830. /// \version 14
  2831. int PPIndentWidth;
  2832. /// See documentation of ``RawStringFormats``.
  2833. struct RawStringFormat {
  2834. /// The language of this raw string.
  2835. LanguageKind Language;
  2836. /// A list of raw string delimiters that match this language.
  2837. std::vector<std::string> Delimiters;
  2838. /// A list of enclosing function names that match this language.
  2839. std::vector<std::string> EnclosingFunctions;
  2840. /// The canonical delimiter for this language.
  2841. std::string CanonicalDelimiter;
  2842. /// The style name on which this raw string format is based on.
  2843. /// If not specified, the raw string format is based on the style that this
  2844. /// format is based on.
  2845. std::string BasedOnStyle;
  2846. bool operator==(const RawStringFormat &Other) const {
  2847. return Language == Other.Language && Delimiters == Other.Delimiters &&
  2848. EnclosingFunctions == Other.EnclosingFunctions &&
  2849. CanonicalDelimiter == Other.CanonicalDelimiter &&
  2850. BasedOnStyle == Other.BasedOnStyle;
  2851. }
  2852. };
  2853. /// Defines hints for detecting supported languages code blocks in raw
  2854. /// strings.
  2855. ///
  2856. /// A raw string with a matching delimiter or a matching enclosing function
  2857. /// name will be reformatted assuming the specified language based on the
  2858. /// style for that language defined in the .clang-format file. If no style has
  2859. /// been defined in the .clang-format file for the specific language, a
  2860. /// predefined style given by 'BasedOnStyle' is used. If 'BasedOnStyle' is not
  2861. /// found, the formatting is based on llvm style. A matching delimiter takes
  2862. /// precedence over a matching enclosing function name for determining the
  2863. /// language of the raw string contents.
  2864. ///
  2865. /// If a canonical delimiter is specified, occurrences of other delimiters for
  2866. /// the same language will be updated to the canonical if possible.
  2867. ///
  2868. /// There should be at most one specification per language and each delimiter
  2869. /// and enclosing function should not occur in multiple specifications.
  2870. ///
  2871. /// To configure this in the .clang-format file, use:
  2872. /// \code{.yaml}
  2873. /// RawStringFormats:
  2874. /// - Language: TextProto
  2875. /// Delimiters:
  2876. /// - 'pb'
  2877. /// - 'proto'
  2878. /// EnclosingFunctions:
  2879. /// - 'PARSE_TEXT_PROTO'
  2880. /// BasedOnStyle: google
  2881. /// - Language: Cpp
  2882. /// Delimiters:
  2883. /// - 'cc'
  2884. /// - 'cpp'
  2885. /// BasedOnStyle: llvm
  2886. /// CanonicalDelimiter: 'cc'
  2887. /// \endcode
  2888. /// \version 6
  2889. std::vector<RawStringFormat> RawStringFormats;
  2890. /// \brief The ``&`` and ``&&`` alignment style.
  2891. enum ReferenceAlignmentStyle {
  2892. /// Align reference like ``PointerAlignment``.
  2893. RAS_Pointer,
  2894. /// Align reference to the left.
  2895. /// \code
  2896. /// int& a;
  2897. /// \endcode
  2898. RAS_Left,
  2899. /// Align reference to the right.
  2900. /// \code
  2901. /// int &a;
  2902. /// \endcode
  2903. RAS_Right,
  2904. /// Align reference in the middle.
  2905. /// \code
  2906. /// int & a;
  2907. /// \endcode
  2908. RAS_Middle
  2909. };
  2910. /// \brief Reference alignment style (overrides ``PointerAlignment`` for
  2911. /// references).
  2912. /// \version 14
  2913. ReferenceAlignmentStyle ReferenceAlignment;
  2914. // clang-format off
  2915. /// If ``true``, clang-format will attempt to re-flow comments.
  2916. /// \code
  2917. /// false:
  2918. /// // veryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryLongComment with plenty of information
  2919. /// /* second veryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryLongComment with plenty of information */
  2920. ///
  2921. /// true:
  2922. /// // veryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryLongComment with plenty of
  2923. /// // information
  2924. /// /* second veryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryLongComment with plenty of
  2925. /// * information */
  2926. /// \endcode
  2927. /// \version 4
  2928. bool ReflowComments;
  2929. // clang-format on
  2930. /// Remove optional braces of control statements (``if``, ``else``, ``for``,
  2931. /// and ``while``) in C++ according to the LLVM coding style.
  2932. /// \warning
  2933. /// This option will be renamed and expanded to support other styles.
  2934. /// \endwarning
  2935. /// \warning
  2936. /// Setting this option to `true` could lead to incorrect code formatting due
  2937. /// to clang-format's lack of complete semantic information. As such, extra
  2938. /// care should be taken to review code changes made by this option.
  2939. /// \endwarning
  2940. /// \code
  2941. /// false: true:
  2942. ///
  2943. /// if (isa<FunctionDecl>(D)) { vs. if (isa<FunctionDecl>(D))
  2944. /// handleFunctionDecl(D); handleFunctionDecl(D);
  2945. /// } else if (isa<VarDecl>(D)) { else if (isa<VarDecl>(D))
  2946. /// handleVarDecl(D); handleVarDecl(D);
  2947. /// }
  2948. ///
  2949. /// if (isa<VarDecl>(D)) { vs. if (isa<VarDecl>(D)) {
  2950. /// for (auto *A : D.attrs()) { for (auto *A : D.attrs())
  2951. /// if (shouldProcessAttr(A)) { if (shouldProcessAttr(A))
  2952. /// handleAttr(A); handleAttr(A);
  2953. /// } }
  2954. /// }
  2955. /// }
  2956. ///
  2957. /// if (isa<FunctionDecl>(D)) { vs. if (isa<FunctionDecl>(D))
  2958. /// for (auto *A : D.attrs()) { for (auto *A : D.attrs())
  2959. /// handleAttr(A); handleAttr(A);
  2960. /// }
  2961. /// }
  2962. ///
  2963. /// if (auto *D = (T)(D)) { vs. if (auto *D = (T)(D)) {
  2964. /// if (shouldProcess(D)) { if (shouldProcess(D))
  2965. /// handleVarDecl(D); handleVarDecl(D);
  2966. /// } else { else
  2967. /// markAsIgnored(D); markAsIgnored(D);
  2968. /// } }
  2969. /// }
  2970. ///
  2971. /// if (a) { vs. if (a)
  2972. /// b(); b();
  2973. /// } else { else if (c)
  2974. /// if (c) { d();
  2975. /// d(); else
  2976. /// } else { e();
  2977. /// e();
  2978. /// }
  2979. /// }
  2980. /// \endcode
  2981. /// \version 14
  2982. bool RemoveBracesLLVM;
  2983. /// \brief The style if definition blocks should be separated.
  2984. enum SeparateDefinitionStyle {
  2985. /// Leave definition blocks as they are.
  2986. SDS_Leave,
  2987. /// Insert an empty line between definition blocks.
  2988. SDS_Always,
  2989. /// Remove any empty line between definition blocks.
  2990. SDS_Never
  2991. };
  2992. /// Specifies the use of empty lines to separate definition blocks, including
  2993. /// classes, structs, enums, and functions.
  2994. /// \code
  2995. /// Never v.s. Always
  2996. /// #include <cstring> #include <cstring>
  2997. /// struct Foo {
  2998. /// int a, b, c; struct Foo {
  2999. /// }; int a, b, c;
  3000. /// namespace Ns { };
  3001. /// class Bar {
  3002. /// public: namespace Ns {
  3003. /// struct Foobar { class Bar {
  3004. /// int a; public:
  3005. /// int b; struct Foobar {
  3006. /// }; int a;
  3007. /// private: int b;
  3008. /// int t; };
  3009. /// int method1() {
  3010. /// // ... private:
  3011. /// } int t;
  3012. /// enum List {
  3013. /// ITEM1, int method1() {
  3014. /// ITEM2 // ...
  3015. /// }; }
  3016. /// template<typename T>
  3017. /// int method2(T x) { enum List {
  3018. /// // ... ITEM1,
  3019. /// } ITEM2
  3020. /// int i, j, k; };
  3021. /// int method3(int par) {
  3022. /// // ... template<typename T>
  3023. /// } int method2(T x) {
  3024. /// }; // ...
  3025. /// class C {}; }
  3026. /// }
  3027. /// int i, j, k;
  3028. ///
  3029. /// int method3(int par) {
  3030. /// // ...
  3031. /// }
  3032. /// };
  3033. ///
  3034. /// class C {};
  3035. /// }
  3036. /// \endcode
  3037. /// \version 14
  3038. SeparateDefinitionStyle SeparateDefinitionBlocks;
  3039. /// The maximal number of unwrapped lines that a short namespace spans.
  3040. /// Defaults to 1.
  3041. ///
  3042. /// This determines the maximum length of short namespaces by counting
  3043. /// unwrapped lines (i.e. containing neither opening nor closing
  3044. /// namespace brace) and makes "FixNamespaceComments" omit adding
  3045. /// end comments for those.
  3046. /// \code
  3047. /// ShortNamespaceLines: 1 vs. ShortNamespaceLines: 0
  3048. /// namespace a { namespace a {
  3049. /// int foo; int foo;
  3050. /// } } // namespace a
  3051. ///
  3052. /// ShortNamespaceLines: 1 vs. ShortNamespaceLines: 0
  3053. /// namespace b { namespace b {
  3054. /// int foo; int foo;
  3055. /// int bar; int bar;
  3056. /// } // namespace b } // namespace b
  3057. /// \endcode
  3058. /// \version 14
  3059. unsigned ShortNamespaceLines;
  3060. /// Include sorting options.
  3061. enum SortIncludesOptions : unsigned char {
  3062. /// Includes are never sorted.
  3063. /// \code
  3064. /// #include "B/A.h"
  3065. /// #include "A/B.h"
  3066. /// #include "a/b.h"
  3067. /// #include "A/b.h"
  3068. /// #include "B/a.h"
  3069. /// \endcode
  3070. SI_Never,
  3071. /// Includes are sorted in an ASCIIbetical or case sensitive fashion.
  3072. /// \code
  3073. /// #include "A/B.h"
  3074. /// #include "A/b.h"
  3075. /// #include "B/A.h"
  3076. /// #include "B/a.h"
  3077. /// #include "a/b.h"
  3078. /// \endcode
  3079. SI_CaseSensitive,
  3080. /// Includes are sorted in an alphabetical or case insensitive fashion.
  3081. /// \code
  3082. /// #include "A/B.h"
  3083. /// #include "A/b.h"
  3084. /// #include "a/b.h"
  3085. /// #include "B/A.h"
  3086. /// #include "B/a.h"
  3087. /// \endcode
  3088. SI_CaseInsensitive,
  3089. };
  3090. /// Controls if and how clang-format will sort ``#includes``.
  3091. /// If ``Never``, includes are never sorted.
  3092. /// If ``CaseInsensitive``, includes are sorted in an ASCIIbetical or case
  3093. /// insensitive fashion.
  3094. /// If ``CaseSensitive``, includes are sorted in an alphabetical or case
  3095. /// sensitive fashion.
  3096. /// \version 4
  3097. SortIncludesOptions SortIncludes;
  3098. /// Position for Java Static imports.
  3099. enum SortJavaStaticImportOptions : unsigned char {
  3100. /// Static imports are placed before non-static imports.
  3101. /// \code{.java}
  3102. /// import static org.example.function1;
  3103. ///
  3104. /// import org.example.ClassA;
  3105. /// \endcode
  3106. SJSIO_Before,
  3107. /// Static imports are placed after non-static imports.
  3108. /// \code{.java}
  3109. /// import org.example.ClassA;
  3110. ///
  3111. /// import static org.example.function1;
  3112. /// \endcode
  3113. SJSIO_After,
  3114. };
  3115. /// When sorting Java imports, by default static imports are placed before
  3116. /// non-static imports. If ``JavaStaticImportAfterImport`` is ``After``,
  3117. /// static imports are placed after non-static imports.
  3118. /// \version 12
  3119. SortJavaStaticImportOptions SortJavaStaticImport;
  3120. /// If ``true``, clang-format will sort using declarations.
  3121. ///
  3122. /// The order of using declarations is defined as follows:
  3123. /// Split the strings by "::" and discard any initial empty strings. The last
  3124. /// element of each list is a non-namespace name; all others are namespace
  3125. /// names. Sort the lists of names lexicographically, where the sort order of
  3126. /// individual names is that all non-namespace names come before all namespace
  3127. /// names, and within those groups, names are in case-insensitive
  3128. /// lexicographic order.
  3129. /// \code
  3130. /// false: true:
  3131. /// using std::cout; vs. using std::cin;
  3132. /// using std::cin; using std::cout;
  3133. /// \endcode
  3134. /// \version 5
  3135. bool SortUsingDeclarations;
  3136. /// If ``true``, a space is inserted after C style casts.
  3137. /// \code
  3138. /// true: false:
  3139. /// (int) i; vs. (int)i;
  3140. /// \endcode
  3141. /// \version 3.5
  3142. bool SpaceAfterCStyleCast;
  3143. /// If ``true``, a space is inserted after the logical not operator (``!``).
  3144. /// \code
  3145. /// true: false:
  3146. /// ! someExpression(); vs. !someExpression();
  3147. /// \endcode
  3148. /// \version 9
  3149. bool SpaceAfterLogicalNot;
  3150. /// If \c true, a space will be inserted after the 'template' keyword.
  3151. /// \code
  3152. /// true: false:
  3153. /// template <int> void foo(); vs. template<int> void foo();
  3154. /// \endcode
  3155. /// \version 4
  3156. bool SpaceAfterTemplateKeyword;
  3157. /// Different ways to put a space before opening parentheses.
  3158. enum SpaceAroundPointerQualifiersStyle : unsigned char {
  3159. /// Don't ensure spaces around pointer qualifiers and use PointerAlignment
  3160. /// instead.
  3161. /// \code
  3162. /// PointerAlignment: Left PointerAlignment: Right
  3163. /// void* const* x = NULL; vs. void *const *x = NULL;
  3164. /// \endcode
  3165. SAPQ_Default,
  3166. /// Ensure that there is a space before pointer qualifiers.
  3167. /// \code
  3168. /// PointerAlignment: Left PointerAlignment: Right
  3169. /// void* const* x = NULL; vs. void * const *x = NULL;
  3170. /// \endcode
  3171. SAPQ_Before,
  3172. /// Ensure that there is a space after pointer qualifiers.
  3173. /// \code
  3174. /// PointerAlignment: Left PointerAlignment: Right
  3175. /// void* const * x = NULL; vs. void *const *x = NULL;
  3176. /// \endcode
  3177. SAPQ_After,
  3178. /// Ensure that there is a space both before and after pointer qualifiers.
  3179. /// \code
  3180. /// PointerAlignment: Left PointerAlignment: Right
  3181. /// void* const * x = NULL; vs. void * const *x = NULL;
  3182. /// \endcode
  3183. SAPQ_Both,
  3184. };
  3185. /// Defines in which cases to put a space before or after pointer qualifiers
  3186. /// \version 12
  3187. SpaceAroundPointerQualifiersStyle SpaceAroundPointerQualifiers;
  3188. /// If ``false``, spaces will be removed before assignment operators.
  3189. /// \code
  3190. /// true: false:
  3191. /// int a = 5; vs. int a= 5;
  3192. /// a += 42; a+= 42;
  3193. /// \endcode
  3194. /// \version 3.7
  3195. bool SpaceBeforeAssignmentOperators;
  3196. /// If ``false``, spaces will be removed before case colon.
  3197. /// \code
  3198. /// true: false
  3199. /// switch (x) { vs. switch (x) {
  3200. /// case 1 : break; case 1: break;
  3201. /// } }
  3202. /// \endcode
  3203. /// \version 12
  3204. bool SpaceBeforeCaseColon;
  3205. /// If ``true``, a space will be inserted before a C++11 braced list
  3206. /// used to initialize an object (after the preceding identifier or type).
  3207. /// \code
  3208. /// true: false:
  3209. /// Foo foo { bar }; vs. Foo foo{ bar };
  3210. /// Foo {}; Foo{};
  3211. /// vector<int> { 1, 2, 3 }; vector<int>{ 1, 2, 3 };
  3212. /// new int[3] { 1, 2, 3 }; new int[3]{ 1, 2, 3 };
  3213. /// \endcode
  3214. /// \version 7
  3215. bool SpaceBeforeCpp11BracedList;
  3216. /// If ``false``, spaces will be removed before constructor initializer
  3217. /// colon.
  3218. /// \code
  3219. /// true: false:
  3220. /// Foo::Foo() : a(a) {} Foo::Foo(): a(a) {}
  3221. /// \endcode
  3222. /// \version 7
  3223. bool SpaceBeforeCtorInitializerColon;
  3224. /// If ``false``, spaces will be removed before inheritance colon.
  3225. /// \code
  3226. /// true: false:
  3227. /// class Foo : Bar {} vs. class Foo: Bar {}
  3228. /// \endcode
  3229. /// \version 7
  3230. bool SpaceBeforeInheritanceColon;
  3231. /// Different ways to put a space before opening parentheses.
  3232. enum SpaceBeforeParensStyle : unsigned char {
  3233. /// Never put a space before opening parentheses.
  3234. /// \code
  3235. /// void f() {
  3236. /// if(true) {
  3237. /// f();
  3238. /// }
  3239. /// }
  3240. /// \endcode
  3241. SBPO_Never,
  3242. /// Put a space before opening parentheses only after control statement
  3243. /// keywords (``for/if/while...``).
  3244. /// \code
  3245. /// void f() {
  3246. /// if (true) {
  3247. /// f();
  3248. /// }
  3249. /// }
  3250. /// \endcode
  3251. SBPO_ControlStatements,
  3252. /// Same as ``SBPO_ControlStatements`` except this option doesn't apply to
  3253. /// ForEach and If macros. This is useful in projects where ForEach/If
  3254. /// macros are treated as function calls instead of control statements.
  3255. /// ``SBPO_ControlStatementsExceptForEachMacros`` remains an alias for
  3256. /// backward compatibility.
  3257. /// \code
  3258. /// void f() {
  3259. /// Q_FOREACH(...) {
  3260. /// f();
  3261. /// }
  3262. /// }
  3263. /// \endcode
  3264. SBPO_ControlStatementsExceptControlMacros,
  3265. /// Put a space before opening parentheses only if the parentheses are not
  3266. /// empty i.e. '()'
  3267. /// \code
  3268. /// void() {
  3269. /// if (true) {
  3270. /// f();
  3271. /// g (x, y, z);
  3272. /// }
  3273. /// }
  3274. /// \endcode
  3275. SBPO_NonEmptyParentheses,
  3276. /// Always put a space before opening parentheses, except when it's
  3277. /// prohibited by the syntax rules (in function-like macro definitions) or
  3278. /// when determined by other style rules (after unary operators, opening
  3279. /// parentheses, etc.)
  3280. /// \code
  3281. /// void f () {
  3282. /// if (true) {
  3283. /// f ();
  3284. /// }
  3285. /// }
  3286. /// \endcode
  3287. SBPO_Always,
  3288. /// Configure each individual space before parentheses in
  3289. /// `SpaceBeforeParensOptions`.
  3290. SBPO_Custom,
  3291. };
  3292. /// Defines in which cases to put a space before opening parentheses.
  3293. /// \version 3.5
  3294. SpaceBeforeParensStyle SpaceBeforeParens;
  3295. /// Precise control over the spacing before parentheses.
  3296. /// \code
  3297. /// # Should be declared this way:
  3298. /// SpaceBeforeParens: Custom
  3299. /// SpaceBeforeParensOptions:
  3300. /// AfterControlStatements: true
  3301. /// AfterFunctionDefinitionName: true
  3302. /// \endcode
  3303. struct SpaceBeforeParensCustom {
  3304. /// If ``true``, put space betwee control statement keywords
  3305. /// (for/if/while...) and opening parentheses.
  3306. /// \code
  3307. /// true: false:
  3308. /// if (...) {} vs. if(...) {}
  3309. /// \endcode
  3310. bool AfterControlStatements;
  3311. /// If ``true``, put space between foreach macros and opening parentheses.
  3312. /// \code
  3313. /// true: false:
  3314. /// FOREACH (...) vs. FOREACH(...)
  3315. /// <loop-body> <loop-body>
  3316. /// \endcode
  3317. bool AfterForeachMacros;
  3318. /// If ``true``, put a space between function declaration name and opening
  3319. /// parentheses.
  3320. /// \code
  3321. /// true: false:
  3322. /// void f (); vs. void f();
  3323. /// \endcode
  3324. bool AfterFunctionDeclarationName;
  3325. /// If ``true``, put a space between function definition name and opening
  3326. /// parentheses.
  3327. /// \code
  3328. /// true: false:
  3329. /// void f () {} vs. void f() {}
  3330. /// \endcode
  3331. bool AfterFunctionDefinitionName;
  3332. /// If ``true``, put space between if macros and opening parentheses.
  3333. /// \code
  3334. /// true: false:
  3335. /// IF (...) vs. IF(...)
  3336. /// <conditional-body> <conditional-body>
  3337. /// \endcode
  3338. bool AfterIfMacros;
  3339. /// If ``true``, put a space between operator overloading and opening
  3340. /// parentheses.
  3341. /// \code
  3342. /// true: false:
  3343. /// void operator++ (int a); vs. void operator++(int a);
  3344. /// object.operator++ (10); object.operator++(10);
  3345. /// \endcode
  3346. bool AfterOverloadedOperator;
  3347. /// If ``true``, put a space before opening parentheses only if the
  3348. /// parentheses are not empty.
  3349. /// \code
  3350. /// true: false:
  3351. /// void f (int a); vs. void f();
  3352. /// f (a); f();
  3353. /// \endcode
  3354. bool BeforeNonEmptyParentheses;
  3355. SpaceBeforeParensCustom()
  3356. : AfterControlStatements(false), AfterForeachMacros(false),
  3357. AfterFunctionDeclarationName(false),
  3358. AfterFunctionDefinitionName(false), AfterIfMacros(false),
  3359. AfterOverloadedOperator(false), BeforeNonEmptyParentheses(false) {}
  3360. bool operator==(const SpaceBeforeParensCustom &Other) const {
  3361. return AfterControlStatements == Other.AfterControlStatements &&
  3362. AfterForeachMacros == Other.AfterForeachMacros &&
  3363. AfterFunctionDeclarationName ==
  3364. Other.AfterFunctionDeclarationName &&
  3365. AfterFunctionDefinitionName == Other.AfterFunctionDefinitionName &&
  3366. AfterIfMacros == Other.AfterIfMacros &&
  3367. AfterOverloadedOperator == Other.AfterOverloadedOperator &&
  3368. BeforeNonEmptyParentheses == Other.BeforeNonEmptyParentheses;
  3369. }
  3370. };
  3371. /// Control of individual space before parentheses.
  3372. ///
  3373. /// If ``SpaceBeforeParens`` is set to ``Custom``, use this to specify
  3374. /// how each individual space before parentheses case should be handled.
  3375. /// Otherwise, this is ignored.
  3376. /// \code{.yaml}
  3377. /// # Example of usage:
  3378. /// SpaceBeforeParens: Custom
  3379. /// SpaceBeforeParensOptions:
  3380. /// AfterControlStatements: true
  3381. /// AfterFunctionDefinitionName: true
  3382. /// \endcode
  3383. /// \version 14
  3384. SpaceBeforeParensCustom SpaceBeforeParensOptions;
  3385. /// If ``false``, spaces will be removed before range-based for loop
  3386. /// colon.
  3387. /// \code
  3388. /// true: false:
  3389. /// for (auto v : values) {} vs. for(auto v: values) {}
  3390. /// \endcode
  3391. /// \version 7
  3392. bool SpaceBeforeRangeBasedForLoopColon;
  3393. /// If ``true``, spaces will be inserted into ``{}``.
  3394. /// \code
  3395. /// true: false:
  3396. /// void f() { } vs. void f() {}
  3397. /// while (true) { } while (true) {}
  3398. /// \endcode
  3399. /// \version 11
  3400. bool SpaceInEmptyBlock;
  3401. /// If ``true``, spaces may be inserted into ``()``.
  3402. /// \code
  3403. /// true: false:
  3404. /// void f( ) { vs. void f() {
  3405. /// int x[] = {foo( ), bar( )}; int x[] = {foo(), bar()};
  3406. /// if (true) { if (true) {
  3407. /// f( ); f();
  3408. /// } }
  3409. /// } }
  3410. /// \endcode
  3411. /// \version 3.7
  3412. bool SpaceInEmptyParentheses;
  3413. /// The number of spaces before trailing line comments
  3414. /// (``//`` - comments).
  3415. ///
  3416. /// This does not affect trailing block comments (``/*`` - comments) as
  3417. /// those commonly have different usage patterns and a number of special
  3418. /// cases.
  3419. /// \code
  3420. /// SpacesBeforeTrailingComments: 3
  3421. /// void f() {
  3422. /// if (true) { // foo1
  3423. /// f(); // bar
  3424. /// } // foo
  3425. /// }
  3426. /// \endcode
  3427. /// \version 3.7
  3428. unsigned SpacesBeforeTrailingComments;
  3429. /// Styles for adding spacing after ``<`` and before ``>`
  3430. /// in template argument lists.
  3431. enum SpacesInAnglesStyle : unsigned char {
  3432. /// Remove spaces after ``<`` and before ``>``.
  3433. /// \code
  3434. /// static_cast<int>(arg);
  3435. /// std::function<void(int)> fct;
  3436. /// \endcode
  3437. SIAS_Never,
  3438. /// Add spaces after ``<`` and before ``>``.
  3439. /// \code
  3440. /// static_cast< int >(arg);
  3441. /// std::function< void(int) > fct;
  3442. /// \endcode
  3443. SIAS_Always,
  3444. /// Keep a single space after ``<`` and before ``>`` if any spaces were
  3445. /// present. Option ``Standard: Cpp03`` takes precedence.
  3446. SIAS_Leave
  3447. };
  3448. /// The SpacesInAnglesStyle to use for template argument lists.
  3449. /// \version 14
  3450. SpacesInAnglesStyle SpacesInAngles;
  3451. /// If ``true``, spaces will be inserted around if/for/switch/while
  3452. /// conditions.
  3453. /// \code
  3454. /// true: false:
  3455. /// if ( a ) { ... } vs. if (a) { ... }
  3456. /// while ( i < 5 ) { ... } while (i < 5) { ... }
  3457. /// \endcode
  3458. /// \version 11
  3459. bool SpacesInConditionalStatement;
  3460. /// If ``true``, spaces are inserted inside container literals (e.g.
  3461. /// ObjC and Javascript array and dict literals).
  3462. /// \code{.js}
  3463. /// true: false:
  3464. /// var arr = [ 1, 2, 3 ]; vs. var arr = [1, 2, 3];
  3465. /// f({a : 1, b : 2, c : 3}); f({a: 1, b: 2, c: 3});
  3466. /// \endcode
  3467. /// \version 3.7
  3468. bool SpacesInContainerLiterals;
  3469. /// If ``true``, spaces may be inserted into C style casts.
  3470. /// \code
  3471. /// true: false:
  3472. /// x = ( int32 )y vs. x = (int32)y
  3473. /// \endcode
  3474. /// \version 3.7
  3475. bool SpacesInCStyleCastParentheses;
  3476. /// Control of spaces within a single line comment
  3477. struct SpacesInLineComment {
  3478. /// The minimum number of spaces at the start of the comment.
  3479. unsigned Minimum;
  3480. /// The maximum number of spaces at the start of the comment.
  3481. unsigned Maximum;
  3482. };
  3483. /// How many spaces are allowed at the start of a line comment. To disable the
  3484. /// maximum set it to ``-1``, apart from that the maximum takes precedence
  3485. /// over the minimum.
  3486. /// \code
  3487. /// Minimum = 1
  3488. /// Maximum = -1
  3489. /// // One space is forced
  3490. ///
  3491. /// // but more spaces are possible
  3492. ///
  3493. /// Minimum = 0
  3494. /// Maximum = 0
  3495. /// //Forces to start every comment directly after the slashes
  3496. /// \endcode
  3497. ///
  3498. /// Note that in line comment sections the relative indent of the subsequent
  3499. /// lines is kept, that means the following:
  3500. /// \code
  3501. /// before: after:
  3502. /// Minimum: 1
  3503. /// //if (b) { // if (b) {
  3504. /// // return true; // return true;
  3505. /// //} // }
  3506. ///
  3507. /// Maximum: 0
  3508. /// /// List: ///List:
  3509. /// /// - Foo /// - Foo
  3510. /// /// - Bar /// - Bar
  3511. /// \endcode
  3512. /// \version 14
  3513. SpacesInLineComment SpacesInLineCommentPrefix;
  3514. /// If ``true``, spaces will be inserted after ``(`` and before ``)``.
  3515. /// \code
  3516. /// true: false:
  3517. /// t f( Deleted & ) & = delete; vs. t f(Deleted &) & = delete;
  3518. /// \endcode
  3519. /// \version 3.7
  3520. bool SpacesInParentheses;
  3521. /// If ``true``, spaces will be inserted after ``[`` and before ``]``.
  3522. /// Lambdas without arguments or unspecified size array declarations will not
  3523. /// be affected.
  3524. /// \code
  3525. /// true: false:
  3526. /// int a[ 5 ]; vs. int a[5];
  3527. /// std::unique_ptr<int[]> foo() {} // Won't be affected
  3528. /// \endcode
  3529. /// \version 3.7
  3530. bool SpacesInSquareBrackets;
  3531. /// If ``true``, spaces will be before ``[``.
  3532. /// Lambdas will not be affected. Only the first ``[`` will get a space added.
  3533. /// \code
  3534. /// true: false:
  3535. /// int a [5]; vs. int a[5];
  3536. /// int a [5][5]; vs. int a[5][5];
  3537. /// \endcode
  3538. /// \version 11
  3539. bool SpaceBeforeSquareBrackets;
  3540. /// Styles for adding spacing around ``:`` in bitfield definitions.
  3541. enum BitFieldColonSpacingStyle : unsigned char {
  3542. /// Add one space on each side of the ``:``
  3543. /// \code
  3544. /// unsigned bf : 2;
  3545. /// \endcode
  3546. BFCS_Both,
  3547. /// Add no space around the ``:`` (except when needed for
  3548. /// ``AlignConsecutiveBitFields``).
  3549. /// \code
  3550. /// unsigned bf:2;
  3551. /// \endcode
  3552. BFCS_None,
  3553. /// Add space before the ``:`` only
  3554. /// \code
  3555. /// unsigned bf :2;
  3556. /// \endcode
  3557. BFCS_Before,
  3558. /// Add space after the ``:`` only (space may be added before if
  3559. /// needed for ``AlignConsecutiveBitFields``).
  3560. /// \code
  3561. /// unsigned bf: 2;
  3562. /// \endcode
  3563. BFCS_After
  3564. };
  3565. /// The BitFieldColonSpacingStyle to use for bitfields.
  3566. /// \version 12
  3567. BitFieldColonSpacingStyle BitFieldColonSpacing;
  3568. /// Supported language standards for parsing and formatting C++ constructs.
  3569. /// \code
  3570. /// Latest: vector<set<int>>
  3571. /// c++03 vs. vector<set<int> >
  3572. /// \endcode
  3573. ///
  3574. /// The correct way to spell a specific language version is e.g. ``c++11``.
  3575. /// The historical aliases ``Cpp03`` and ``Cpp11`` are deprecated.
  3576. enum LanguageStandard : unsigned char {
  3577. /// Parse and format as C++03.
  3578. /// ``Cpp03`` is a deprecated alias for ``c++03``
  3579. LS_Cpp03, // c++03
  3580. /// Parse and format as C++11.
  3581. LS_Cpp11, // c++11
  3582. /// Parse and format as C++14.
  3583. LS_Cpp14, // c++14
  3584. /// Parse and format as C++17.
  3585. LS_Cpp17, // c++17
  3586. /// Parse and format as C++20.
  3587. LS_Cpp20, // c++20
  3588. /// Parse and format using the latest supported language version.
  3589. /// ``Cpp11`` is a deprecated alias for ``Latest``
  3590. LS_Latest,
  3591. /// Automatic detection based on the input.
  3592. LS_Auto,
  3593. };
  3594. /// Parse and format C++ constructs compatible with this standard.
  3595. /// \code
  3596. /// c++03: latest:
  3597. /// vector<set<int> > x; vs. vector<set<int>> x;
  3598. /// \endcode
  3599. /// \version 3.7
  3600. LanguageStandard Standard;
  3601. /// Macros which are ignored in front of a statement, as if they were an
  3602. /// attribute. So that they are not parsed as identifier, for example for Qts
  3603. /// emit.
  3604. /// \code
  3605. /// AlignConsecutiveDeclarations: true
  3606. /// StatementAttributeLikeMacros: []
  3607. /// unsigned char data = 'x';
  3608. /// emit signal(data); // This is parsed as variable declaration.
  3609. ///
  3610. /// AlignConsecutiveDeclarations: true
  3611. /// StatementAttributeLikeMacros: [emit]
  3612. /// unsigned char data = 'x';
  3613. /// emit signal(data); // Now it's fine again.
  3614. /// \endcode
  3615. /// \version 12
  3616. std::vector<std::string> StatementAttributeLikeMacros;
  3617. /// The number of columns used for tab stops.
  3618. /// \version 3.7
  3619. unsigned TabWidth;
  3620. /// Different ways to use tab in formatting.
  3621. enum UseTabStyle : unsigned char {
  3622. /// Never use tab.
  3623. UT_Never,
  3624. /// Use tabs only for indentation.
  3625. UT_ForIndentation,
  3626. /// Fill all leading whitespace with tabs, and use spaces for alignment that
  3627. /// appears within a line (e.g. consecutive assignments and declarations).
  3628. UT_ForContinuationAndIndentation,
  3629. /// Use tabs for line continuation and indentation, and spaces for
  3630. /// alignment.
  3631. UT_AlignWithSpaces,
  3632. /// Use tabs whenever we need to fill whitespace that spans at least from
  3633. /// one tab stop to the next one.
  3634. UT_Always
  3635. };
  3636. /// \brief Use ``\r\n`` instead of ``\n`` for line breaks.
  3637. /// Also used as fallback if ``DeriveLineEnding`` is true.
  3638. /// \version 11
  3639. bool UseCRLF;
  3640. /// The way to use tab characters in the resulting file.
  3641. /// \version 3.7
  3642. UseTabStyle UseTab;
  3643. bool operator==(const FormatStyle &R) const {
  3644. return AccessModifierOffset == R.AccessModifierOffset &&
  3645. AlignAfterOpenBracket == R.AlignAfterOpenBracket &&
  3646. AlignArrayOfStructures == R.AlignArrayOfStructures &&
  3647. AlignConsecutiveAssignments == R.AlignConsecutiveAssignments &&
  3648. AlignConsecutiveBitFields == R.AlignConsecutiveBitFields &&
  3649. AlignConsecutiveDeclarations == R.AlignConsecutiveDeclarations &&
  3650. AlignConsecutiveMacros == R.AlignConsecutiveMacros &&
  3651. AlignEscapedNewlines == R.AlignEscapedNewlines &&
  3652. AlignOperands == R.AlignOperands &&
  3653. AlignTrailingComments == R.AlignTrailingComments &&
  3654. AllowAllArgumentsOnNextLine == R.AllowAllArgumentsOnNextLine &&
  3655. AllowAllParametersOfDeclarationOnNextLine ==
  3656. R.AllowAllParametersOfDeclarationOnNextLine &&
  3657. AllowShortEnumsOnASingleLine == R.AllowShortEnumsOnASingleLine &&
  3658. AllowShortBlocksOnASingleLine == R.AllowShortBlocksOnASingleLine &&
  3659. AllowShortCaseLabelsOnASingleLine ==
  3660. R.AllowShortCaseLabelsOnASingleLine &&
  3661. AllowShortFunctionsOnASingleLine ==
  3662. R.AllowShortFunctionsOnASingleLine &&
  3663. AllowShortIfStatementsOnASingleLine ==
  3664. R.AllowShortIfStatementsOnASingleLine &&
  3665. AllowShortLambdasOnASingleLine == R.AllowShortLambdasOnASingleLine &&
  3666. AllowShortLoopsOnASingleLine == R.AllowShortLoopsOnASingleLine &&
  3667. AlwaysBreakAfterReturnType == R.AlwaysBreakAfterReturnType &&
  3668. AlwaysBreakBeforeMultilineStrings ==
  3669. R.AlwaysBreakBeforeMultilineStrings &&
  3670. AlwaysBreakTemplateDeclarations ==
  3671. R.AlwaysBreakTemplateDeclarations &&
  3672. AttributeMacros == R.AttributeMacros &&
  3673. BinPackArguments == R.BinPackArguments &&
  3674. BinPackParameters == R.BinPackParameters &&
  3675. BreakBeforeBinaryOperators == R.BreakBeforeBinaryOperators &&
  3676. BreakBeforeBraces == R.BreakBeforeBraces &&
  3677. BreakBeforeConceptDeclarations == R.BreakBeforeConceptDeclarations &&
  3678. BreakBeforeTernaryOperators == R.BreakBeforeTernaryOperators &&
  3679. BreakConstructorInitializers == R.BreakConstructorInitializers &&
  3680. CompactNamespaces == R.CompactNamespaces &&
  3681. BreakAfterJavaFieldAnnotations == R.BreakAfterJavaFieldAnnotations &&
  3682. BreakStringLiterals == R.BreakStringLiterals &&
  3683. ColumnLimit == R.ColumnLimit && CommentPragmas == R.CommentPragmas &&
  3684. BreakInheritanceList == R.BreakInheritanceList &&
  3685. ConstructorInitializerIndentWidth ==
  3686. R.ConstructorInitializerIndentWidth &&
  3687. ContinuationIndentWidth == R.ContinuationIndentWidth &&
  3688. Cpp11BracedListStyle == R.Cpp11BracedListStyle &&
  3689. DeriveLineEnding == R.DeriveLineEnding &&
  3690. DerivePointerAlignment == R.DerivePointerAlignment &&
  3691. DisableFormat == R.DisableFormat &&
  3692. EmptyLineAfterAccessModifier == R.EmptyLineAfterAccessModifier &&
  3693. EmptyLineBeforeAccessModifier == R.EmptyLineBeforeAccessModifier &&
  3694. ExperimentalAutoDetectBinPacking ==
  3695. R.ExperimentalAutoDetectBinPacking &&
  3696. PackConstructorInitializers == R.PackConstructorInitializers &&
  3697. FixNamespaceComments == R.FixNamespaceComments &&
  3698. ForEachMacros == R.ForEachMacros &&
  3699. IncludeStyle.IncludeBlocks == R.IncludeStyle.IncludeBlocks &&
  3700. IncludeStyle.IncludeCategories == R.IncludeStyle.IncludeCategories &&
  3701. IncludeStyle.IncludeIsMainRegex ==
  3702. R.IncludeStyle.IncludeIsMainRegex &&
  3703. IncludeStyle.IncludeIsMainSourceRegex ==
  3704. R.IncludeStyle.IncludeIsMainSourceRegex &&
  3705. IndentAccessModifiers == R.IndentAccessModifiers &&
  3706. IndentCaseLabels == R.IndentCaseLabels &&
  3707. IndentCaseBlocks == R.IndentCaseBlocks &&
  3708. IndentGotoLabels == R.IndentGotoLabels &&
  3709. IndentPPDirectives == R.IndentPPDirectives &&
  3710. IndentExternBlock == R.IndentExternBlock &&
  3711. IndentRequires == R.IndentRequires && IndentWidth == R.IndentWidth &&
  3712. Language == R.Language &&
  3713. IndentWrappedFunctionNames == R.IndentWrappedFunctionNames &&
  3714. JavaImportGroups == R.JavaImportGroups &&
  3715. JavaScriptQuotes == R.JavaScriptQuotes &&
  3716. JavaScriptWrapImports == R.JavaScriptWrapImports &&
  3717. KeepEmptyLinesAtTheStartOfBlocks ==
  3718. R.KeepEmptyLinesAtTheStartOfBlocks &&
  3719. LambdaBodyIndentation == R.LambdaBodyIndentation &&
  3720. MacroBlockBegin == R.MacroBlockBegin &&
  3721. MacroBlockEnd == R.MacroBlockEnd &&
  3722. MaxEmptyLinesToKeep == R.MaxEmptyLinesToKeep &&
  3723. NamespaceIndentation == R.NamespaceIndentation &&
  3724. NamespaceMacros == R.NamespaceMacros &&
  3725. ObjCBinPackProtocolList == R.ObjCBinPackProtocolList &&
  3726. ObjCBlockIndentWidth == R.ObjCBlockIndentWidth &&
  3727. ObjCBreakBeforeNestedBlockParam ==
  3728. R.ObjCBreakBeforeNestedBlockParam &&
  3729. ObjCSpaceAfterProperty == R.ObjCSpaceAfterProperty &&
  3730. ObjCSpaceBeforeProtocolList == R.ObjCSpaceBeforeProtocolList &&
  3731. PenaltyBreakAssignment == R.PenaltyBreakAssignment &&
  3732. PenaltyBreakBeforeFirstCallParameter ==
  3733. R.PenaltyBreakBeforeFirstCallParameter &&
  3734. PenaltyBreakComment == R.PenaltyBreakComment &&
  3735. PenaltyBreakFirstLessLess == R.PenaltyBreakFirstLessLess &&
  3736. PenaltyBreakOpenParenthesis == R.PenaltyBreakOpenParenthesis &&
  3737. PenaltyBreakString == R.PenaltyBreakString &&
  3738. PenaltyExcessCharacter == R.PenaltyExcessCharacter &&
  3739. PenaltyReturnTypeOnItsOwnLine == R.PenaltyReturnTypeOnItsOwnLine &&
  3740. PenaltyBreakTemplateDeclaration ==
  3741. R.PenaltyBreakTemplateDeclaration &&
  3742. PointerAlignment == R.PointerAlignment &&
  3743. QualifierAlignment == R.QualifierAlignment &&
  3744. QualifierOrder == R.QualifierOrder &&
  3745. RawStringFormats == R.RawStringFormats &&
  3746. ReferenceAlignment == R.ReferenceAlignment &&
  3747. RemoveBracesLLVM == R.RemoveBracesLLVM &&
  3748. SeparateDefinitionBlocks == R.SeparateDefinitionBlocks &&
  3749. ShortNamespaceLines == R.ShortNamespaceLines &&
  3750. SortIncludes == R.SortIncludes &&
  3751. SortJavaStaticImport == R.SortJavaStaticImport &&
  3752. SpaceAfterCStyleCast == R.SpaceAfterCStyleCast &&
  3753. SpaceAfterLogicalNot == R.SpaceAfterLogicalNot &&
  3754. SpaceAfterTemplateKeyword == R.SpaceAfterTemplateKeyword &&
  3755. SpaceBeforeAssignmentOperators == R.SpaceBeforeAssignmentOperators &&
  3756. SpaceBeforeCaseColon == R.SpaceBeforeCaseColon &&
  3757. SpaceBeforeCpp11BracedList == R.SpaceBeforeCpp11BracedList &&
  3758. SpaceBeforeCtorInitializerColon ==
  3759. R.SpaceBeforeCtorInitializerColon &&
  3760. SpaceBeforeInheritanceColon == R.SpaceBeforeInheritanceColon &&
  3761. SpaceBeforeParens == R.SpaceBeforeParens &&
  3762. SpaceBeforeParensOptions == R.SpaceBeforeParensOptions &&
  3763. SpaceAroundPointerQualifiers == R.SpaceAroundPointerQualifiers &&
  3764. SpaceBeforeRangeBasedForLoopColon ==
  3765. R.SpaceBeforeRangeBasedForLoopColon &&
  3766. SpaceInEmptyBlock == R.SpaceInEmptyBlock &&
  3767. SpaceInEmptyParentheses == R.SpaceInEmptyParentheses &&
  3768. SpacesBeforeTrailingComments == R.SpacesBeforeTrailingComments &&
  3769. SpacesInAngles == R.SpacesInAngles &&
  3770. SpacesInConditionalStatement == R.SpacesInConditionalStatement &&
  3771. SpacesInContainerLiterals == R.SpacesInContainerLiterals &&
  3772. SpacesInCStyleCastParentheses == R.SpacesInCStyleCastParentheses &&
  3773. SpacesInLineCommentPrefix.Minimum ==
  3774. R.SpacesInLineCommentPrefix.Minimum &&
  3775. SpacesInLineCommentPrefix.Maximum ==
  3776. R.SpacesInLineCommentPrefix.Maximum &&
  3777. SpacesInParentheses == R.SpacesInParentheses &&
  3778. SpacesInSquareBrackets == R.SpacesInSquareBrackets &&
  3779. SpaceBeforeSquareBrackets == R.SpaceBeforeSquareBrackets &&
  3780. BitFieldColonSpacing == R.BitFieldColonSpacing &&
  3781. Standard == R.Standard &&
  3782. StatementAttributeLikeMacros == R.StatementAttributeLikeMacros &&
  3783. StatementMacros == R.StatementMacros && TabWidth == R.TabWidth &&
  3784. UseTab == R.UseTab && UseCRLF == R.UseCRLF &&
  3785. TypenameMacros == R.TypenameMacros;
  3786. }
  3787. llvm::Optional<FormatStyle> GetLanguageStyle(LanguageKind Language) const;
  3788. // Stores per-language styles. A FormatStyle instance inside has an empty
  3789. // StyleSet. A FormatStyle instance returned by the Get method has its
  3790. // StyleSet set to a copy of the originating StyleSet, effectively keeping the
  3791. // internal representation of that StyleSet alive.
  3792. //
  3793. // The memory management and ownership reminds of a birds nest: chicks
  3794. // leaving the nest take photos of the nest with them.
  3795. struct FormatStyleSet {
  3796. typedef std::map<FormatStyle::LanguageKind, FormatStyle> MapType;
  3797. llvm::Optional<FormatStyle> Get(FormatStyle::LanguageKind Language) const;
  3798. // Adds \p Style to this FormatStyleSet. Style must not have an associated
  3799. // FormatStyleSet.
  3800. // Style.Language should be different than LK_None. If this FormatStyleSet
  3801. // already contains an entry for Style.Language, that gets replaced with the
  3802. // passed Style.
  3803. void Add(FormatStyle Style);
  3804. // Clears this FormatStyleSet.
  3805. void Clear();
  3806. private:
  3807. std::shared_ptr<MapType> Styles;
  3808. };
  3809. static FormatStyleSet BuildStyleSetFromConfiguration(
  3810. const FormatStyle &MainStyle,
  3811. const std::vector<FormatStyle> &ConfigurationStyles);
  3812. private:
  3813. FormatStyleSet StyleSet;
  3814. friend std::error_code
  3815. parseConfiguration(llvm::MemoryBufferRef Config, FormatStyle *Style,
  3816. bool AllowUnknownOptions,
  3817. llvm::SourceMgr::DiagHandlerTy DiagHandler,
  3818. void *DiagHandlerCtxt);
  3819. };
  3820. /// Returns a format style complying with the LLVM coding standards:
  3821. /// http://llvm.org/docs/CodingStandards.html.
  3822. FormatStyle getLLVMStyle(
  3823. FormatStyle::LanguageKind Language = FormatStyle::LanguageKind::LK_Cpp);
  3824. /// Returns a format style complying with one of Google's style guides:
  3825. /// http://google-styleguide.googlecode.com/svn/trunk/cppguide.xml.
  3826. /// http://google-styleguide.googlecode.com/svn/trunk/javascriptguide.xml.
  3827. /// https://developers.google.com/protocol-buffers/docs/style.
  3828. FormatStyle getGoogleStyle(FormatStyle::LanguageKind Language);
  3829. /// Returns a format style complying with Chromium's style guide:
  3830. /// http://www.chromium.org/developers/coding-style.
  3831. FormatStyle getChromiumStyle(FormatStyle::LanguageKind Language);
  3832. /// Returns a format style complying with Mozilla's style guide:
  3833. /// https://firefox-source-docs.mozilla.org/code-quality/coding-style/index.html.
  3834. FormatStyle getMozillaStyle();
  3835. /// Returns a format style complying with Webkit's style guide:
  3836. /// http://www.webkit.org/coding/coding-style.html
  3837. FormatStyle getWebKitStyle();
  3838. /// Returns a format style complying with GNU Coding Standards:
  3839. /// http://www.gnu.org/prep/standards/standards.html
  3840. FormatStyle getGNUStyle();
  3841. /// Returns a format style complying with Microsoft style guide:
  3842. /// https://docs.microsoft.com/en-us/visualstudio/ide/editorconfig-code-style-settings-reference?view=vs-2017
  3843. FormatStyle getMicrosoftStyle(FormatStyle::LanguageKind Language);
  3844. /// Returns style indicating formatting should be not applied at all.
  3845. FormatStyle getNoStyle();
  3846. /// Gets a predefined style for the specified language by name.
  3847. ///
  3848. /// Currently supported names: LLVM, Google, Chromium, Mozilla. Names are
  3849. /// compared case-insensitively.
  3850. ///
  3851. /// Returns ``true`` if the Style has been set.
  3852. bool getPredefinedStyle(StringRef Name, FormatStyle::LanguageKind Language,
  3853. FormatStyle *Style);
  3854. /// Parse configuration from YAML-formatted text.
  3855. ///
  3856. /// Style->Language is used to get the base style, if the ``BasedOnStyle``
  3857. /// option is present.
  3858. ///
  3859. /// The FormatStyleSet of Style is reset.
  3860. ///
  3861. /// When ``BasedOnStyle`` is not present, options not present in the YAML
  3862. /// document, are retained in \p Style.
  3863. ///
  3864. /// If AllowUnknownOptions is true, no errors are emitted if unknown
  3865. /// format options are occured.
  3866. ///
  3867. /// If set all diagnostics are emitted through the DiagHandler.
  3868. std::error_code
  3869. parseConfiguration(llvm::MemoryBufferRef Config, FormatStyle *Style,
  3870. bool AllowUnknownOptions = false,
  3871. llvm::SourceMgr::DiagHandlerTy DiagHandler = nullptr,
  3872. void *DiagHandlerCtx = nullptr);
  3873. /// Like above but accepts an unnamed buffer.
  3874. inline std::error_code parseConfiguration(StringRef Config, FormatStyle *Style,
  3875. bool AllowUnknownOptions = false) {
  3876. return parseConfiguration(llvm::MemoryBufferRef(Config, "YAML"), Style,
  3877. AllowUnknownOptions);
  3878. }
  3879. /// Gets configuration in a YAML string.
  3880. std::string configurationAsText(const FormatStyle &Style);
  3881. /// Returns the replacements necessary to sort all ``#include`` blocks
  3882. /// that are affected by ``Ranges``.
  3883. tooling::Replacements sortIncludes(const FormatStyle &Style, StringRef Code,
  3884. ArrayRef<tooling::Range> Ranges,
  3885. StringRef FileName,
  3886. unsigned *Cursor = nullptr);
  3887. /// Returns the replacements corresponding to applying and formatting
  3888. /// \p Replaces on success; otheriwse, return an llvm::Error carrying
  3889. /// llvm::StringError.
  3890. llvm::Expected<tooling::Replacements>
  3891. formatReplacements(StringRef Code, const tooling::Replacements &Replaces,
  3892. const FormatStyle &Style);
  3893. /// Returns the replacements corresponding to applying \p Replaces and
  3894. /// cleaning up the code after that on success; otherwise, return an llvm::Error
  3895. /// carrying llvm::StringError.
  3896. /// This also supports inserting/deleting C++ #include directives:
  3897. /// - If a replacement has offset UINT_MAX, length 0, and a replacement text
  3898. /// that is an #include directive, this will insert the #include into the
  3899. /// correct block in the \p Code.
  3900. /// - If a replacement has offset UINT_MAX, length 1, and a replacement text
  3901. /// that is the name of the header to be removed, the header will be removed
  3902. /// from \p Code if it exists.
  3903. /// The include manipulation is done via `tooling::HeaderInclude`, see its
  3904. /// documentation for more details on how include insertion points are found and
  3905. /// what edits are produced.
  3906. llvm::Expected<tooling::Replacements>
  3907. cleanupAroundReplacements(StringRef Code, const tooling::Replacements &Replaces,
  3908. const FormatStyle &Style);
  3909. /// Represents the status of a formatting attempt.
  3910. struct FormattingAttemptStatus {
  3911. /// A value of ``false`` means that any of the affected ranges were not
  3912. /// formatted due to a non-recoverable syntax error.
  3913. bool FormatComplete = true;
  3914. /// If ``FormatComplete`` is false, ``Line`` records a one-based
  3915. /// original line number at which a syntax error might have occurred. This is
  3916. /// based on a best-effort analysis and could be imprecise.
  3917. unsigned Line = 0;
  3918. };
  3919. /// Reformats the given \p Ranges in \p Code.
  3920. ///
  3921. /// Each range is extended on either end to its next bigger logic unit, i.e.
  3922. /// everything that might influence its formatting or might be influenced by its
  3923. /// formatting.
  3924. ///
  3925. /// Returns the ``Replacements`` necessary to make all \p Ranges comply with
  3926. /// \p Style.
  3927. ///
  3928. /// If ``Status`` is non-null, its value will be populated with the status of
  3929. /// this formatting attempt. See \c FormattingAttemptStatus.
  3930. tooling::Replacements reformat(const FormatStyle &Style, StringRef Code,
  3931. ArrayRef<tooling::Range> Ranges,
  3932. StringRef FileName = "<stdin>",
  3933. FormattingAttemptStatus *Status = nullptr);
  3934. /// Same as above, except if ``IncompleteFormat`` is non-null, its value
  3935. /// will be set to true if any of the affected ranges were not formatted due to
  3936. /// a non-recoverable syntax error.
  3937. tooling::Replacements reformat(const FormatStyle &Style, StringRef Code,
  3938. ArrayRef<tooling::Range> Ranges,
  3939. StringRef FileName, bool *IncompleteFormat);
  3940. /// Clean up any erroneous/redundant code in the given \p Ranges in \p
  3941. /// Code.
  3942. ///
  3943. /// Returns the ``Replacements`` that clean up all \p Ranges in \p Code.
  3944. tooling::Replacements cleanup(const FormatStyle &Style, StringRef Code,
  3945. ArrayRef<tooling::Range> Ranges,
  3946. StringRef FileName = "<stdin>");
  3947. /// Fix namespace end comments in the given \p Ranges in \p Code.
  3948. ///
  3949. /// Returns the ``Replacements`` that fix the namespace comments in all
  3950. /// \p Ranges in \p Code.
  3951. tooling::Replacements fixNamespaceEndComments(const FormatStyle &Style,
  3952. StringRef Code,
  3953. ArrayRef<tooling::Range> Ranges,
  3954. StringRef FileName = "<stdin>");
  3955. /// Inserts or removes empty lines separating definition blocks including
  3956. /// classes, structs, functions, namespaces, and enums in the given \p Ranges in
  3957. /// \p Code.
  3958. ///
  3959. /// Returns the ``Replacements`` that inserts or removes empty lines separating
  3960. /// definition blocks in all \p Ranges in \p Code.
  3961. tooling::Replacements separateDefinitionBlocks(const FormatStyle &Style,
  3962. StringRef Code,
  3963. ArrayRef<tooling::Range> Ranges,
  3964. StringRef FileName = "<stdin>");
  3965. /// Sort consecutive using declarations in the given \p Ranges in
  3966. /// \p Code.
  3967. ///
  3968. /// Returns the ``Replacements`` that sort the using declarations in all
  3969. /// \p Ranges in \p Code.
  3970. tooling::Replacements sortUsingDeclarations(const FormatStyle &Style,
  3971. StringRef Code,
  3972. ArrayRef<tooling::Range> Ranges,
  3973. StringRef FileName = "<stdin>");
  3974. /// Returns the ``LangOpts`` that the formatter expects you to set.
  3975. ///
  3976. /// \param Style determines specific settings for lexing mode.
  3977. LangOptions getFormattingLangOpts(const FormatStyle &Style = getLLVMStyle());
  3978. /// Description to be used for help text for a ``llvm::cl`` option for
  3979. /// specifying format style. The description is closely related to the operation
  3980. /// of ``getStyle()``.
  3981. extern const char *StyleOptionHelpDescription;
  3982. /// The suggested format style to use by default. This allows tools using
  3983. /// `getStyle` to have a consistent default style.
  3984. /// Different builds can modify the value to the preferred styles.
  3985. extern const char *DefaultFormatStyle;
  3986. /// The suggested predefined style to use as the fallback style in `getStyle`.
  3987. /// Different builds can modify the value to the preferred styles.
  3988. extern const char *DefaultFallbackStyle;
  3989. /// Construct a FormatStyle based on ``StyleName``.
  3990. ///
  3991. /// ``StyleName`` can take several forms:
  3992. /// * "{<key>: <value>, ...}" - Set specic style parameters.
  3993. /// * "<style name>" - One of the style names supported by
  3994. /// getPredefinedStyle().
  3995. /// * "file" - Load style configuration from a file called ``.clang-format``
  3996. /// located in one of the parent directories of ``FileName`` or the current
  3997. /// directory if ``FileName`` is empty.
  3998. /// * "file:<format_file_path>" to explicitly specify the configuration file to
  3999. /// use.
  4000. ///
  4001. /// \param[in] StyleName Style name to interpret according to the description
  4002. /// above.
  4003. /// \param[in] FileName Path to start search for .clang-format if ``StyleName``
  4004. /// == "file".
  4005. /// \param[in] FallbackStyle The name of a predefined style used to fallback to
  4006. /// in case \p StyleName is "file" and no file can be found.
  4007. /// \param[in] Code The actual code to be formatted. Used to determine the
  4008. /// language if the filename isn't sufficient.
  4009. /// \param[in] FS The underlying file system, in which the file resides. By
  4010. /// default, the file system is the real file system.
  4011. /// \param[in] AllowUnknownOptions If true, unknown format options only
  4012. /// emit a warning. If false, errors are emitted on unknown format
  4013. /// options.
  4014. ///
  4015. /// \returns FormatStyle as specified by ``StyleName``. If ``StyleName`` is
  4016. /// "file" and no file is found, returns ``FallbackStyle``. If no style could be
  4017. /// determined, returns an Error.
  4018. llvm::Expected<FormatStyle> getStyle(StringRef StyleName, StringRef FileName,
  4019. StringRef FallbackStyle,
  4020. StringRef Code = "",
  4021. llvm::vfs::FileSystem *FS = nullptr,
  4022. bool AllowUnknownOptions = false);
  4023. // Guesses the language from the ``FileName`` and ``Code`` to be formatted.
  4024. // Defaults to FormatStyle::LK_Cpp.
  4025. FormatStyle::LanguageKind guessLanguage(StringRef FileName, StringRef Code);
  4026. // Returns a string representation of ``Language``.
  4027. inline StringRef getLanguageName(FormatStyle::LanguageKind Language) {
  4028. switch (Language) {
  4029. case FormatStyle::LK_Cpp:
  4030. return "C++";
  4031. case FormatStyle::LK_CSharp:
  4032. return "CSharp";
  4033. case FormatStyle::LK_ObjC:
  4034. return "Objective-C";
  4035. case FormatStyle::LK_Java:
  4036. return "Java";
  4037. case FormatStyle::LK_JavaScript:
  4038. return "JavaScript";
  4039. case FormatStyle::LK_Json:
  4040. return "Json";
  4041. case FormatStyle::LK_Proto:
  4042. return "Proto";
  4043. case FormatStyle::LK_TableGen:
  4044. return "TableGen";
  4045. case FormatStyle::LK_TextProto:
  4046. return "TextProto";
  4047. default:
  4048. return "Unknown";
  4049. }
  4050. }
  4051. } // end namespace format
  4052. } // end namespace clang
  4053. namespace std {
  4054. template <>
  4055. struct is_error_code_enum<clang::format::ParseError> : std::true_type {};
  4056. } // namespace std
  4057. #endif // LLVM_CLANG_FORMAT_FORMAT_H
  4058. #ifdef __GNUC__
  4059. #pragma GCC diagnostic pop
  4060. #endif