[clang] [Clang] Implement the 'counted_by' attribute (PR #68750)

via cfe-commits cfe-commits at lists.llvm.org
Tue Oct 10 15:37:05 PDT 2023


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 3a6cc52fe3501b2b7b3aabdff305a18122c9e0db b7b0c40542589e9c54c21140dbb5b163dd8ffc7b -- clang/test/CodeGen/attr-counted-by.c clang/test/Sema/attr-counted-by.c clang/include/clang/AST/Decl.h clang/include/clang/AST/DeclBase.h clang/include/clang/Sema/Sema.h clang/lib/AST/ASTImporter.cpp clang/lib/AST/DeclBase.cpp clang/lib/AST/Expr.cpp clang/lib/CodeGen/CGBuiltin.cpp clang/lib/CodeGen/CGExpr.cpp clang/lib/CodeGen/CodeGenFunction.h clang/lib/Sema/SemaDecl.cpp clang/lib/Sema/SemaDeclAttr.cpp clang/test/CodeGen/bounds-checking.c
``````````

</details>

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

``````````diff
diff --git a/clang/lib/Sema/SemaDeclAttr.cpp b/clang/lib/Sema/SemaDeclAttr.cpp
index 47e072ace072..934f7271b03e 100644
--- a/clang/lib/Sema/SemaDeclAttr.cpp
+++ b/clang/lib/Sema/SemaDeclAttr.cpp
@@ -8457,8 +8457,7 @@ bool Sema::CheckCountedByAttr(Scope *S, const FieldDecl *FD) {
                                        StrictFlexArraysLevel, true)) {
     // The "counted_by" attribute must be on a flexible array member.
     SourceRange SR = FD->getLocation();
-    Diag(SR.getBegin(),
-         diag::err_counted_by_attr_not_on_flexible_array_member)
+    Diag(SR.getBegin(), diag::err_counted_by_attr_not_on_flexible_array_member)
         << SR;
     return true;
   }
@@ -8466,14 +8465,12 @@ bool Sema::CheckCountedByAttr(Scope *S, const FieldDecl *FD) {
   if (Field->hasAttr<CountedByAttr>()) {
     // The "counted_by" field can't point to the flexible array member.
     SourceRange SR = CBA->getCountedByFieldLoc();
-    Diag(SR.getBegin(),
-         diag::err_flexible_array_counted_by_attr_refers_to_self)
+    Diag(SR.getBegin(), diag::err_flexible_array_counted_by_attr_refers_to_self)
         << CBA->getCountedByField() << SR;
     return true;
   }
 
-  if (!Field->getType()->isIntegerType() ||
-      Field->getType()->isBooleanType()) {
+  if (!Field->getType()->isIntegerType() || Field->getType()->isBooleanType()) {
     // The "counted_by" field must have an integer type.
     SourceRange SR = Field->getLocation();
     Diag(SR.getBegin(),

``````````

</details>


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


More information about the cfe-commits mailing list