[PATCH] D148381: [WIP][Clang] Add counted_by attribute

Nick Desaulniers via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Aug 29 09:07:54 PDT 2023


nickdesaulniers added a comment.

I assume you plan to add some clang CodeGen tests at some point?



================
Comment at: clang/lib/CodeGen/CGBuiltin.cpp:875-876
+        if (auto *RD = DRE->getType()->getPointeeType()->getAsRecordDecl())
+          for (FieldDecl *Field : RD->fields())
+            VD = Field;
+
----------------
You should use your newly added `RecordDecl::getLastField()` here.


================
Comment at: clang/lib/CodeGen/CodeGenFunction.h:531-532
 
-  /// True if CodeGen currently emits code implementing sanitizer checks.
-  bool IsSanitizerScope = false;
+  /// Non-zero if CodeGen currently emits code implementing sanitizer checks.
+  unsigned IsSanitizerScope = 0;
 
----------------
I don't understand this change. Grepping for `IsSanitizerScope` doesn't show any changed references to how this variable is used. Intentional?


================
Comment at: clang/lib/Sema/SemaDecl.cpp:17911
+        return FD;
+    }
+
----------------
unnecessary curly braces?


================
Comment at: clang/lib/Sema/SemaDecl.cpp:17915
+      return FindFieldWithCountedByAttr(SubRD);
+    }
+  }
----------------
unnecessary curly braces?


================
Comment at: clang/lib/Sema/SemaDecl.cpp:17927
+                                                SourceRange &Loc) {
+  const CountedByAttr *ECA = FD->getAttr<CountedByAttr>();
+
----------------
const auto *....


================
Comment at: clang/lib/Sema/SemaDecl.cpp:18000
+  // the struct.
+  if (const RecordDecl *RD = dyn_cast<RecordDecl>(Tag)) {
+    if (const FieldDecl *FD = FindFieldWithCountedByAttr(RD)) {
----------------
const auto *


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D148381/new/

https://reviews.llvm.org/D148381



More information about the cfe-commits mailing list