[clang] Issue #63106: [сlang] Representation of ellipsis in AST (PR #80976)

via cfe-commits cfe-commits at lists.llvm.org
Wed Feb 7 03:35:17 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 ec42d547eba5c0ad0bddbecc8902d35383968e78 79c592853c77fb0a96746d860be63d4605ea87e7 -- clang/include/clang/AST/DeclBase.h clang/include/clang/Sema/Sema.h clang/lib/AST/TextNodeDumper.cpp clang/lib/Parse/ParseStmt.cpp clang/lib/Sema/SemaDeclCXX.cpp clang/test/AST/ast-dump-stmt.cpp
``````````

</details>

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

``````````diff
diff --git a/clang/include/clang/AST/DeclBase.h b/clang/include/clang/AST/DeclBase.h
index 67f5c7dd1b7..06f236db328 100644
--- a/clang/include/clang/AST/DeclBase.h
+++ b/clang/include/clang/AST/DeclBase.h
@@ -397,17 +397,17 @@ protected:
   Decl(Kind DK, DeclContext *DC, SourceLocation L)
       : NextInContextAndBits(nullptr, getModuleOwnershipKindForChildOf(DC)),
         DeclCtx(DC), Loc(L), DeclKind(DK), InvalidDecl(false), HasAttrs(false),
-        Implicit(false), HasCatchEllipsis(false), Used(false), Referenced(false),
-        TopLevelDeclInObjCContainer(false), Access(AS_none), FromASTFile(0),
-        IdentifierNamespace(getIdentifierNamespaceForKind(DK)),
+        Implicit(false), HasCatchEllipsis(false), Used(false),
+        Referenced(false), TopLevelDeclInObjCContainer(false), Access(AS_none),
+        FromASTFile(0), IdentifierNamespace(getIdentifierNamespaceForKind(DK)),
         CacheValidAndLinkage(llvm::to_underlying(Linkage::Invalid)) {
     if (StatisticsEnabled) add(DK);
   }
 
   Decl(Kind DK, EmptyShell Empty)
-      : DeclKind(DK), InvalidDecl(false), HasAttrs(false), Implicit(false), HasCatchEllipsis(false),
-        Used(false), Referenced(false), TopLevelDeclInObjCContainer(false),
-        Access(AS_none), FromASTFile(0),
+      : DeclKind(DK), InvalidDecl(false), HasAttrs(false), Implicit(false),
+        HasCatchEllipsis(false), Used(false), Referenced(false),
+        TopLevelDeclInObjCContainer(false), Access(AS_none), FromASTFile(0),
         IdentifierNamespace(getIdentifierNamespaceForKind(DK)),
         CacheValidAndLinkage(llvm::to_underlying(Linkage::Invalid)) {
     if (StatisticsEnabled) add(DK);
diff --git a/clang/include/clang/Sema/Sema.h b/clang/include/clang/Sema/Sema.h
index ffc6d2926f8..0f9418e329e 100644
--- a/clang/include/clang/Sema/Sema.h
+++ b/clang/include/clang/Sema/Sema.h
@@ -5322,7 +5322,8 @@ public:
                                      SourceLocation IdLoc,
                                      IdentifierInfo *Id);
 
-  Decl *ActOnExceptionDeclarator(Scope *S, Declarator &D, bool isCatchAll = false);
+  Decl *ActOnExceptionDeclarator(Scope *S, Declarator &D,
+                                 bool isCatchAll = false);
 
   StmtResult ActOnCXXCatchBlock(SourceLocation CatchLoc,
                                 Decl *ExDecl, Stmt *HandlerBlock);
diff --git a/clang/lib/Parse/ParseStmt.cpp b/clang/lib/Parse/ParseStmt.cpp
index 56c1e86afd4..df109c7fc48 100644
--- a/clang/lib/Parse/ParseStmt.cpp
+++ b/clang/lib/Parse/ParseStmt.cpp
@@ -2698,16 +2698,17 @@ StmtResult Parser::ParseCXXCatchBlock(bool FnCatch) {
     Declarator ExDecl(DS, Attributes, DeclaratorContext::CXXCatch);
     ParseDeclarator(ExDecl);
     ExceptionDecl = Actions.ActOnExceptionDeclarator(getCurScope(), ExDecl);
-  }
-  else {
-  ConsumeToken();
-  // explicitly creating a var of type no-type for '...' and marking it as catch_all
-  ParsedAttributes Attributes(AttrFactory);
-  DeclSpec DS(AttrFactory);
-  Declarator ExDecl(DS, Attributes, DeclaratorContext::BlockLiteral);
-  ParseDeclarator(ExDecl);
-  ExceptionDecl = Actions.ActOnExceptionDeclarator(getCurScope(), ExDecl, true);
-  ExceptionDecl->setCatchEllipsisTok();
+  } else {
+    ConsumeToken();
+    // explicitly creating a var of type no-type for '...' and marking it as
+    // catch_all
+    ParsedAttributes Attributes(AttrFactory);
+    DeclSpec DS(AttrFactory);
+    Declarator ExDecl(DS, Attributes, DeclaratorContext::BlockLiteral);
+    ParseDeclarator(ExDecl);
+    ExceptionDecl =
+        Actions.ActOnExceptionDeclarator(getCurScope(), ExDecl, true);
+    ExceptionDecl->setCatchEllipsisTok();
   }
   T.consumeClose();
   if (T.getCloseLocation().isInvalid())
diff --git a/clang/lib/Sema/SemaDeclCXX.cpp b/clang/lib/Sema/SemaDeclCXX.cpp
index 1916d3c3d8e..3a69b632426 100644
--- a/clang/lib/Sema/SemaDeclCXX.cpp
+++ b/clang/lib/Sema/SemaDeclCXX.cpp
@@ -16994,7 +16994,7 @@ Decl *Sema::ActOnExceptionDeclarator(Scope *S, Declarator &D, bool isCatchAll) {
                                              D.getIdentifierLoc());
     Invalid = true;
   }
-    if (isCatchAll)
+  if (isCatchAll)
     TInfo = Context.getTrivialTypeSourceInfo(Context.UnknownAnyTy,
                                              D.getIdentifierLoc());
 

``````````

</details>


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


More information about the cfe-commits mailing list