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

via cfe-commits cfe-commits at lists.llvm.org
Tue Aug 13 02:07:18 PDT 2024


================
@@ -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<CountAttributedType>();
+  if (!CAT)
+    return nullptr;
+
+  const auto *CountDRE = cast<DeclRefExpr>(CAT->getCountExpr());
----------------
Sirraide wrote:

This is only tangentially related to this patch and should probably be a separate investigation, but is there a reason why we’re not storing a DRE in the `CountAttributedType` instead of just an `Expr` (because we check that it is a DRE when we create the type)? 

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


More information about the cfe-commits mailing list