diff --git a/clang/docs/ClangFormatStyleOptions.rst b/clang/docs/ClangFormatStyleOptions.rst index 0bdb73a74e3b37..7e4d1582d866f7 100644 --- a/clang/docs/ClangFormatStyleOptions.rst +++ b/clang/docs/ClangFormatStyleOptions.rst @@ -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:: @@ -3243,8 +3243,8 @@ 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++ @@ -3252,7 +3252,7 @@ the configuration (without a prefix: ``Auto``). 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++ @@ -3260,7 +3260,7 @@ the configuration (without a prefix: ``Auto``). 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++ @@ -3268,12 +3268,12 @@ the configuration (without a prefix: ``Auto``). 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' , '', 'const'] + QualifierOrder: ['inline', 'static' , 'type', 'const'] .. code-block:: c++ @@ -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 @@ -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 diff --git a/clang/include/clang/Format/Format.h b/clang/include/clang/Format/Format.h index f5e7b5f5c149b8..a6fd44693a0336 100644 --- a/clang/include/clang/Format/Format.h +++ b/clang/include/clang/Format/Format.h @@ -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' , '', 'const'] + /// QualifierOrder: ['inline', 'static' , 'type', 'const'] /// \endcode /// /// \code @@ -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 @@ -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' ] diff --git a/clang/lib/Format/QualifierAlignmentFixer.cpp b/clang/lib/Format/QualifierAlignmentFixer.cpp index 30b199952edbd5..b1a0fd84fa698e 100644 --- a/clang/lib/Format/QualifierAlignmentFixer.cpp +++ b/clang/lib/Format/QualifierAlignmentFixer.cpp @@ -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(Qualifier) .Case("type", tok::kw_typeof) .Case("const", tok::kw_const) diff --git a/clang/lib/Format/TokenAnnotator.cpp b/clang/lib/Format/TokenAnnotator.cpp index bc84666ddfc747..29580ebe5ebfc9 100644 --- a/clang/lib/Format/TokenAnnotator.cpp +++ b/clang/lib/Format/TokenAnnotator.cpp @@ -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) @@ -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);