clang
3.9.0
|
Namespaces | |
encoding | |
Classes | |
class | ParseErrorCategory |
struct | FormatStyle |
The FormatStyle is used to configure the formatting to follow specific guidelines. More... | |
class | AffectedRangeManager |
class | BreakableToken |
Base class for strategies on how to break tokens. More... | |
class | BreakableSingleLineToken |
Base class for single line tokens that can be broken. More... | |
class | BreakableStringLiteral |
class | BreakableLineComment |
class | BreakableBlockComment |
class | ContinuationIndenter |
struct | ParenState |
struct | LineState |
The current state when indenting a unwrapped line. More... | |
struct | FormatToken |
A wrapper around a Token storing information about the whitespace characters preceding it. More... | |
class | TokenRole |
class | CommaSeparatedList |
struct | AdditionalKeywords |
Encapsulates keywords that are context sensitive or for languages not properly supported by Clang's lexer. More... | |
class | FormatTokenLexer |
struct | JsImportedSymbol |
struct | JsModuleReference |
class | JavaScriptImportSorter |
class | Environment |
class | TokenAnalyzer |
class | AnnotatedLine |
class | TokenAnnotator |
Determines extra information about the tokens comprising an UnwrappedLine . More... | |
class | UnwrappedLineFormatter |
class | FormatTokenSource |
class | ScopedLineState |
class | CompoundStatementIndenter |
struct | UnwrappedLine |
An unwrapped line is a sequence of Token , that we would like to put on a single line if there was no column limit. More... | |
class | UnwrappedLineConsumer |
class | UnwrappedLineParser |
struct | UnwrappedLineNode |
class | WhitespaceManager |
Manages the whitespaces around tokens and their replacements. More... | |
Enumerations | |
enum | ParseError { ParseError::Success = 0, ParseError::Error, ParseError::Unsuitable } |
enum | TokenType { NUM_TOKEN_TYPES } |
enum | BraceBlockKind { BK_Unknown, BK_Block, BK_BracedInit } |
enum | ParameterPackingKind { PPK_BinPacked, PPK_OnePerLine, PPK_Inconclusive } |
enum | FormatDecision { FD_Unformatted, FD_Continue, FD_Break } |
enum | LineType { LT_Invalid, LT_ImportStatement, LT_ObjCDecl, LT_ObjCMethodDecl, LT_ObjCProperty, LT_Other, LT_PreprocessorDirective, LT_VirtualFunctionDecl } |
Functions | |
const std::error_category & | getParseCategory () |
std::error_code | make_error_code (ParseError e) |
FormatStyle | getLLVMStyle () |
Returns a format style complying with the LLVM coding standards: http://llvm.org/docs/CodingStandards.html. More... | |
FormatStyle | getGoogleStyle (FormatStyle::LanguageKind Language) |
Returns a format style complying with one of Google's style guides: http://google-styleguide.googlecode.com/svn/trunk/cppguide.xml. More... | |
FormatStyle | getChromiumStyle (FormatStyle::LanguageKind Language) |
Returns a format style complying with Chromium's style guide: http://www.chromium.org/developers/coding-style. More... | |
FormatStyle | getMozillaStyle () |
Returns a format style complying with Mozilla's style guide: https://developer.mozilla.org/en-US/docs/Developer_Guide/Coding_Style. More... | |
FormatStyle | getWebKitStyle () |
Returns a format style complying with Webkit's style guide: http://www.webkit.org/coding/coding-style.html. More... | |
FormatStyle | getGNUStyle () |
Returns a format style complying with GNU Coding Standards: http://www.gnu.org/prep/standards/standards.html. More... | |
FormatStyle | getNoStyle () |
Returns style indicating formatting should be not applied at all. More... | |
bool | getPredefinedStyle (StringRef Name, FormatStyle::LanguageKind Language, FormatStyle *Style) |
Gets a predefined style for the specified language by name. More... | |
std::error_code | parseConfiguration (StringRef Text, FormatStyle *Style) |
Parse configuration from YAML-formatted text. More... | |
std::string | configurationAsText (const FormatStyle &Style) |
Gets configuration in a YAML string. More... | |
tooling::Replacements | sortIncludes (const FormatStyle &Style, StringRef Code, ArrayRef< tooling::Range > Ranges, StringRef FileName, unsigned *Cursor=nullptr) |
Returns the replacements necessary to sort all #include blocks that are affected by Ranges . More... | |
llvm::Expected < tooling::Replacements > | formatReplacements (StringRef Code, const tooling::Replacements &Replaces, const FormatStyle &Style) |
Returns the replacements corresponding to applying and formatting Replaces on success; otheriwse, return an llvm::Error carrying llvm::StringError. More... | |
llvm::Expected < tooling::Replacements > | cleanupAroundReplacements (StringRef Code, const tooling::Replacements &Replaces, const FormatStyle &Style) |
Returns the replacements corresponding to applying Replaces and cleaning up the code after that on success; otherwise, return an llvm::Error carrying llvm::StringError. More... | |
tooling::Replacements | reformat (const FormatStyle &Style, SourceManager &SourceMgr, FileID ID, ArrayRef< CharSourceRange > Ranges, bool *IncompleteFormat=nullptr) |
Reformats the given Ranges in the file ID . More... | |
tooling::Replacements | reformat (const FormatStyle &Style, StringRef Code, ArrayRef< tooling::Range > Ranges, StringRef FileName="<stdin>", bool *IncompleteFormat=nullptr) |
Reformats the given Ranges in Code . More... | |
tooling::Replacements | cleanup (const FormatStyle &Style, SourceManager &SourceMgr, FileID ID, ArrayRef< CharSourceRange > Ranges) |
Clean up any erroneous/redundant code in the given Ranges in the file ID . More... | |
tooling::Replacements | cleanup (const FormatStyle &Style, StringRef Code, ArrayRef< tooling::Range > Ranges, StringRef FileName="<stdin>") |
Clean up any erroneous/redundant code in the given Ranges in Code . More... | |
LangOptions | getFormattingLangOpts (const FormatStyle &Style=getLLVMStyle()) |
Returns the LangOpts that the formatter expects you to set. More... | |
FormatStyle | getStyle (StringRef StyleName, StringRef FileName, StringRef FallbackStyle, vfs::FileSystem *FS=nullptr) |
Construct a FormatStyle based on StyleName . More... | |
StringRef | getLanguageName (FormatStyle::LanguageKind Language) |
static bool | IsBlank (char C) |
static BreakableToken::Split | getCommentSplit (StringRef Text, unsigned ContentStartColumn, unsigned ColumnLimit, unsigned TabWidth, encoding::Encoding Encoding) |
static BreakableToken::Split | getStringSplit (StringRef Text, unsigned UsedColumns, unsigned ColumnLimit, unsigned TabWidth, encoding::Encoding Encoding) |
static StringRef | getLineCommentIndentPrefix (StringRef Comment) |
static unsigned | getLengthToMatchingParen (const FormatToken &Tok) |
static unsigned | getLengthToNextOperator (const FormatToken &Tok) |
static bool | startsSegmentOfBuilderTypeCall (const FormatToken &Tok) |
static bool | startsNextParameter (const FormatToken &Current, const FormatStyle &Style) |
static FormatStyle | expandPresets (const FormatStyle &Style) |
static bool | affectsRange (ArrayRef< tooling::Range > Ranges, unsigned Start, unsigned End) |
static void | sortCppIncludes (const FormatStyle &Style, const SmallVectorImpl< IncludeDirective > &Includes, ArrayRef< tooling::Range > Ranges, StringRef FileName, tooling::Replacements &Replaces, unsigned *Cursor) |
tooling::Replacements | sortCppIncludes (const FormatStyle &Style, StringRef Code, ArrayRef< tooling::Range > Ranges, StringRef FileName, tooling::Replacements &Replaces, unsigned *Cursor) |
template<typename T > | |
static llvm::Expected < tooling::Replacements > | processReplacements (T ProcessFunc, StringRef Code, const tooling::Replacements &Replaces, const FormatStyle &Style) |
static FormatStyle::LanguageKind | getLanguageByFileName (StringRef FileName) |
const char * | getTokenTypeName (TokenType Type) |
Determines the name of a token type. More... | |
static unsigned | CodePointsBetween (const FormatToken *Begin, const FormatToken *End) |
bool | operator< (const JsModuleReference &LHS, const JsModuleReference &RHS) |
tooling::Replacements | sortJavaScriptImports (const FormatStyle &Style, StringRef Code, ArrayRef< tooling::Range > Ranges, StringRef FileName) |
static bool | isFunctionDeclarationName (const FormatToken &Current, const AnnotatedLine &Line) |
static bool | isAllmanBrace (const FormatToken &Tok) |
static bool | isGoogScope (const UnwrappedLine &Line) |
static bool | ShouldBreakBeforeBrace (const FormatStyle &Style, const FormatToken &InitialToken) |
static bool | tokenCanStartNewLine (const clang::Token &Tok) |
static bool | mustBeJSIdent (const AdditionalKeywords &Keywords, const FormatToken *FormatTok) |
static bool | mustBeJSIdentOrValue (const AdditionalKeywords &Keywords, const FormatToken *FormatTok) |
static bool | isJSDeclOrStmt (const AdditionalKeywords &Keywords, const FormatToken *FormatTok) |
static LLVM_ATTRIBUTE_UNUSED void | printDebugInfo (const UnwrappedLine &Line, StringRef Prefix="") |
template<typename F > | |
static void | AlignTokenSequence (unsigned Start, unsigned End, unsigned Column, F &&Matches, SmallVector< WhitespaceManager::Change, 16 > &Changes) |
template<typename F > | |
static void | AlignTokens (const FormatStyle &Style, F &&Matches, SmallVector< WhitespaceManager::Change, 16 > &Changes) |
Variables | |
const char * | StyleOptionHelpDescription |
Description to be used for help text for a llvm::cl option for specifying format style. More... | |
static const char *const | Blanks = " \t\v\f\r" |
Enumerator | |
---|---|
BK_Unknown | |
BK_Block | |
BK_BracedInit |
Definition at line 101 of file FormatToken.h.
Enumerator | |
---|---|
FD_Unformatted | |
FD_Continue | |
FD_Break |
Definition at line 106 of file FormatToken.h.
Enumerator | |
---|---|
LT_Invalid | |
LT_ImportStatement | |
LT_ObjCDecl | |
LT_ObjCMethodDecl | |
LT_ObjCProperty | |
LT_Other | |
LT_PreprocessorDirective | |
LT_VirtualFunctionDecl |
Definition at line 28 of file TokenAnnotator.h.
Enumerator | |
---|---|
PPK_BinPacked | |
PPK_OnePerLine | |
PPK_Inconclusive |
Definition at line 104 of file FormatToken.h.
|
strong |
Enumerator | |
---|---|
NUM_TOKEN_TYPES |
Definition at line 90 of file FormatToken.h.
|
static |
Definition at line 1203 of file Format.cpp.
Referenced by sortCppIncludes().
|
static |
Definition at line 199 of file WhitespaceManager.cpp.
References AlignTokenSequence(), clang::format::FormatStyle::ColumnLimit, Matches, max(), min(), and UINT_MAX.
|
static |
Definition at line 166 of file WhitespaceManager.cpp.
References End, Matches, and clang::prec::Shift.
Referenced by AlignTokens().
tooling::Replacements clang::format::cleanup | ( | const FormatStyle & | Style, |
SourceManager & | SourceMgr, | ||
FileID | ID, | ||
ArrayRef< CharSourceRange > | Ranges | ||
) |
Clean up any erroneous/redundant code in the given Ranges
in the file ID
.
Returns the Replacements
that clean up all Ranges
in the file ID
.
Definition at line 1639 of file Format.cpp.
Referenced by cleanupAroundReplacements(), clang::CodeGen::EHScopeStack::containsOnlyLifetimeMarkers(), clang::CodeGen::CodeGenFunction::EmitAnyExprToExn(), clang::CodeGen::CodeGenFunction::EmitBlockLiteral(), clang::CodeGen::EHScopeStack::getInnermostActiveNormalCleanup(), clang::CodeGen::CodeGenFunction::initFullExprCleanup(), IsUsedAsEHCleanup(), clang::CodeGen::EHScopeStack::requiresLandingPad(), and clang::CodeGen::CGBlockInfo::Capture::setCleanup().
tooling::Replacements clang::format::cleanup | ( | const FormatStyle & | Style, |
StringRef | Code, | ||
ArrayRef< tooling::Range > | Ranges, | ||
StringRef | FileName = "<stdin>" |
||
) |
Clean up any erroneous/redundant code in the given Ranges
in Code
.
Otherwise identical to the cleanup() function using a file ID.
Definition at line 1646 of file Format.cpp.
References clang::format::Environment::CreateVirtualEnvironment().
llvm::Expected< tooling::Replacements > clang::format::cleanupAroundReplacements | ( | StringRef | Code, |
const tooling::Replacements & | Replaces, | ||
const FormatStyle & | Style | ||
) |
Returns the replacements corresponding to applying Replaces
and cleaning up the code after that on success; otherwise, return an llvm::Error carrying llvm::StringError.
This also inserts a C++ #include directive into the correct block if the replacement corresponding to the header insertion has offset UINT_MAX.
Definition at line 1599 of file Format.cpp.
References cleanup(), FileName, processReplacements(), and Style.
|
static |
Definition at line 140 of file FormatToken.cpp.
References clang::format::FormatToken::ColumnWidth, and clang::format::FormatToken::TotalLength.
Referenced by clang::format::CommaSeparatedList::precomputeFormattingInfos().
std::string clang::format::configurationAsText | ( | const FormatStyle & | Style | ) |
Gets configuration in a YAML string.
Definition at line 781 of file Format.cpp.
References expandPresets(), and Text.
|
static |
Definition at line 439 of file Format.cpp.
References clang::format::FormatStyle::BraceWrappingFlags::AfterClass, clang::format::FormatStyle::BraceWrappingFlags::AfterControlStatement, clang::format::FormatStyle::BraceWrappingFlags::AfterEnum, clang::format::FormatStyle::BraceWrappingFlags::AfterFunction, clang::format::FormatStyle::BraceWrappingFlags::AfterNamespace, clang::format::FormatStyle::BraceWrappingFlags::AfterObjCDeclaration, clang::format::FormatStyle::BraceWrappingFlags::AfterStruct, clang::format::FormatStyle::BraceWrappingFlags::AfterUnion, clang::format::FormatStyle::BraceWrappingFlags::BeforeCatch, clang::format::FormatStyle::BraceWrappingFlags::BeforeElse, clang::format::FormatStyle::BraceWrapping, clang::format::FormatStyle::BreakBeforeBraces, clang::format::FormatStyle::BS_Allman, clang::format::FormatStyle::BS_Custom, clang::format::FormatStyle::BS_GNU, clang::format::FormatStyle::BS_Linux, clang::format::FormatStyle::BS_Mozilla, clang::format::FormatStyle::BS_Stroustrup, clang::format::FormatStyle::BS_WebKit, and Style.
Referenced by configurationAsText(), and reformat().
llvm::Expected< tooling::Replacements > clang::format::formatReplacements | ( | StringRef | Code, |
const tooling::Replacements & | Replaces, | ||
const FormatStyle & | Style | ||
) |
Returns the replacements corresponding to applying and formatting Replaces
on success; otheriwse, return an llvm::Error carrying llvm::StringError.
Definition at line 1417 of file Format.cpp.
References FileName, processReplacements(), reformat(), sortIncludes(), and Style.
Referenced by clang::tooling::formatAndApplyAllReplacements().
FormatStyle clang::format::getChromiumStyle | ( | FormatStyle::LanguageKind | Language | ) |
Returns a format style complying with Chromium's style guide: http://www.chromium.org/developers/coding-style.
Definition at line 629 of file Format.cpp.
References clang::format::FormatStyle::AllowAllParametersOfDeclarationOnNextLine, clang::format::FormatStyle::AllowShortFunctionsOnASingleLine, clang::format::FormatStyle::AllowShortIfStatementsOnASingleLine, clang::format::FormatStyle::AllowShortLoopsOnASingleLine, clang::format::FormatStyle::BinPackParameters, clang::format::FormatStyle::BreakAfterJavaFieldAnnotations, clang::format::FormatStyle::ContinuationIndentWidth, clang::format::FormatStyle::DerivePointerAlignment, getGoogleStyle(), clang::format::FormatStyle::IndentWidth, clang::format::FormatStyle::LK_Java, clang::format::FormatStyle::SFS_Inline, and clang::format::FormatStyle::SortIncludes.
Referenced by getPredefinedStyle().
|
static |
Definition at line 42 of file BreakableToken.cpp.
References Blanks, clang::format::encoding::columnWidthWithTabs(), and clang::format::encoding::getCodePointNumBytes().
Referenced by clang::format::BreakableLineComment::getSplit(), and clang::format::BreakableBlockComment::getSplit().
LangOptions clang::format::getFormattingLangOpts | ( | const FormatStyle & | Style = getLLVMStyle() | ) |
Returns the LangOpts
that the formatter expects you to set.
Style | determines specific settings for lexing mode. |
Definition at line 1655 of file Format.cpp.
References clang::format::FormatStyle::Language, clang::format::FormatStyle::LK_Cpp, clang::format::FormatStyle::LS_Cpp03, and clang::format::FormatStyle::Standard.
Referenced by clang::format::FormatTokenLexer::FormatTokenLexer().
FormatStyle clang::format::getGNUStyle | ( | ) |
Returns a format style complying with GNU Coding Standards: http://www.gnu.org/prep/standards/standards.html.
Definition at line 690 of file Format.cpp.
References clang::format::FormatStyle::AlwaysBreakAfterDefinitionReturnType, clang::format::FormatStyle::AlwaysBreakAfterReturnType, clang::format::FormatStyle::BOS_All, clang::format::FormatStyle::BreakBeforeBinaryOperators, clang::format::FormatStyle::BreakBeforeBraces, clang::format::FormatStyle::BreakBeforeTernaryOperators, clang::format::FormatStyle::BS_GNU, clang::format::FormatStyle::ColumnLimit, clang::format::FormatStyle::Cpp11BracedListStyle, clang::format::FormatStyle::DRTBS_All, getLLVMStyle(), clang::format::FormatStyle::LS_Cpp03, clang::format::FormatStyle::RTBS_AllDefinitions, clang::format::FormatStyle::SBPO_Always, clang::format::FormatStyle::SpaceBeforeParens, clang::format::FormatStyle::Standard, and Style.
Referenced by getPredefinedStyle().
FormatStyle clang::format::getGoogleStyle | ( | FormatStyle::LanguageKind | Language | ) |
Returns a format style complying with one of Google's style guides: http://google-styleguide.googlecode.com/svn/trunk/cppguide.xml.
http://google-styleguide.googlecode.com/svn/trunk/javascriptguide.xml. https://developers.google.com/protocol-buffers/docs/style.
Definition at line 573 of file Format.cpp.
References clang::format::FormatStyle::AccessModifierOffset, clang::format::FormatStyle::AlignAfterOpenBracket, clang::format::FormatStyle::AlignEscapedNewlinesLeft, clang::format::FormatStyle::AlignOperands, clang::format::FormatStyle::AlignTrailingComments, clang::format::FormatStyle::AllowShortFunctionsOnASingleLine, clang::format::FormatStyle::AllowShortIfStatementsOnASingleLine, clang::format::FormatStyle::AllowShortLoopsOnASingleLine, clang::format::FormatStyle::AlwaysBreakBeforeMultilineStrings, clang::format::FormatStyle::AlwaysBreakTemplateDeclarations, clang::format::FormatStyle::BAS_AlwaysBreak, clang::format::FormatStyle::BAS_DontAlign, clang::format::FormatStyle::BOS_NonAssignment, clang::format::FormatStyle::BreakBeforeBinaryOperators, clang::format::FormatStyle::BreakBeforeTernaryOperators, clang::format::FormatStyle::ColumnLimit, clang::format::FormatStyle::CommentPragmas, clang::format::FormatStyle::ConstructorInitializerAllOnOneLineOrOnePerLine, clang::format::FormatStyle::DerivePointerAlignment, getLLVMStyle(), clang::format::FormatStyle::IncludeCategories, clang::format::FormatStyle::IncludeIsMainRegex, clang::format::FormatStyle::IndentCaseLabels, clang::format::FormatStyle::JavaScriptQuotes, clang::format::FormatStyle::JavaScriptWrapImports, clang::format::FormatStyle::JSQS_Single, clang::format::FormatStyle::KeepEmptyLinesAtTheStartOfBlocks, clang::format::FormatStyle::Language, clang::format::FormatStyle::LK_Java, clang::format::FormatStyle::LK_JavaScript, clang::format::FormatStyle::LK_Proto, clang::format::FormatStyle::LS_Auto, clang::format::FormatStyle::MaxEmptyLinesToKeep, clang::format::FormatStyle::NamespaceIndentation, clang::format::FormatStyle::NI_All, clang::format::FormatStyle::ObjCSpaceAfterProperty, clang::format::FormatStyle::ObjCSpaceBeforeProtocolList, clang::format::FormatStyle::PAS_Left, clang::format::FormatStyle::PenaltyBreakBeforeFirstCallParameter, clang::format::FormatStyle::PenaltyReturnTypeOnItsOwnLine, clang::format::FormatStyle::PointerAlignment, clang::format::FormatStyle::SFS_Empty, clang::format::FormatStyle::SFS_Inline, clang::format::FormatStyle::SFS_None, clang::format::FormatStyle::SpaceAfterCStyleCast, clang::format::FormatStyle::SpacesBeforeTrailingComments, clang::format::FormatStyle::SpacesInContainerLiterals, and clang::format::FormatStyle::Standard.
Referenced by getChromiumStyle(), and getPredefinedStyle().
|
static |
Definition at line 1682 of file Format.cpp.
References clang::format::FormatStyle::LK_Cpp, clang::format::FormatStyle::LK_Java, clang::format::FormatStyle::LK_JavaScript, clang::format::FormatStyle::LK_Proto, and clang::format::FormatStyle::LK_TableGen.
Referenced by getStyle().
|
inline |
Definition at line 864 of file Format.h.
References clang::format::FormatStyle::LK_Cpp, clang::format::FormatStyle::LK_Java, clang::format::FormatStyle::LK_JavaScript, and clang::format::FormatStyle::LK_Proto.
Referenced by getStyle(), and clang::format::TokenAnalyzer::TokenAnalyzer().
|
static |
Definition at line 31 of file ContinuationIndenter.cpp.
References clang::format::FormatToken::CanBreakBefore, End, clang::format::FormatToken::MatchingParen, clang::format::FormatToken::Next, and clang::format::FormatToken::TotalLength.
Referenced by clang::format::ContinuationIndenter::mustBreak().
|
static |
Definition at line 41 of file ContinuationIndenter.cpp.
References clang::format::FormatToken::NextOperator, and clang::format::FormatToken::TotalLength.
Referenced by clang::format::ContinuationIndenter::mustBreak().
|
static |
Definition at line 185 of file BreakableToken.cpp.
FormatStyle clang::format::getLLVMStyle | ( | ) |
Returns a format style complying with the LLVM coding standards: http://llvm.org/docs/CodingStandards.html.
Definition at line 487 of file Format.cpp.
References clang::format::FormatStyle::AccessModifierOffset, clang::format::FormatStyle::AlignAfterOpenBracket, clang::format::FormatStyle::AlignConsecutiveAssignments, clang::format::FormatStyle::AlignConsecutiveDeclarations, clang::format::FormatStyle::AlignEscapedNewlinesLeft, clang::format::FormatStyle::AlignOperands, clang::format::FormatStyle::AlignTrailingComments, clang::format::FormatStyle::AllowAllParametersOfDeclarationOnNextLine, clang::format::FormatStyle::AllowShortBlocksOnASingleLine, clang::format::FormatStyle::AllowShortCaseLabelsOnASingleLine, clang::format::FormatStyle::AllowShortFunctionsOnASingleLine, clang::format::FormatStyle::AllowShortIfStatementsOnASingleLine, clang::format::FormatStyle::AllowShortLoopsOnASingleLine, clang::format::FormatStyle::AlwaysBreakAfterDefinitionReturnType, clang::format::FormatStyle::AlwaysBreakAfterReturnType, clang::format::FormatStyle::AlwaysBreakBeforeMultilineStrings, clang::format::FormatStyle::AlwaysBreakTemplateDeclarations, clang::format::FormatStyle::BAS_Align, clang::format::FormatStyle::BinPackArguments, clang::format::FormatStyle::BinPackParameters, clang::format::FormatStyle::BOS_None, clang::format::FormatStyle::BraceWrapping, clang::format::FormatStyle::BreakAfterJavaFieldAnnotations, clang::format::FormatStyle::BreakBeforeBinaryOperators, clang::format::FormatStyle::BreakBeforeBraces, clang::format::FormatStyle::BreakBeforeTernaryOperators, clang::format::FormatStyle::BreakConstructorInitializersBeforeComma, clang::format::FormatStyle::BreakStringLiterals, clang::format::FormatStyle::BS_Attach, clang::format::FormatStyle::ColumnLimit, clang::format::FormatStyle::CommentPragmas, clang::format::FormatStyle::ConstructorInitializerAllOnOneLineOrOnePerLine, clang::format::FormatStyle::ConstructorInitializerIndentWidth, clang::format::FormatStyle::ContinuationIndentWidth, clang::format::FormatStyle::Cpp11BracedListStyle, clang::format::FormatStyle::DerivePointerAlignment, clang::format::FormatStyle::DisableFormat, clang::format::FormatStyle::DRTBS_None, clang::format::FormatStyle::ExperimentalAutoDetectBinPacking, clang::format::FormatStyle::ForEachMacros, clang::format::FormatStyle::IncludeCategories, clang::format::FormatStyle::IncludeIsMainRegex, clang::format::FormatStyle::IndentCaseLabels, clang::format::FormatStyle::IndentWidth, clang::format::FormatStyle::IndentWrappedFunctionNames, clang::format::FormatStyle::JavaScriptQuotes, clang::format::FormatStyle::JavaScriptWrapImports, clang::format::FormatStyle::JSQS_Leave, clang::format::FormatStyle::KeepEmptyLinesAtTheStartOfBlocks, clang::format::FormatStyle::Language, clang::format::FormatStyle::LK_Cpp, clang::format::FormatStyle::LS_Cpp11, clang::format::FormatStyle::MaxEmptyLinesToKeep, clang::format::FormatStyle::NamespaceIndentation, clang::format::FormatStyle::NI_None, clang::format::FormatStyle::ObjCBlockIndentWidth, clang::format::FormatStyle::ObjCSpaceAfterProperty, clang::format::FormatStyle::ObjCSpaceBeforeProtocolList, clang::format::FormatStyle::PAS_Right, clang::format::FormatStyle::PenaltyBreakBeforeFirstCallParameter, clang::format::FormatStyle::PenaltyBreakComment, clang::format::FormatStyle::PenaltyBreakFirstLessLess, clang::format::FormatStyle::PenaltyBreakString, clang::format::FormatStyle::PenaltyExcessCharacter, clang::format::FormatStyle::PenaltyReturnTypeOnItsOwnLine, clang::format::FormatStyle::PointerAlignment, clang::format::FormatStyle::ReflowComments, clang::format::FormatStyle::RTBS_None, clang::format::FormatStyle::SBPO_ControlStatements, clang::format::FormatStyle::SFS_All, clang::format::FormatStyle::SortIncludes, clang::format::FormatStyle::SpaceAfterCStyleCast, clang::format::FormatStyle::SpaceBeforeAssignmentOperators, clang::format::FormatStyle::SpaceBeforeParens, clang::format::FormatStyle::SpaceInEmptyParentheses, clang::format::FormatStyle::SpacesBeforeTrailingComments, clang::format::FormatStyle::SpacesInAngles, clang::format::FormatStyle::SpacesInContainerLiterals, clang::format::FormatStyle::SpacesInCStyleCastParentheses, clang::format::FormatStyle::SpacesInParentheses, clang::format::FormatStyle::SpacesInSquareBrackets, clang::format::FormatStyle::Standard, clang::format::FormatStyle::TabWidth, clang::format::FormatStyle::UseTab, and clang::format::FormatStyle::UT_Never.
Referenced by getGNUStyle(), getGoogleStyle(), getMozillaStyle(), getNoStyle(), getPredefinedStyle(), getStyle(), and getWebKitStyle().
FormatStyle clang::format::getMozillaStyle | ( | ) |
Returns a format style complying with Mozilla's style guide: https://developer.mozilla.org/en-US/docs/Developer_Guide/Coding_Style.
Definition at line 648 of file Format.cpp.
References clang::format::FormatStyle::AllowAllParametersOfDeclarationOnNextLine, clang::format::FormatStyle::AllowShortFunctionsOnASingleLine, clang::format::FormatStyle::AlwaysBreakAfterDefinitionReturnType, clang::format::FormatStyle::AlwaysBreakAfterReturnType, clang::format::FormatStyle::AlwaysBreakTemplateDeclarations, clang::format::FormatStyle::BreakBeforeBraces, clang::format::FormatStyle::BreakConstructorInitializersBeforeComma, clang::format::FormatStyle::BS_Mozilla, clang::format::FormatStyle::ConstructorInitializerIndentWidth, clang::format::FormatStyle::ContinuationIndentWidth, clang::format::FormatStyle::Cpp11BracedListStyle, clang::format::FormatStyle::DRTBS_TopLevel, getLLVMStyle(), clang::format::FormatStyle::IndentCaseLabels, clang::format::FormatStyle::ObjCSpaceAfterProperty, clang::format::FormatStyle::ObjCSpaceBeforeProtocolList, clang::format::FormatStyle::PAS_Left, clang::format::FormatStyle::PenaltyReturnTypeOnItsOwnLine, clang::format::FormatStyle::PointerAlignment, clang::format::FormatStyle::RTBS_TopLevelDefinitions, and clang::format::FormatStyle::SFS_Inline.
Referenced by getPredefinedStyle().
FormatStyle clang::format::getNoStyle | ( | ) |
Returns style indicating formatting should be not applied at all.
Definition at line 704 of file Format.cpp.
References clang::format::FormatStyle::DisableFormat, getLLVMStyle(), and clang::format::FormatStyle::SortIncludes.
Referenced by getPredefinedStyle().
const std::error_category & clang::format::getParseCategory | ( | ) |
Definition at line 415 of file Format.cpp.
Referenced by make_error_code().
bool clang::format::getPredefinedStyle | ( | StringRef | Name, |
FormatStyle::LanguageKind | Language, | ||
FormatStyle * | Style | ||
) |
Gets a predefined style for the specified language by name.
Currently supported names: LLVM, Google, Chromium, Mozilla. Names are compared case-insensitively.
Returns true
if the Style has been set.
Definition at line 711 of file Format.cpp.
References getChromiumStyle(), getGNUStyle(), getGoogleStyle(), getLLVMStyle(), getMozillaStyle(), getNoStyle(), getWebKitStyle(), and clang::format::FormatStyle::Language.
Referenced by getStyle(), and llvm::yaml::MappingTraits< FormatStyle >::mapping().
|
static |
Definition at line 86 of file BreakableToken.cpp.
References clang::format::encoding::columnWidthWithTabs(), clang::format::encoding::getCodePointNumBytes(), clang::format::encoding::getEscapeSequenceLength(), clang::isAlphanumeric(), and IsBlank().
Referenced by clang::format::BreakableStringLiteral::getSplit().
FormatStyle clang::format::getStyle | ( | StringRef | StyleName, |
StringRef | FileName, | ||
StringRef | FallbackStyle, | ||
vfs::FileSystem * | FS = nullptr |
||
) |
Construct a FormatStyle based on StyleName
.
StyleName
can take several forms:
.clang-format
located in one of the parent directories of FileName
or the current directory if FileName
is empty.[in] | StyleName | Style name to interpret according to the description above. |
[in] | FileName | Path to start search for .clang-format if StyleName == "file". |
[in] | FallbackStyle | The name of a predefined style used to fallback to in case the style can't be determined from StyleName . |
[in] | FS | The underlying file system, in which the file resides. By default, the file system is the real file system. |
StyleName
. If no style could be determined, the default is LLVM Style (see getLLVMStyle()
). Definition at line 1695 of file Format.cpp.
References clang::vfs::FileSystem::getBufferForFile(), getLanguageByFileName(), getLanguageName(), getLLVMStyle(), getPredefinedStyle(), clang::vfs::getRealFileSystem(), clang::format::FormatStyle::Language, parseConfiguration(), clang::vfs::FileSystem::status(), Style, and Unsuitable.
Referenced by clang::tooling::formatAndApplyAllReplacements().
const char * clang::format::getTokenTypeName | ( | TokenType | Type | ) |
Determines the name of a token type.
Definition at line 26 of file FormatToken.cpp.
References LIST_TOKEN_TYPES, NUM_TOKEN_TYPES, and TokNames.
FormatStyle clang::format::getWebKitStyle | ( | ) |
Returns a format style complying with Webkit's style guide: http://www.webkit.org/coding/coding-style.html.
Definition at line 670 of file Format.cpp.
References clang::format::FormatStyle::AccessModifierOffset, clang::format::FormatStyle::AlignAfterOpenBracket, clang::format::FormatStyle::AlignOperands, clang::format::FormatStyle::AlignTrailingComments, clang::format::FormatStyle::BAS_DontAlign, clang::format::FormatStyle::BOS_All, clang::format::FormatStyle::BreakBeforeBinaryOperators, clang::format::FormatStyle::BreakBeforeBraces, clang::format::FormatStyle::BreakConstructorInitializersBeforeComma, clang::format::FormatStyle::BS_WebKit, clang::format::FormatStyle::ColumnLimit, clang::format::FormatStyle::Cpp11BracedListStyle, getLLVMStyle(), clang::format::FormatStyle::IndentWidth, clang::format::FormatStyle::LS_Cpp03, clang::format::FormatStyle::NamespaceIndentation, clang::format::FormatStyle::NI_Inner, clang::format::FormatStyle::ObjCBlockIndentWidth, clang::format::FormatStyle::ObjCSpaceAfterProperty, clang::format::FormatStyle::PAS_Left, clang::format::FormatStyle::PointerAlignment, clang::format::FormatStyle::Standard, and Style.
Referenced by getPredefinedStyle().
|
static |
Definition at line 2246 of file TokenAnnotator.cpp.
References BK_Block, clang::format::FormatToken::BlockKind, clang::format::FormatToken::is(), and clang::format::FormatToken::isOneOf().
|
static |
Definition at line 29 of file BreakableToken.cpp.
Referenced by getStringSplit().
|
static |
Definition at line 1590 of file TokenAnnotator.cpp.
References clang::format::FormatToken::is(), clang::format::AnnotatedLine::Last, clang::format::FormatToken::MatchingParen, clang::format::FormatToken::NestingLevel, clang::format::FormatToken::Next, Next, and clang::format::FormatToken::Previous.
Referenced by clang::format::TokenAnnotator::calculateFormattingInformation().
|
static |
Definition at line 453 of file UnwrappedLineParser.cpp.
References I, and clang::format::UnwrappedLine::Tokens.
|
static |
Definition at line 688 of file UnwrappedLineParser.cpp.
References clang::format::FormatToken::isOneOf(), clang::format::AdditionalKeywords::kw_async, clang::format::AdditionalKeywords::kw_finally, clang::format::AdditionalKeywords::kw_function, clang::format::AdditionalKeywords::kw_import, clang::format::AdditionalKeywords::kw_let, clang::format::AdditionalKeywords::kw_var, and clang::format::AdditionalKeywords::kw_yield.
std::error_code clang::format::make_error_code | ( | ParseError | e | ) |
Definition at line 419 of file Format.cpp.
References getParseCategory().
Referenced by clang::CompilerInstance::createOutputFile(), clang::vfs::InMemoryFileSystem::dir_begin(), clang::vfs::OverlayFileSystem::openFileForRead(), clang::vfs::InMemoryFileSystem::openFileForRead(), parseConfiguration(), and clang::vfs::OverlayFileSystem::status().
|
static |
Definition at line 666 of file UnwrappedLineParser.cpp.
References clang::Token::getIdentifierInfo(), clang::format::FormatToken::is(), clang::format::FormatToken::isOneOf(), clang::format::AdditionalKeywords::kw_abstract, clang::format::AdditionalKeywords::kw_as, clang::format::AdditionalKeywords::kw_async, clang::format::AdditionalKeywords::kw_await, clang::format::AdditionalKeywords::kw_extends, clang::format::AdditionalKeywords::kw_finally, clang::format::AdditionalKeywords::kw_function, clang::format::AdditionalKeywords::kw_implements, clang::format::AdditionalKeywords::kw_import, clang::format::AdditionalKeywords::kw_in, clang::format::AdditionalKeywords::kw_instanceof, clang::format::AdditionalKeywords::kw_interface, clang::format::AdditionalKeywords::kw_is, clang::format::AdditionalKeywords::kw_let, clang::format::AdditionalKeywords::kw_of, clang::format::AdditionalKeywords::kw_throws, clang::format::AdditionalKeywords::kw_var, clang::format::AdditionalKeywords::kw_yield, and clang::format::FormatToken::Tok.
Referenced by mustBeJSIdentOrValue().
|
static |
Definition at line 681 of file UnwrappedLineParser.cpp.
References clang::Token::isLiteral(), mustBeJSIdent(), and clang::format::FormatToken::Tok.
bool clang::format::operator< | ( | const JsModuleReference & | LHS, |
const JsModuleReference & | RHS | ||
) |
Definition at line 95 of file SortJavaScriptImports.cpp.
References clang::format::JsModuleReference::Category, clang::format::JsModuleReference::IsExport, clang::format::JsModuleReference::Prefix, and clang::format::JsModuleReference::URL.
std::error_code clang::format::parseConfiguration | ( | StringRef | Text, |
FormatStyle * | Style | ||
) |
Parse configuration from YAML-formatted text.
Style->Language is used to get the base style, if the BasedOnStyle
option is present.
When BasedOnStyle
is not present, options not present in the YAML document, are retained in Style
.
Definition at line 735 of file Format.cpp.
References Error, Input, clang::format::FormatStyle::Language, clang::format::FormatStyle::LK_None, make_error_code(), Success, and Unsuitable.
Referenced by getStyle().
|
static |
Definition at line 1974 of file UnwrappedLineParser.cpp.
References clang::format::UnwrappedLineNode::Children, E, I, clang::format::UnwrappedLine::InPPDirective, clang::format::UnwrappedLine::Level, Node, and clang::format::UnwrappedLine::Tokens.
|
static |
Definition at line 1397 of file Format.cpp.
References clang::tooling::applyAllReplacements(), clang::tooling::calculateChangedRanges(), and clang::tooling::mergeReplacements().
Referenced by cleanupAroundReplacements(), and formatReplacements().
tooling::Replacements clang::format::reformat | ( | const FormatStyle & | Style, |
SourceManager & | SourceMgr, | ||
FileID | ID, | ||
ArrayRef< CharSourceRange > | Ranges, | ||
bool * | IncompleteFormat = nullptr |
||
) |
Reformats the given Ranges
in the file ID
.
Each range is extended on either end to its next bigger logic unit, i.e. everything that might influence its formatting or might be influenced by its formatting.
Returns the Replacements
necessary to make all Ranges
comply with Style
.
If IncompleteFormat
is non-null, its value will be set to true if any of the affected ranges were not formatted due to a non-recoverable syntax error.
Definition at line 1614 of file Format.cpp.
References clang::format::FormatStyle::DisableFormat, and expandPresets().
Referenced by formatReplacements().
tooling::Replacements clang::format::reformat | ( | const FormatStyle & | Style, |
StringRef | Code, | ||
ArrayRef< tooling::Range > | Ranges, | ||
StringRef | FileName = "<stdin>" , |
||
bool * | IncompleteFormat = nullptr |
||
) |
Reformats the given Ranges
in Code
.
Otherwise identical to the reformat() function using a file ID.
Definition at line 1626 of file Format.cpp.
References clang::format::Environment::CreateVirtualEnvironment(), clang::format::FormatStyle::DisableFormat, and expandPresets().
|
static |
Definition at line 471 of file UnwrappedLineParser.cpp.
References clang::format::FormatStyle::BraceWrappingFlags::AfterClass, clang::format::FormatStyle::BraceWrappingFlags::AfterNamespace, clang::format::FormatStyle::BraceWrappingFlags::AfterStruct, clang::format::FormatStyle::BraceWrappingFlags::AfterUnion, clang::format::FormatStyle::BraceWrapping, clang::if(), and clang::format::FormatToken::is().
|
static |
Definition at line 1216 of file Format.cpp.
References affectsRange(), Category, End, and Filename.
Referenced by sortCppIncludes(), and sortIncludes().
tooling::Replacements clang::format::sortCppIncludes | ( | const FormatStyle & | Style, |
StringRef | Code, | ||
ArrayRef< tooling::Range > | Ranges, | ||
StringRef | FileName, | ||
tooling::Replacements & | Replaces, | ||
unsigned * | Cursor | ||
) |
Definition at line 1323 of file Format.cpp.
References Category, Line, Matches, and sortCppIncludes().
tooling::Replacements clang::format::sortIncludes | ( | const FormatStyle & | Style, |
StringRef | Code, | ||
ArrayRef< tooling::Range > | Ranges, | ||
StringRef | FileName, | ||
unsigned * | Cursor = nullptr |
||
) |
Returns the replacements necessary to sort all #include
blocks that are affected by Ranges
.
Definition at line 1383 of file Format.cpp.
References clang::format::FormatStyle::Language, sortCppIncludes(), clang::format::FormatStyle::SortIncludes, and sortJavaScriptImports().
Referenced by formatReplacements().
tooling::Replacements clang::format::sortJavaScriptImports | ( | const FormatStyle & | Style, |
StringRef | Code, | ||
ArrayRef< tooling::Range > | Ranges, | ||
StringRef | FileName | ||
) |
Definition at line 430 of file SortJavaScriptImports.cpp.
References clang::format::Environment::CreateVirtualEnvironment(), and clang::format::TokenAnalyzer::process().
Referenced by sortIncludes().
|
static |
Definition at line 54 of file ContinuationIndenter.cpp.
References clang::format::FormatStyle::BreakConstructorInitializersBeforeComma, clang::format::FormatToken::is(), clang::format::FormatToken::isNot(), clang::format::FormatToken::isTrailingComment(), clang::format::FormatToken::Previous, and Previous.
Referenced by clang::format::ContinuationIndenter::mustBreak().
|
static |
Definition at line 49 of file ContinuationIndenter.cpp.
References clang::format::FormatToken::closesScope(), clang::format::FormatToken::isMemberAccess(), and clang::format::FormatToken::Previous.
Referenced by clang::format::ContinuationIndenter::mustBreak().
|
static |
Definition at line 640 of file UnwrappedLineParser.cpp.
References clang::Token::isNot().
|
static |
Definition at line 28 of file BreakableToken.cpp.
Referenced by getCommentSplit().
const char * clang::format::StyleOptionHelpDescription |
Description to be used for help text for a llvm::cl
option for specifying format style.
The description is closely related to the operation of getStyle()
.
Definition at line 1671 of file Format.cpp.