-
Notifications
You must be signed in to change notification settings - Fork 10.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[clang-format] Support of TableGen formatting. #76059
Closed
Closed
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -396,6 +396,39 @@ struct FormatStyle { | |
/// \version 17 | ||
ShortCaseStatementsAlignmentStyle AlignConsecutiveShortCaseStatements; | ||
|
||
/// Style of aligning consecutive TableGen DAGArg operator colons. | ||
/// This works only when TableGenBreakInsideDAGArgList is true and the DAGArg | ||
/// is not excepted by TableGenBreakingDAGArgOperators's effect. Align the | ||
/// colon inside DAGArg which have line break inside. \code{tablegen} | ||
/// let dagarg = (ins | ||
/// a :$src1, | ||
/// aa :$src2, | ||
/// aaa:$src3 | ||
/// ) | ||
/// \endcode | ||
/// \version 18 | ||
AlignConsecutiveStyle AlignConsecutiveTableGenBreakingDAGArgColons; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please sort alphabetically. |
||
|
||
/// Style of aligning consecutive TableGen cond operator colons. | ||
/// Align the colons of each case inside !cond operators. | ||
/// \code | ||
/// !cond(!eq(size, 1) : 1, | ||
/// !eq(size, 16): 1, | ||
/// true : 0) | ||
/// \endcode | ||
/// \version 18 | ||
AlignConsecutiveStyle AlignConsecutiveTableGenCondOperatorColons; | ||
|
||
/// Style of aligning consecutive TableGen def colons. | ||
/// This aligns the inherits colons of consecutive definitions. | ||
/// \code | ||
/// def Def : Parent {} | ||
/// def DefDef : Parent {} | ||
/// def DefDefDef : Parent {} | ||
/// \endcode | ||
/// \version 18 | ||
AlignConsecutiveStyle AlignConsecutiveTableGenDefinitionColons; | ||
|
||
/// Different styles for aligning escaped newlines. | ||
enum EscapedNewlineAlignmentStyle : int8_t { | ||
/// Don't align escaped newlines. | ||
|
@@ -3037,6 +3070,7 @@ struct FormatStyle { | |
bool isProto() const { | ||
return Language == LK_Proto || Language == LK_TextProto; | ||
} | ||
bool isTableGen() const { return Language == LK_TableGen; } | ||
|
||
/// Language, this format style is targeted at. | ||
/// \version 3.5 | ||
|
@@ -4656,6 +4690,69 @@ struct FormatStyle { | |
/// \version 8 | ||
std::vector<std::string> StatementMacros; | ||
|
||
/// Works only when TableGenBreakInsideDAGArgList is true. | ||
/// The list needs to be consists of identifiers in TableGen. | ||
/// If any identifier is specified, this limits the effect of | ||
/// TableGenBreakInsideDAGArgList only on DAGArgs beginning with the specified | ||
/// identifiers. For example the configuration, | ||
/// | ||
/// \code | ||
/// TableGenBreakingDAGArgOperators: ['ins', 'outs'] | ||
/// \endcode | ||
/// | ||
/// makes the line break only occurs inside DAGArgs beginning with the | ||
/// specified identifiers 'ins' and 'outs'. | ||
/// | ||
/// \code | ||
/// let DAGArgIns = (ins | ||
/// i32:$src1, | ||
/// i32:$src2 | ||
/// ); | ||
/// let DAGArgOthers = (others i32:$other1, i32:$other2); | ||
/// let DAGArgBang = (!cast<SomeType>("Some") i32:$src1, i32:$src2) | ||
/// \endcode | ||
/// \version 18 | ||
std::vector<std::string> TableGenBreakingDAGArgOperators; | ||
|
||
/// Insert the line break after each case of !cond operator in TableGen. | ||
/// \code | ||
/// let CondOpe1 = !cond(!eq(size, 1): 1, | ||
/// !eq(size, 16): 1, | ||
/// true: 0); | ||
/// \endcode | ||
/// By default this is true. | ||
/// \version 18 | ||
bool TableGenBreakInsideCondOperator; | ||
|
||
/// Insert the line break after each element of DAGArg list in TableGen. | ||
/// \code | ||
/// let DAGArgIns = (ins | ||
/// i32:$src1, | ||
/// i32:$src2 | ||
/// ); | ||
/// \endcode | ||
/// \version 18 | ||
bool TableGenBreakInsideDAGArgList; | ||
|
||
/// Tend to break inside square bracket in TableGen. | ||
/// For whom likes such a style. | ||
/// \code | ||
/// def Def : Parent<"Def",[ | ||
/// a, b, c | ||
/// ]> { | ||
/// ... | ||
/// } | ||
/// \endcode | ||
/// \version 18 | ||
bool TableGenPreferBreakInsideSquareBracket; | ||
|
||
/// Insert the space around the colon inside a DAGArg list in TableGen. | ||
/// \code | ||
/// let DAGArgIns = (ins i32 : $src1, i32 : $src2); | ||
/// \endcode | ||
/// \version 18 | ||
bool TableGenSpaceAroundDAGArgColon; | ||
|
||
/// The number of columns used for tab stops. | ||
/// \version 3.7 | ||
unsigned TabWidth; | ||
|
@@ -4753,6 +4850,12 @@ struct FormatStyle { | |
AlignConsecutiveMacros == R.AlignConsecutiveMacros && | ||
AlignConsecutiveShortCaseStatements == | ||
R.AlignConsecutiveShortCaseStatements && | ||
AlignConsecutiveTableGenBreakingDAGArgColons == | ||
R.AlignConsecutiveTableGenBreakingDAGArgColons && | ||
AlignConsecutiveTableGenCondOperatorColons == | ||
R.AlignConsecutiveTableGenCondOperatorColons && | ||
AlignConsecutiveTableGenDefinitionColons == | ||
R.AlignConsecutiveTableGenDefinitionColons && | ||
AlignEscapedNewlines == R.AlignEscapedNewlines && | ||
AlignOperands == R.AlignOperands && | ||
AlignTrailingComments == R.AlignTrailingComments && | ||
|
@@ -4902,9 +5005,17 @@ struct FormatStyle { | |
SpacesInSquareBrackets == R.SpacesInSquareBrackets && | ||
Standard == R.Standard && | ||
StatementAttributeLikeMacros == R.StatementAttributeLikeMacros && | ||
StatementMacros == R.StatementMacros && TabWidth == R.TabWidth && | ||
TypeNames == R.TypeNames && TypenameMacros == R.TypenameMacros && | ||
UseTab == R.UseTab && | ||
StatementMacros == R.StatementMacros && | ||
TableGenBreakingDAGArgOperators == | ||
R.TableGenBreakingDAGArgOperators && | ||
TableGenBreakInsideCondOperator == | ||
R.TableGenBreakInsideCondOperator && | ||
TableGenBreakInsideDAGArgList == R.TableGenBreakInsideDAGArgList && | ||
TableGenPreferBreakInsideSquareBracket == | ||
R.TableGenPreferBreakInsideSquareBracket && | ||
TableGenSpaceAroundDAGArgColon == R.TableGenSpaceAroundDAGArgColon && | ||
TabWidth == R.TabWidth && TypeNames == R.TypeNames && | ||
TypenameMacros == R.TypenameMacros && UseTab == R.UseTab && | ||
VerilogBreakBetweenInstancePorts == | ||
R.VerilogBreakBetweenInstancePorts && | ||
WhitespaceSensitiveMacros == R.WhitespaceSensitiveMacros; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Your edits in Format.h won't show up in the documentation until after you've run the script in
clang/docs/tools/dump_format_style.py
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for the information. I added the document.