[clang] [Clang] Add __builtin_get_counted_by builtin (PR #102549)

2024-08-14 Thread via cfe-commits
@@ -222,6 +222,49 @@ bool Expr::isFlexibleArrayMemberLike( IgnoreTemplateOrMacroSubstitution); } +namespace { + +/// MemberExprVisitor - Find the MemberExpr through all of the casts, array +/// subscripts, and unary ops. This intentiona

[clang] [Clang] Add __builtin_get_counted_by builtin (PR #102549)

2024-08-14 Thread via cfe-commits
@@ -222,6 +222,49 @@ bool Expr::isFlexibleArrayMemberLike( IgnoreTemplateOrMacroSubstitution); } +namespace { + +/// MemberExprVisitor - Find the MemberExpr through all of the casts, array +/// subscripts, and unary ops. This intentiona

[clang] [Clang] Add __builtin_get_counted_by builtin (PR #102549)

2024-08-14 Thread via cfe-commits
https://github.com/Sirraide edited https://github.com/llvm/llvm-project/pull/102549 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [Clang] Add __builtin_get_counted_by builtin (PR #102549)

2024-08-14 Thread via cfe-commits
https://github.com/Sirraide edited https://github.com/llvm/llvm-project/pull/102549 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [Clang] Add __builtin_get_counted_by builtin (PR #102549)

2024-08-14 Thread via cfe-commits
@@ -222,6 +222,49 @@ bool Expr::isFlexibleArrayMemberLike( IgnoreTemplateOrMacroSubstitution); } +namespace { + +/// MemberExprVisitor - Find the MemberExpr through all of the casts, array +/// subscripts, and unary ops. This intentiona

[clang] [Clang] Add __builtin_get_counted_by builtin (PR #102549)

2024-08-14 Thread Bill Wendling via cfe-commits
https://github.com/bwendling commented: I made changes to use the CustomTypeChecking for the builtin. PTAL https://github.com/llvm/llvm-project/pull/102549 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/l

[clang] [Clang] Add __builtin_get_counted_by builtin (PR #102549)

2024-08-14 Thread Bill Wendling via cfe-commits
@@ -222,6 +222,49 @@ bool Expr::isFlexibleArrayMemberLike( IgnoreTemplateOrMacroSubstitution); } +namespace { + +/// MemberExprVisitor - Find the MemberExpr through all of the casts, array +/// subscripts, and unary ops. This intentiona

[clang] [Clang] Add __builtin_get_counted_by builtin (PR #102549)

2024-08-14 Thread Bill Wendling via cfe-commits
https://github.com/bwendling edited https://github.com/llvm/llvm-project/pull/102549 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [Clang] Add __builtin_get_counted_by builtin (PR #102549)

2024-08-14 Thread Bill Wendling via cfe-commits
@@ -6590,8 +6590,34 @@ ExprResult Sema::BuildCallExpr(Scope *Scope, Expr *Fn, SourceLocation LParenLoc, return CallExpr::Create(Context, Fn, ArgExprs, Context.DependentTy, VK_PRValue, RParenLoc, CurFPFeatureOverrides()); } - return BuildResol

[clang] [Clang] Add __builtin_get_counted_by builtin (PR #102549)

2024-08-14 Thread Bill Wendling via cfe-commits
@@ -4678,6 +4678,19 @@ void FieldDecl::printName(raw_ostream &OS, const PrintingPolicy &Policy) const { DeclaratorDecl::printName(OS, Policy); } +const FieldDecl *FieldDecl::FindCountedByField() const { + const auto *CAT = getType()->getAs(); + if (!CAT) +return nullp

[clang] [Clang] Add __builtin_get_counted_by builtin (PR #102549)

2024-08-14 Thread Bill Wendling via cfe-commits
@@ -222,6 +222,49 @@ bool Expr::isFlexibleArrayMemberLike( IgnoreTemplateOrMacroSubstitution); } +namespace { + +/// MemberExprVisitor - Find the MemberExpr through all of the casts, array +/// subscripts, and unary ops. This intentiona

[clang] [Clang] Add __builtin_get_counted_by builtin (PR #102549)

2024-08-14 Thread Bill Wendling via cfe-commits
https://github.com/bwendling updated https://github.com/llvm/llvm-project/pull/102549 >From 7ba43ae2b737fbd868848a23b58b3965f8d36ce1 Mon Sep 17 00:00:00 2001 From: Bill Wendling Date: Tue, 6 Aug 2024 17:49:01 -0700 Subject: [PATCH 01/11] [WIP][Clang] Add __builtin_get_counted_by builtin The __

[clang] [Clang] Add __builtin_get_counted_by builtin (PR #102549)

2024-08-13 Thread Bill Wendling via cfe-commits
@@ -4774,3 +4774,9 @@ def ArithmeticFence : LangBuiltin<"ALL_LANGUAGES"> { let Attributes = [CustomTypeChecking, Constexpr]; let Prototype = "void(...)"; } + +def GetCountedBy : Builtin { + let Spellings = ["__builtin_get_counted_by"]; + let Attributes = [NoThrow]; + let

[clang] [Clang] Add __builtin_get_counted_by builtin (PR #102549)

2024-08-13 Thread via cfe-commits
@@ -537,15 +537,21 @@ class Expr : public ValueStmt { /// semantically correspond to a bool. bool isKnownToHaveBooleanValue(bool Semantic = true) const; - /// Check whether this array fits the idiom of a flexible array member, - /// depending on the value of -fstrict-fle

[clang] [Clang] Add __builtin_get_counted_by builtin (PR #102549)

2024-08-13 Thread Bill Wendling via cfe-commits
https://github.com/bwendling edited https://github.com/llvm/llvm-project/pull/102549 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [Clang] Add __builtin_get_counted_by builtin (PR #102549)

2024-08-13 Thread Bill Wendling via cfe-commits
@@ -537,15 +537,21 @@ class Expr : public ValueStmt { /// semantically correspond to a bool. bool isKnownToHaveBooleanValue(bool Semantic = true) const; - /// Check whether this array fits the idiom of a flexible array member, - /// depending on the value of -fstrict-fle

[clang] [Clang] Add __builtin_get_counted_by builtin (PR #102549)

2024-08-13 Thread Bill Wendling via cfe-commits
bwendling wrote: > Hmm, I could see how this could be useful, but it seems like a rather niche > use case. > > @AaronBallman Should this go through the ususal process of someone writing an > RFC for it seeing as it is a language extension? I'll be happy to open this up to the larger community

[clang] [Clang] Add __builtin_get_counted_by builtin (PR #102549)

2024-08-13 Thread via cfe-commits
Sirraide wrote: Also, as ever, I forgot to mention this, but this also needs a release note and it should also go in the docs next to all the other builtins (`clang/docs/LanguageExtensions.rst`). https://github.com/llvm/llvm-project/pull/102549 ___ c

[clang] [Clang] Add __builtin_get_counted_by builtin (PR #102549)

2024-08-13 Thread via cfe-commits
@@ -222,6 +222,49 @@ bool Expr::isFlexibleArrayMemberLike( IgnoreTemplateOrMacroSubstitution); } +namespace { + +/// MemberExprVisitor - Find the MemberExpr through all of the casts, array +/// subscripts, and unary ops. This intentiona

[clang] [Clang] Add __builtin_get_counted_by builtin (PR #102549)

2024-08-13 Thread via cfe-commits
@@ -222,6 +222,49 @@ bool Expr::isFlexibleArrayMemberLike( IgnoreTemplateOrMacroSubstitution); } +namespace { + +/// MemberExprVisitor - Find the MemberExpr through all of the casts, array +/// subscripts, and unary ops. This intentiona

[clang] [Clang] Add __builtin_get_counted_by builtin (PR #102549)

2024-08-13 Thread via cfe-commits
@@ -6590,8 +6590,34 @@ ExprResult Sema::BuildCallExpr(Scope *Scope, Expr *Fn, SourceLocation LParenLoc, return CallExpr::Create(Context, Fn, ArgExprs, Context.DependentTy, VK_PRValue, RParenLoc, CurFPFeatureOverrides()); } - return BuildResol

[clang] [Clang] Add __builtin_get_counted_by builtin (PR #102549)

2024-08-13 Thread via cfe-commits
@@ -222,6 +222,49 @@ bool Expr::isFlexibleArrayMemberLike( IgnoreTemplateOrMacroSubstitution); } +namespace { + +/// MemberExprVisitor - Find the MemberExpr through all of the casts, array +/// subscripts, and unary ops. This intentiona

[clang] [Clang] Add __builtin_get_counted_by builtin (PR #102549)

2024-08-13 Thread via cfe-commits
@@ -6590,8 +6590,34 @@ ExprResult Sema::BuildCallExpr(Scope *Scope, Expr *Fn, SourceLocation LParenLoc, return CallExpr::Create(Context, Fn, ArgExprs, Context.DependentTy, VK_PRValue, RParenLoc, CurFPFeatureOverrides()); } - return BuildResol

[clang] [Clang] Add __builtin_get_counted_by builtin (PR #102549)

2024-08-13 Thread via cfe-commits
@@ -4678,6 +4678,19 @@ void FieldDecl::printName(raw_ostream &OS, const PrintingPolicy &Policy) const { DeclaratorDecl::printName(OS, Policy); } +const FieldDecl *FieldDecl::FindCountedByField() const { + const auto *CAT = getType()->getAs(); + if (!CAT) +return nullp

[clang] [Clang] Add __builtin_get_counted_by builtin (PR #102549)

2024-08-13 Thread via cfe-commits
@@ -6590,8 +6590,34 @@ ExprResult Sema::BuildCallExpr(Scope *Scope, Expr *Fn, SourceLocation LParenLoc, return CallExpr::Create(Context, Fn, ArgExprs, Context.DependentTy, VK_PRValue, RParenLoc, CurFPFeatureOverrides()); } - return BuildResol

[clang] [Clang] Add __builtin_get_counted_by builtin (PR #102549)

2024-08-13 Thread via cfe-commits
@@ -222,6 +222,49 @@ bool Expr::isFlexibleArrayMemberLike( IgnoreTemplateOrMacroSubstitution); } +namespace { + +/// MemberExprVisitor - Find the MemberExpr through all of the casts, array +/// subscripts, and unary ops. This intentiona

[clang] [Clang] Add __builtin_get_counted_by builtin (PR #102549)

2024-08-13 Thread via cfe-commits
@@ -222,6 +222,49 @@ bool Expr::isFlexibleArrayMemberLike( IgnoreTemplateOrMacroSubstitution); } +namespace { + +/// MemberExprVisitor - Find the MemberExpr through all of the casts, array +/// subscripts, and unary ops. This intentiona

[clang] [Clang] Add __builtin_get_counted_by builtin (PR #102549)

2024-08-13 Thread via cfe-commits
@@ -4774,3 +4774,9 @@ def ArithmeticFence : LangBuiltin<"ALL_LANGUAGES"> { let Attributes = [CustomTypeChecking, Constexpr]; let Prototype = "void(...)"; } + +def GetCountedBy : Builtin { + let Spellings = ["__builtin_get_counted_by"]; + let Attributes = [NoThrow]; + let

[clang] [Clang] Add __builtin_get_counted_by builtin (PR #102549)

2024-08-13 Thread via cfe-commits
@@ -537,15 +537,21 @@ class Expr : public ValueStmt { /// semantically correspond to a bool. bool isKnownToHaveBooleanValue(bool Semantic = true) const; - /// Check whether this array fits the idiom of a flexible array member, - /// depending on the value of -fstrict-fle

[clang] [Clang] Add __builtin_get_counted_by builtin (PR #102549)

2024-08-13 Thread via cfe-commits
@@ -6590,8 +6590,34 @@ ExprResult Sema::BuildCallExpr(Scope *Scope, Expr *Fn, SourceLocation LParenLoc, return CallExpr::Create(Context, Fn, ArgExprs, Context.DependentTy, VK_PRValue, RParenLoc, CurFPFeatureOverrides()); } - return BuildResol

[clang] [Clang] Add __builtin_get_counted_by builtin (PR #102549)

2024-08-13 Thread via cfe-commits
https://github.com/Sirraide requested changes to this pull request. Hmm, I could see how this could be useful, but it seems like a rather niche use case. @AaronBallman Should this go through the ususal process of someone writing an RFC for it seeing as it is a language extension? I also saw t

[clang] [Clang] Add __builtin_get_counted_by builtin (PR #102549)

2024-08-13 Thread via cfe-commits
https://github.com/Sirraide edited https://github.com/llvm/llvm-project/pull/102549 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [Clang] Add __builtin_get_counted_by builtin (PR #102549)

2024-08-12 Thread Bill Wendling via cfe-commits
bwendling wrote: I removed the WIP and updated the description. I'll look into adding some more diagnostics. https://github.com/llvm/llvm-project/pull/102549 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailma

[clang] [Clang] Add __builtin_get_counted_by builtin (PR #102549)

2024-08-12 Thread Bill Wendling via cfe-commits
https://github.com/bwendling edited https://github.com/llvm/llvm-project/pull/102549 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [Clang] Add __builtin_get_counted_by builtin (PR #102549)

2024-08-12 Thread Bill Wendling via cfe-commits
https://github.com/bwendling edited https://github.com/llvm/llvm-project/pull/102549 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits