[clang] [BoundsSafety] Support late parsing for `counted_by` in type positions (PR #166491)

via cfe-commits cfe-commits at lists.llvm.org
Mon Nov 10 10:48:04 PST 2025


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 origin/main HEAD --extensions cpp,h,c -- clang/test/Sema/attr-bounds-safety-function-ptr-param.c clang/include/clang/Parse/Parser.h clang/include/clang/Sema/DeclSpec.h clang/include/clang/Sema/Sema.h clang/lib/Parse/ParseDecl.cpp clang/lib/Sema/SemaBoundsSafety.cpp clang/lib/Sema/SemaDecl.cpp clang/lib/Sema/SemaDeclAttr.cpp clang/test/AST/attr-counted-by-or-null-struct-ptrs.c clang/test/AST/attr-counted-by-struct-ptrs.c clang/test/AST/attr-sized-by-or-null-struct-ptrs.c clang/test/AST/attr-sized-by-struct-ptrs.c clang/test/Sema/attr-counted-by-late-parsed-struct-ptrs.c clang/test/Sema/attr-counted-by-or-null-late-parsed-struct-ptrs.c clang/test/Sema/attr-counted-by-or-null-struct-ptrs-completable-incomplete-pointee.c clang/test/Sema/attr-counted-by-or-null-struct-ptrs.c clang/test/Sema/attr-counted-by-struct-ptrs-completable-incomplete-pointee.c clang/test/Sema/attr-counted-by-struct-ptrs.c clang/test/Sema/attr-sized-by-late-parsed-struct-ptrs.c clang/test/Sema/attr-sized-by-or-null-late-parsed-struct-ptrs.c clang/test/Sema/attr-sized-by-or-null-struct-ptrs.c clang/test/Sema/attr-sized-by-struct-ptrs.c --diff_from_common_commit
``````````

:warning:
The reproduction instructions above might return results for more than one PR
in a stack if you are using a stacked PR workflow. You can limit the results by
changing `origin/main` to the base branch/commit you want to compare against.
:warning:

</details>

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

``````````diff
diff --git a/clang/include/clang/Parse/Parser.h b/clang/include/clang/Parse/Parser.h
index f2f969e7b..b05badc24 100644
--- a/clang/include/clang/Parse/Parser.h
+++ b/clang/include/clang/Parse/Parser.h
@@ -1164,8 +1164,10 @@ private:
     unsigned NestedTypeLevel;
 
     explicit LateParsedAttribute(Parser *P, IdentifierInfo &Name,
-                                 SourceLocation Loc, unsigned NestedTypeLevel = 0)
-        : Self(P), AttrName(Name), AttrNameLoc(Loc), NestedTypeLevel(NestedTypeLevel) {}
+                                 SourceLocation Loc,
+                                 unsigned NestedTypeLevel = 0)
+        : Self(P), AttrName(Name), AttrNameLoc(Loc),
+          NestedTypeLevel(NestedTypeLevel) {}
 
     void ParseLexedAttributes() override;
 
diff --git a/clang/include/clang/Sema/DeclSpec.h b/clang/include/clang/Sema/DeclSpec.h
index fd5ca9b0d..75a9e937a 100644
--- a/clang/include/clang/Sema/DeclSpec.h
+++ b/clang/include/clang/Sema/DeclSpec.h
@@ -2331,9 +2331,10 @@ public:
   /// EndLoc, which should be the last token of the chunk.
   /// This function takes attrs by R-Value reference because it takes ownership
   /// of those attributes from the parameter.
-  void AddTypeInfo(const DeclaratorChunk &TI, ParsedAttributes &&attrs,
-                   SourceLocation EndLoc,
-                   ArrayRef<DeclaratorChunk::LateAttrOpaquePtr> LateAttrs = {}) {
+  void
+  AddTypeInfo(const DeclaratorChunk &TI, ParsedAttributes &&attrs,
+              SourceLocation EndLoc,
+              ArrayRef<DeclaratorChunk::LateAttrOpaquePtr> LateAttrs = {}) {
     DeclTypeInfo.push_back(TI);
     DeclTypeInfo.back().getAttrs().prepend(attrs.begin(), attrs.end());
     getAttributePool().takeAllFrom(attrs.getPool());

``````````

</details>


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


More information about the cfe-commits mailing list