Skip to content

Commit

Permalink
[format] [docs] Fix typos and clarify QualifierAlignment/QualifierOrd…
Browse files Browse the repository at this point in the history
…er documentation.
  • Loading branch information
mkurdej committed Sep 30, 2021
1 parent 8c1b785 commit 2c60cfc
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 26 deletions.
22 changes: 11 additions & 11 deletions clang/docs/ClangFormatStyleOptions.rst
Expand Up @@ -3234,7 +3234,7 @@ the configuration (without a prefix: ``Auto``).


**QualifierAlignment** (``QualifierAlignmentStyle``) :versionbadge:`clang-format 14`
Different ways to arrange const/volatile qualifiers.
Different ways to arrange specifiers and qualifiers (e.g. const/volatile).

.. warning::

Expand All @@ -3243,37 +3243,37 @@ the configuration (without a prefix: ``Auto``).
Possible values:

* ``QAS_Leave`` (in configuration: ``Leave``)
Don't change specifiers/qualifier to either Left or Right alignment
(default)
Don't change specifiers/qualifiers to either Left or Right alignment
(default).

.. code-block:: c++

int const a;
const int *a;
* ``QAS_Left`` (in configuration: ``Left``)
Change specifiers/qualifiers to be Left aligned.
Change specifiers/qualifiers to be left-aligned.

.. code-block:: c++

const int a;
const int *a;
* ``QAS_Right`` (in configuration: ``Right``)
Change specifiers/qualifiers to be Right aligned.
Change specifiers/qualifiers to be right-aligned.

.. code-block:: c++

int const a;
int const *a;
* ``QAS_Custom`` (in configuration: ``Custom``)
Change specifiers/qualifiers to be aligned based on QualfierOrder.
Change specifiers/qualifiers to be aligned based on ``QualifierOrder``.
With:

.. code-block:: yaml
QualifierOrder: ['inline', 'static' , '<type>', 'const']
QualifierOrder: ['inline', 'static' , 'type', 'const']
.. code-block:: c++
Expand All @@ -3285,8 +3285,8 @@ the configuration (without a prefix: ``Auto``).


**QualifierOrder** (``List of Strings``) :versionbadge:`clang-format 14`
The Order in which the qualifiers appear.
Order is a an array can contain any of the following
The order in which the qualifiers appear.
Order is an array that can contain any of the following:

* const
* inline
Expand All @@ -3297,8 +3297,8 @@ the configuration (without a prefix: ``Auto``).
* type

Note: it MUST contain 'type'.
Items to the left of type will be aligned in the order supplied.
Items to the right of type will be aligned in the order supplied.
Items to the left of 'type' will be placed to the left of the type and aligned in the order supplied.
Items to the right of 'type' will be placed to the right of the type and aligned in the order supplied.


.. code-block:: yaml
Expand Down
24 changes: 12 additions & 12 deletions clang/include/clang/Format/Format.h
Expand Up @@ -1861,31 +1861,31 @@ struct FormatStyle {
/// \version 3.7
std::string CommentPragmas;

/// Different const/volatile qualifier alignment styles.
/// Different specifiers and qualifiers alignment styles.
enum QualifierAlignmentStyle {
/// Don't change specifiers/qualifier to either Left or Right alignment
/// (default)
/// Don't change specifiers/qualifiers to either Left or Right alignment
/// (default).
/// \code
/// int const a;
/// const int *a;
/// \endcode
QAS_Leave,
/// Change specifiers/qualifiers to be Left aligned.
/// Change specifiers/qualifiers to be left-aligned.
/// \code
/// const int a;
/// const int *a;
/// \endcode
QAS_Left,
/// Change specifiers/qualifiers to be Right aligned.
/// Change specifiers/qualifiers to be right-aligned.
/// \code
/// int const a;
/// int const *a;
/// \endcode
QAS_Right,
/// Change specifiers/qualifiers to be aligned based on QualfierOrder.
/// Change specifiers/qualifiers to be aligned based on ``QualifierOrder``.
/// With:
/// \code{.yaml}
/// QualifierOrder: ['inline', 'static' , '<type>', 'const']
/// QualifierOrder: ['inline', 'static' , 'type', 'const']
/// \endcode
///
/// \code
Expand All @@ -1896,15 +1896,15 @@ struct FormatStyle {
QAS_Custom
};

/// Different ways to arrange const/volatile qualifiers.
/// Different ways to arrange specifiers and qualifiers (e.g. const/volatile).
/// \warning
/// ``QualifierAlignment`` COULD lead to incorrect code generation.
/// \endwarning
/// \version 14
QualifierAlignmentStyle QualifierAlignment;

/// The Order in which the qualifiers appear.
/// Order is a an array can contain any of the following
/// The order in which the qualifiers appear.
/// Order is an array that can contain any of the following:
///
/// * const
/// * inline
Expand All @@ -1915,8 +1915,8 @@ struct FormatStyle {
/// * type
///
/// Note: it MUST contain 'type'.
/// Items to the left of type will be aligned in the order supplied.
/// Items to the right of type will be aligned in the order supplied.
/// Items to the left of 'type' will be placed to the left of the type and aligned in the order supplied.
/// Items to the right of 'type' will be placed to the right of the type and aligned in the order supplied.
///
/// \code{.yaml}
/// QualifierOrder: ['inline', 'static', 'type', 'const', 'volatile' ]
Expand Down
2 changes: 1 addition & 1 deletion clang/lib/Format/QualifierAlignmentFixer.cpp
Expand Up @@ -361,7 +361,7 @@ FormatToken *LeftRightQualifierAlignmentFixer::analyzeLeft(

tok::TokenKind LeftRightQualifierAlignmentFixer::getTokenFromQualifier(
const std::string &Qualifier) {
// don't let 'type' be an indentifier steal typeof token
// Don't let 'type' be an identifier, but steal typeof token.
return llvm::StringSwitch<tok::TokenKind>(Qualifier)
.Case("type", tok::kw_typeof)
.Case("const", tok::kw_const)
Expand Down
4 changes: 2 additions & 2 deletions clang/lib/Format/TokenAnnotator.cpp
Expand Up @@ -2467,7 +2467,7 @@ static bool isFunctionDeclarationName(bool IsCpp, const FormatToken &Current,
// Check whether parameter list can belong to a function declaration.
if (!Next || !Next->is(tok::l_paren) || !Next->MatchingParen)
return false;
// If the lines ends with "{", this is likely an function definition.
// If the lines ends with "{", this is likely a function definition.
if (Line.Last->is(tok::l_brace))
return true;
if (Next->Next == Next->MatchingParen)
Expand Down Expand Up @@ -3587,7 +3587,7 @@ static bool isAllmanBrace(const FormatToken &Tok) {
!Tok.isOneOf(TT_ObjCBlockLBrace, TT_LambdaLBrace, TT_DictLiteral);
}

// Returns 'true' if 'Tok' is an function argument.
// Returns 'true' if 'Tok' is a function argument.
static bool IsFunctionArgument(const FormatToken &Tok) {
return Tok.MatchingParen && Tok.MatchingParen->Next &&
Tok.MatchingParen->Next->isOneOf(tok::comma, tok::r_paren);
Expand Down

0 comments on commit 2c60cfc

Please sign in to comment.