[clang] Improved is simple type specifier (PR #78903)

via cfe-commits cfe-commits at lists.llvm.org
Sun Jan 21 08:15:24 PST 2024


github-actions[bot] wrote:

<!--LLVM CODE FORMAT COMMENT: {clang-format}-->


:warning: C/C++ code formatter, clang-format found issues in your code. :warning:

<details>
<summary>
You can test this locally with the following command:
</summary>

``````````bash
git-clang-format --diff f73bf45d68bd2c17602a909751da4a23138d711a d46a0f8fde1a7d6b57fa52b0d2b6db96d3e4e260 -- clang/include/clang/Basic/IdentifierTable.h clang/include/clang/Sema/Sema.h clang/lib/Basic/IdentifierTable.cpp clang/lib/Format/FormatToken.cpp clang/lib/Format/TokenAnnotator.cpp clang/lib/Format/UnwrappedLineParser.cpp clang/lib/Parse/ParseExpr.cpp clang/lib/Parse/ParseObjc.cpp clang/lib/Sema/SemaDecl.cpp
``````````

</details>

<details>
<summary>
View the diff from clang-format here.
</summary>

``````````diff
diff --git a/clang/lib/Format/TokenAnnotator.cpp b/clang/lib/Format/TokenAnnotator.cpp
index c365dacd49..88cea044c2 100644
--- a/clang/lib/Format/TokenAnnotator.cpp
+++ b/clang/lib/Format/TokenAnnotator.cpp
@@ -2406,7 +2406,8 @@ private:
     // Heuristically try to determine whether the parentheses contain a type.
     auto IsQualifiedPointerOrReference = [](FormatToken *T) {
       // This is used to handle cases such as x = (foo *const)&y;
-      assert(!T->isSimpleTypeSpecifier(Style) && "Should have already been checked");
+      assert(!T->isSimpleTypeSpecifier(Style) &&
+             "Should have already been checked");
       // Strip trailing qualifiers such as const or volatile when checking
       // whether the parens could be a cast to a pointer/reference type.
       while (T) {
@@ -4155,7 +4156,8 @@ bool TokenAnnotator::spaceRequiredBetween(const AnnotatedLine &Line,
   if (Right.isPointerOrReference()) {
     const FormatToken *Previous = &Left;
     while (Previous && Previous->isNot(tok::kw_operator)) {
-      if (Previous->is(tok::identifier) || Previous->isSimpleTypeSpecifier(Style)) {
+      if (Previous->is(tok::identifier) ||
+          Previous->isSimpleTypeSpecifier(Style)) {
         Previous = Previous->getPreviousNonComment();
         continue;
       }
diff --git a/clang/lib/Parse/ParseExpr.cpp b/clang/lib/Parse/ParseExpr.cpp
index 7e6f59c2f6..8f9f918bf5 100644
--- a/clang/lib/Parse/ParseExpr.cpp
+++ b/clang/lib/Parse/ParseExpr.cpp
@@ -1597,7 +1597,8 @@ ExprResult Parser::ParseCastExpression(CastParseKind ParseKind,
       if (TryAnnotateTypeOrScopeToken())
         return ExprError();
 
-      if (!Tok.getIdentifierInfo() || !Actions.isSimpleTypeSpecifier(*Tok.getIdentifierInfo()))
+      if (!Tok.getIdentifierInfo() ||
+          !Actions.isSimpleTypeSpecifier(*Tok.getIdentifierInfo()))
         // We are trying to parse a simple-type-specifier but might not get such
         // a token after error recovery.
         return ExprError();
diff --git a/clang/lib/Parse/ParseObjc.cpp b/clang/lib/Parse/ParseObjc.cpp
index 58e5bc4a42..5565770610 100644
--- a/clang/lib/Parse/ParseObjc.cpp
+++ b/clang/lib/Parse/ParseObjc.cpp
@@ -2971,7 +2971,8 @@ bool Parser::ParseObjCXXMessageReceiver(bool &IsExpr, void *&TypeOrExpr) {
                   tok::annot_cxxscope))
     TryAnnotateTypeOrScopeToken();
 
-  if (!Tok.getIdentifierInfo() || !Actions.isSimpleTypeSpecifier(*Tok.getIdentifierInfo())) {
+  if (!Tok.getIdentifierInfo() ||
+      !Actions.isSimpleTypeSpecifier(*Tok.getIdentifierInfo())) {
     //   objc-receiver:
     //     expression
     // Make sure any typos in the receiver are corrected or diagnosed, so that

``````````

</details>


https://github.com/llvm/llvm-project/pull/78903


More information about the cfe-commits mailing list