clang API Documentation

Format.h
Go to the documentation of this file.
00001 //===--- Format.h - Format C++ code -----------------------------*- C++ -*-===//
00002 //
00003 //                     The LLVM Compiler Infrastructure
00004 //
00005 // This file is distributed under the University of Illinois Open Source
00006 // License. See LICENSE.TXT for details.
00007 //
00008 //===----------------------------------------------------------------------===//
00009 ///
00010 /// \file
00011 /// Various functions to configurably format source code.
00012 ///
00013 //===----------------------------------------------------------------------===//
00014 
00015 #ifndef LLVM_CLANG_FORMAT_FORMAT_H
00016 #define LLVM_CLANG_FORMAT_FORMAT_H
00017 
00018 #include "clang/Basic/LangOptions.h"
00019 #include "clang/Tooling/Core/Replacement.h"
00020 #include "llvm/ADT/ArrayRef.h"
00021 #include <system_error>
00022 
00023 namespace clang {
00024 
00025 class Lexer;
00026 class SourceManager;
00027 class DiagnosticConsumer;
00028 
00029 namespace format {
00030 
00031 enum class ParseError { Success = 0, Error, Unsuitable };
00032 class ParseErrorCategory final : public std::error_category {
00033 public:
00034   const char *name() const LLVM_NOEXCEPT override;
00035   std::string message(int EV) const override;
00036 };
00037 const std::error_category &getParseCategory();
00038 std::error_code make_error_code(ParseError e);
00039 
00040 /// \brief The \c FormatStyle is used to configure the formatting to follow
00041 /// specific guidelines.
00042 struct FormatStyle {
00043   /// \brief Supported languages. When stored in a configuration file, specifies
00044   /// the language, that the configuration targets. When passed to the
00045   /// reformat() function, enables syntax features specific to the language.
00046   enum LanguageKind {
00047     /// Do not use.
00048     LK_None,
00049     /// Should be used for C, C++, ObjectiveC, ObjectiveC++.
00050     LK_Cpp,
00051     /// Should be used for Java.
00052     LK_Java,
00053     /// Should be used for JavaScript.
00054     LK_JavaScript,
00055     /// Should be used for Protocol Buffers
00056     /// (https://developers.google.com/protocol-buffers/).
00057     LK_Proto
00058   };
00059 
00060   /// \brief Language, this format style is targeted at.
00061   LanguageKind Language;
00062 
00063   /// \brief The column limit.
00064   ///
00065   /// A column limit of \c 0 means that there is no column limit. In this case,
00066   /// clang-format will respect the input's line breaking decisions within
00067   /// statements unless they contradict other rules.
00068   unsigned ColumnLimit;
00069 
00070   /// \brief The maximum number of consecutive empty lines to keep.
00071   unsigned MaxEmptyLinesToKeep;
00072 
00073   /// \brief If true, empty lines at the start of blocks are kept.
00074   bool KeepEmptyLinesAtTheStartOfBlocks;
00075 
00076   /// \brief The penalty for each line break introduced inside a comment.
00077   unsigned PenaltyBreakComment;
00078 
00079   /// \brief The penalty for each line break introduced inside a string literal.
00080   unsigned PenaltyBreakString;
00081 
00082   /// \brief The penalty for each character outside of the column limit.
00083   unsigned PenaltyExcessCharacter;
00084 
00085   /// \brief The penalty for breaking before the first \c <<.
00086   unsigned PenaltyBreakFirstLessLess;
00087 
00088   /// \brief The penalty for breaking a function call after "call(".
00089   unsigned PenaltyBreakBeforeFirstCallParameter;
00090 
00091   /// \brief The & and * alignment style.
00092   enum PointerAlignmentStyle {
00093     /// Align pointer to the left.
00094     PAS_Left,
00095     /// Align pointer to the right.
00096     PAS_Right,
00097     /// Align pointer in the middle.
00098     PAS_Middle
00099   };
00100 
00101   /// Pointer and reference alignment style.
00102   PointerAlignmentStyle PointerAlignment;
00103 
00104   /// \brief If \c true, analyze the formatted file for the most common
00105   /// alignment of & and *. \c PointerAlignment is then used only as fallback.
00106   bool DerivePointerAlignment;
00107 
00108   /// \brief The extra indent or outdent of access modifiers, e.g. \c public:.
00109   int AccessModifierOffset;
00110 
00111   /// \brief Supported language standards.
00112   enum LanguageStandard {
00113     /// Use C++03-compatible syntax.
00114     LS_Cpp03,
00115     /// Use features of C++11 (e.g. \c A<A<int>> instead of
00116     /// <tt>A<A<int> ></tt>).
00117     LS_Cpp11,
00118     /// Automatic detection based on the input.
00119     LS_Auto
00120   };
00121 
00122   /// \brief Format compatible with this standard, e.g. use
00123   /// <tt>A<A<int> ></tt> instead of \c A<A<int>> for LS_Cpp03.
00124   LanguageStandard Standard;
00125 
00126   /// \brief Indent case labels one level from the switch statement.
00127   ///
00128   /// When \c false, use the same indentation level as for the switch statement.
00129   /// Switch statement body is always indented one level more than case labels.
00130   bool IndentCaseLabels;
00131 
00132   /// \brief Indent if a function definition or declaration is wrapped after the
00133   /// type.
00134   bool IndentWrappedFunctionNames;
00135 
00136   /// \brief Different ways to indent namespace contents.
00137   enum NamespaceIndentationKind {
00138     /// Don't indent in namespaces.
00139     NI_None,
00140     /// Indent only in inner namespaces (nested in other namespaces).
00141     NI_Inner,
00142     /// Indent in all namespaces.
00143     NI_All
00144   };
00145 
00146   /// \brief The indentation used for namespaces.
00147   NamespaceIndentationKind NamespaceIndentation;
00148 
00149   /// \brief The number of spaces before trailing line comments
00150   /// (\c // - comments).
00151   ///
00152   /// This does not affect trailing block comments (\c /**/ - comments) as those
00153   /// commonly have different usage patterns and a number of special cases.
00154   unsigned SpacesBeforeTrailingComments;
00155 
00156   /// \brief If \c false, a function declaration's or function definition's
00157   /// parameters will either all be on the same line or will have one line each.
00158   bool BinPackParameters;
00159 
00160   /// \brief If \c false, a function call's arguments will either be all on the
00161   /// same line or will have one line each.
00162   bool BinPackArguments;
00163 
00164   /// \brief If \c true, clang-format detects whether function calls and
00165   /// definitions are formatted with one parameter per line.
00166   ///
00167   /// Each call can be bin-packed, one-per-line or inconclusive. If it is
00168   /// inconclusive, e.g. completely on one line, but a decision needs to be
00169   /// made, clang-format analyzes whether there are other bin-packed cases in
00170   /// the input file and act accordingly.
00171   ///
00172   /// NOTE: This is an experimental flag, that might go away or be renamed. Do
00173   /// not use this in config files, etc. Use at your own risk.
00174   bool ExperimentalAutoDetectBinPacking;
00175 
00176   /// \brief Allow putting all parameters of a function declaration onto
00177   /// the next line even if \c BinPackParameters is \c false.
00178   bool AllowAllParametersOfDeclarationOnNextLine;
00179 
00180   /// \brief Penalty for putting the return type of a function onto its own
00181   /// line.
00182   unsigned PenaltyReturnTypeOnItsOwnLine;
00183 
00184   /// \brief If the constructor initializers don't fit on a line, put each
00185   /// initializer on its own line.
00186   bool ConstructorInitializerAllOnOneLineOrOnePerLine;
00187 
00188   /// \brief Always break constructor initializers before commas and align
00189   /// the commas with the colon.
00190   bool BreakConstructorInitializersBeforeComma;
00191 
00192   /// \brief Allows contracting simple braced statements to a single line.
00193   ///
00194   /// E.g., this allows <tt>if (a) { return; }</tt> to be put on a single line.
00195   bool AllowShortBlocksOnASingleLine;
00196 
00197   /// \brief If \c true, <tt>if (a) return;</tt> can be put on a single
00198   /// line.
00199   bool AllowShortIfStatementsOnASingleLine;
00200 
00201   /// \brief If \c true, <tt>while (true) continue;</tt> can be put on a
00202   /// single line.
00203   bool AllowShortLoopsOnASingleLine;
00204 
00205   /// \brief If \c true, short case labels will be contracted to a single line.
00206   bool AllowShortCaseLabelsOnASingleLine;
00207 
00208   /// \brief Different styles for merging short functions containing at most one
00209   /// statement.
00210   enum ShortFunctionStyle {
00211     /// \brief Never merge functions into a single line.
00212     SFS_None,
00213     /// \brief Only merge functions defined inside a class.
00214     SFS_Inline,
00215     /// \brief Merge all functions fitting on a single line.
00216     SFS_All,
00217   };
00218 
00219   /// \brief Dependent on the value, <tt>int f() { return 0; }</tt> can be put
00220   /// on a single line.
00221   ShortFunctionStyle AllowShortFunctionsOnASingleLine;
00222 
00223   /// \brief Add a space after \c @property in Objective-C, i.e. use
00224   /// <tt>\@property (readonly)</tt> instead of <tt>\@property(readonly)</tt>.
00225   bool ObjCSpaceAfterProperty;
00226 
00227   /// \brief Add a space in front of an Objective-C protocol list, i.e. use
00228   /// <tt>Foo <Protocol></tt> instead of \c Foo<Protocol>.
00229   bool ObjCSpaceBeforeProtocolList;
00230 
00231   /// \brief If \c true, aligns trailing comments.
00232   bool AlignTrailingComments;
00233 
00234   /// \brief If \c true, aligns escaped newlines as far left as possible.
00235   /// Otherwise puts them into the right-most column.
00236   bool AlignEscapedNewlinesLeft;
00237 
00238   /// \brief The number of columns to use for indentation.
00239   unsigned IndentWidth;
00240 
00241   /// \brief The number of columns used for tab stops.
00242   unsigned TabWidth;
00243 
00244   /// \brief The number of characters to use for indentation of constructor
00245   /// initializer lists.
00246   unsigned ConstructorInitializerIndentWidth;
00247 
00248   /// \brief The number of characters to use for indentation of ObjC blocks.
00249   unsigned ObjCBlockIndentWidth;
00250 
00251   /// \brief If \c true, always break after function definition return types.
00252   ///
00253   /// More truthfully called 'break before the identifier following the type
00254   /// in a function definition'. PenaltyReturnTypeOnItsOwnLine becomes
00255   /// irrelevant.
00256   bool AlwaysBreakAfterDefinitionReturnType;
00257 
00258   /// \brief If \c true, always break after the <tt>template<...></tt> of a
00259   /// template declaration.
00260   bool AlwaysBreakTemplateDeclarations;
00261 
00262   /// \brief If \c true, always break before multiline string literals.
00263   bool AlwaysBreakBeforeMultilineStrings;
00264 
00265   /// \brief Different ways to use tab in formatting.
00266   enum UseTabStyle {
00267     /// Never use tab.
00268     UT_Never,
00269     /// Use tabs only for indentation.
00270     UT_ForIndentation,
00271     /// Use tabs whenever we need to fill whitespace that spans at least from
00272     /// one tab stop to the next one.
00273     UT_Always
00274   };
00275 
00276   /// \brief The way to use tab characters in the resulting file.
00277   UseTabStyle UseTab;
00278 
00279   /// \brief The style of breaking before or after binary operators.
00280   enum BinaryOperatorStyle {
00281     /// Break after operators.
00282     BOS_None,
00283     /// Break before operators that aren't assignments.
00284     BOS_NonAssignment,
00285     /// Break before operators.
00286     BOS_All,
00287   };
00288 
00289   /// \brief The way to wrap binary operators.
00290   BinaryOperatorStyle BreakBeforeBinaryOperators;
00291 
00292   /// \brief If \c true, ternary operators will be placed after line breaks.
00293   bool BreakBeforeTernaryOperators;
00294 
00295   /// \brief Different ways to attach braces to their surrounding context.
00296   enum BraceBreakingStyle {
00297     /// Always attach braces to surrounding context.
00298     BS_Attach,
00299     /// Like \c Attach, but break before braces on function, namespace and
00300     /// class definitions.
00301     BS_Linux,
00302     /// Like \c Attach, but break before function definitions, and 'else'.
00303     BS_Stroustrup,
00304     /// Always break before braces.
00305     BS_Allman,
00306     /// Always break before braces and add an extra level of indentation to
00307     /// braces of control statements, not to those of class, function
00308     /// or other definitions.
00309     BS_GNU
00310   };
00311 
00312   /// \brief The brace breaking style to use.
00313   BraceBreakingStyle BreakBeforeBraces;
00314 
00315   /// \brief If \c true, format braced lists as best suited for C++11 braced
00316   /// lists.
00317   ///
00318   /// Important differences:
00319   /// - No spaces inside the braced list.
00320   /// - No line break before the closing brace.
00321   /// - Indentation with the continuation indent, not with the block indent.
00322   ///
00323   /// Fundamentally, C++11 braced lists are formatted exactly like function
00324   /// calls would be formatted in their place. If the braced list follows a name
00325   /// (e.g. a type or variable name), clang-format formats as if the \c {} were
00326   /// the parentheses of a function call with that name. If there is no name,
00327   /// a zero-length name is assumed.
00328   bool Cpp11BracedListStyle;
00329 
00330   /// \brief If \c true, spaces will be inserted after '(' and before ')'.
00331   bool SpacesInParentheses;
00332 
00333   /// \brief If \c true, spaces will be inserted after '<' and before '>' in
00334   /// template argument lists
00335   bool SpacesInAngles;
00336 
00337   /// \brief If \c true, spaces will be inserted after '[' and before ']'.
00338   bool SpacesInSquareBrackets;
00339 
00340   /// \brief If \c true, spaces may be inserted into '()'.
00341   bool SpaceInEmptyParentheses;
00342 
00343   /// \brief If \c true, spaces are inserted inside container literals (e.g.
00344   /// ObjC and Javascript array and dict literals).
00345   bool SpacesInContainerLiterals;
00346 
00347   /// \brief If \c true, spaces may be inserted into C style casts.
00348   bool SpacesInCStyleCastParentheses;
00349 
00350   /// \brief If \c true, a space may be inserted after C style casts.
00351   bool SpaceAfterCStyleCast;
00352 
00353   /// \brief Different ways to put a space before opening parentheses.
00354   enum SpaceBeforeParensOptions {
00355     /// Never put a space before opening parentheses.
00356     SBPO_Never,
00357     /// Put a space before opening parentheses only after control statement
00358     /// keywords (<tt>for/if/while...</tt>).
00359     SBPO_ControlStatements,
00360     /// Always put a space before opening parentheses, except when it's
00361     /// prohibited by the syntax rules (in function-like macro definitions) or
00362     /// when determined by other style rules (after unary operators, opening
00363     /// parentheses, etc.)
00364     SBPO_Always
00365   };
00366 
00367   /// \brief Defines in which cases to put a space before opening parentheses.
00368   SpaceBeforeParensOptions SpaceBeforeParens;
00369 
00370   /// \brief If \c false, spaces will be removed before assignment operators.
00371   bool SpaceBeforeAssignmentOperators;
00372 
00373   /// \brief Indent width for line continuations.
00374   unsigned ContinuationIndentWidth;
00375 
00376   /// \brief A regular expression that describes comments with special meaning,
00377   /// which should not be split into lines or otherwise changed.
00378   std::string CommentPragmas;
00379 
00380   /// \brief Disables formatting at all.
00381   bool DisableFormat;
00382 
00383   /// \brief A vector of macros that should be interpreted as foreach loops
00384   /// instead of as function calls.
00385   ///
00386   /// These are expected to be macros of the form:
00387   /// \code
00388   /// FOREACH(<variable-declaration>, ...)
00389   ///   <loop-body>
00390   /// \endcode
00391   ///
00392   /// For example: BOOST_FOREACH.
00393   std::vector<std::string> ForEachMacros;
00394 
00395   bool operator==(const FormatStyle &R) const {
00396     return AccessModifierOffset == R.AccessModifierOffset &&
00397            AlignEscapedNewlinesLeft == R.AlignEscapedNewlinesLeft &&
00398            AlignTrailingComments == R.AlignTrailingComments &&
00399            AllowAllParametersOfDeclarationOnNextLine ==
00400                R.AllowAllParametersOfDeclarationOnNextLine &&
00401            AllowShortFunctionsOnASingleLine ==
00402                R.AllowShortFunctionsOnASingleLine &&
00403            AllowShortBlocksOnASingleLine == R.AllowShortBlocksOnASingleLine &&
00404            AllowShortIfStatementsOnASingleLine ==
00405                R.AllowShortIfStatementsOnASingleLine &&
00406            AllowShortLoopsOnASingleLine == R.AllowShortLoopsOnASingleLine &&
00407            AlwaysBreakAfterDefinitionReturnType ==
00408                R.AlwaysBreakAfterDefinitionReturnType &&
00409            AlwaysBreakTemplateDeclarations ==
00410                R.AlwaysBreakTemplateDeclarations &&
00411            AlwaysBreakBeforeMultilineStrings ==
00412                R.AlwaysBreakBeforeMultilineStrings &&
00413            BinPackParameters == R.BinPackParameters &&
00414            BinPackArguments == R.BinPackArguments &&
00415            BreakBeforeBinaryOperators == R.BreakBeforeBinaryOperators &&
00416            BreakBeforeTernaryOperators == R.BreakBeforeTernaryOperators &&
00417            BreakBeforeBraces == R.BreakBeforeBraces &&
00418            BreakConstructorInitializersBeforeComma ==
00419                R.BreakConstructorInitializersBeforeComma &&
00420            ColumnLimit == R.ColumnLimit &&
00421            ConstructorInitializerAllOnOneLineOrOnePerLine ==
00422                R.ConstructorInitializerAllOnOneLineOrOnePerLine &&
00423            ConstructorInitializerIndentWidth ==
00424                R.ConstructorInitializerIndentWidth &&
00425            DerivePointerAlignment == R.DerivePointerAlignment &&
00426            ExperimentalAutoDetectBinPacking ==
00427                R.ExperimentalAutoDetectBinPacking &&
00428            IndentCaseLabels == R.IndentCaseLabels &&
00429            IndentWrappedFunctionNames == R.IndentWrappedFunctionNames &&
00430            IndentWidth == R.IndentWidth && Language == R.Language &&
00431            MaxEmptyLinesToKeep == R.MaxEmptyLinesToKeep &&
00432            KeepEmptyLinesAtTheStartOfBlocks ==
00433                R.KeepEmptyLinesAtTheStartOfBlocks &&
00434            NamespaceIndentation == R.NamespaceIndentation &&
00435            ObjCBlockIndentWidth == R.ObjCBlockIndentWidth &&
00436            ObjCSpaceAfterProperty == R.ObjCSpaceAfterProperty &&
00437            ObjCSpaceBeforeProtocolList == R.ObjCSpaceBeforeProtocolList &&
00438            PenaltyBreakComment == R.PenaltyBreakComment &&
00439            PenaltyBreakFirstLessLess == R.PenaltyBreakFirstLessLess &&
00440            PenaltyBreakString == R.PenaltyBreakString &&
00441            PenaltyExcessCharacter == R.PenaltyExcessCharacter &&
00442            PenaltyReturnTypeOnItsOwnLine == R.PenaltyReturnTypeOnItsOwnLine &&
00443            PointerAlignment == R.PointerAlignment &&
00444            SpacesBeforeTrailingComments == R.SpacesBeforeTrailingComments &&
00445            Cpp11BracedListStyle == R.Cpp11BracedListStyle &&
00446            Standard == R.Standard && TabWidth == R.TabWidth &&
00447            UseTab == R.UseTab && SpacesInParentheses == R.SpacesInParentheses &&
00448            SpacesInSquareBrackets == R.SpacesInSquareBrackets &&
00449            SpacesInAngles == R.SpacesInAngles &&
00450            SpaceInEmptyParentheses == R.SpaceInEmptyParentheses &&
00451            SpacesInContainerLiterals == R.SpacesInContainerLiterals &&
00452            SpacesInCStyleCastParentheses == R.SpacesInCStyleCastParentheses &&
00453            SpaceAfterCStyleCast == R.SpaceAfterCStyleCast &&
00454            SpaceBeforeParens == R.SpaceBeforeParens &&
00455            SpaceBeforeAssignmentOperators == R.SpaceBeforeAssignmentOperators &&
00456            ContinuationIndentWidth == R.ContinuationIndentWidth &&
00457            CommentPragmas == R.CommentPragmas &&
00458            ForEachMacros == R.ForEachMacros;
00459   }
00460 };
00461 
00462 /// \brief Returns a format style complying with the LLVM coding standards:
00463 /// http://llvm.org/docs/CodingStandards.html.
00464 FormatStyle getLLVMStyle();
00465 
00466 /// \brief Returns a format style complying with one of Google's style guides:
00467 /// http://google-styleguide.googlecode.com/svn/trunk/cppguide.xml.
00468 /// http://google-styleguide.googlecode.com/svn/trunk/javascriptguide.xml.
00469 /// https://developers.google.com/protocol-buffers/docs/style.
00470 FormatStyle getGoogleStyle(FormatStyle::LanguageKind Language);
00471 
00472 /// \brief Returns a format style complying with Chromium's style guide:
00473 /// http://www.chromium.org/developers/coding-style.
00474 FormatStyle getChromiumStyle(FormatStyle::LanguageKind Language);
00475 
00476 /// \brief Returns a format style complying with Mozilla's style guide:
00477 /// https://developer.mozilla.org/en-US/docs/Developer_Guide/Coding_Style.
00478 FormatStyle getMozillaStyle();
00479 
00480 /// \brief Returns a format style complying with Webkit's style guide:
00481 /// http://www.webkit.org/coding/coding-style.html
00482 FormatStyle getWebKitStyle();
00483 
00484 /// \brief Returns a format style complying with GNU Coding Standards:
00485 /// http://www.gnu.org/prep/standards/standards.html
00486 FormatStyle getGNUStyle();
00487 
00488 /// \brief Returns style indicating formatting should be not applied at all.
00489 FormatStyle getNoStyle();
00490 
00491 /// \brief Gets a predefined style for the specified language by name.
00492 ///
00493 /// Currently supported names: LLVM, Google, Chromium, Mozilla. Names are
00494 /// compared case-insensitively.
00495 ///
00496 /// Returns \c true if the Style has been set.
00497 bool getPredefinedStyle(StringRef Name, FormatStyle::LanguageKind Language,
00498                         FormatStyle *Style);
00499 
00500 /// \brief Parse configuration from YAML-formatted text.
00501 ///
00502 /// Style->Language is used to get the base style, if the \c BasedOnStyle
00503 /// option is present.
00504 ///
00505 /// When \c BasedOnStyle is not present, options not present in the YAML
00506 /// document, are retained in \p Style.
00507 std::error_code parseConfiguration(StringRef Text, FormatStyle *Style);
00508 
00509 /// \brief Gets configuration in a YAML string.
00510 std::string configurationAsText(const FormatStyle &Style);
00511 
00512 /// \brief Reformats the given \p Ranges in the token stream coming out of
00513 /// \c Lex.
00514 ///
00515 /// DEPRECATED: Do not use.
00516 tooling::Replacements reformat(const FormatStyle &Style, Lexer &Lex,
00517                                SourceManager &SourceMgr,
00518                                ArrayRef<CharSourceRange> Ranges);
00519 
00520 /// \brief Reformats the given \p Ranges in the file \p ID.
00521 ///
00522 /// Each range is extended on either end to its next bigger logic unit, i.e.
00523 /// everything that might influence its formatting or might be influenced by its
00524 /// formatting.
00525 ///
00526 /// Returns the \c Replacements necessary to make all \p Ranges comply with
00527 /// \p Style.
00528 tooling::Replacements reformat(const FormatStyle &Style,
00529                                SourceManager &SourceMgr, FileID ID,
00530                                ArrayRef<CharSourceRange> Ranges);
00531 
00532 /// \brief Reformats the given \p Ranges in \p Code.
00533 ///
00534 /// Otherwise identical to the reformat() function consuming a \c Lexer.
00535 tooling::Replacements reformat(const FormatStyle &Style, StringRef Code,
00536                                ArrayRef<tooling::Range> Ranges,
00537                                StringRef FileName = "<stdin>");
00538 
00539 /// \brief Returns the \c LangOpts that the formatter expects you to set.
00540 ///
00541 /// \param Style determines specific settings for lexing mode.
00542 LangOptions getFormattingLangOpts(const FormatStyle &Style = getLLVMStyle());
00543 
00544 /// \brief Description to be used for help text for a llvm::cl option for
00545 /// specifying format style. The description is closely related to the operation
00546 /// of getStyle().
00547 extern const char *StyleOptionHelpDescription;
00548 
00549 /// \brief Construct a FormatStyle based on \c StyleName.
00550 ///
00551 /// \c StyleName can take several forms:
00552 /// \li "{<key>: <value>, ...}" - Set specic style parameters.
00553 /// \li "<style name>" - One of the style names supported by
00554 /// getPredefinedStyle().
00555 /// \li "file" - Load style configuration from a file called '.clang-format'
00556 /// located in one of the parent directories of \c FileName or the current
00557 /// directory if \c FileName is empty.
00558 ///
00559 /// \param[in] StyleName Style name to interpret according to the description
00560 /// above.
00561 /// \param[in] FileName Path to start search for .clang-format if \c StyleName
00562 /// == "file".
00563 /// \param[in] FallbackStyle The name of a predefined style used to fallback to
00564 /// in case the style can't be determined from \p StyleName.
00565 ///
00566 /// \returns FormatStyle as specified by \c StyleName. If no style could be
00567 /// determined, the default is LLVM Style (see getLLVMStyle()).
00568 FormatStyle getStyle(StringRef StyleName, StringRef FileName,
00569                      StringRef FallbackStyle);
00570 
00571 } // end namespace format
00572 } // end namespace clang
00573 
00574 namespace std {
00575 template <>
00576 struct is_error_code_enum<clang::format::ParseError> : std::true_type {};
00577 }
00578 
00579 #endif // LLVM_CLANG_FORMAT_FORMAT_H