[clang] [BoundsSafety][Sema] Allow counted_by and counted_by_or_null on pointers where the pointee type is incomplete but potentially completable (PR #106321)
Dan Liew via cfe-commits
cfe-commits at lists.llvm.org
Tue Jan 7 10:34:23 PST 2025
================
@@ -186,4 +218,206 @@ bool Sema::CheckCountedByAttrOnField(FieldDecl *FD, Expr *E, bool CountInBytes,
return false;
}
+static void EmitIncompleteCountedByPointeeNotes(Sema &S,
+ const CountAttributedType *CATy,
+ NamedDecl *IncompleteTyDecl,
+ bool NoteAttrLocation = true) {
+ assert(IncompleteTyDecl == nullptr || isa<TypeDecl>(IncompleteTyDecl));
+
+ if (NoteAttrLocation) {
+ // Note where the attribute is declared
+ // This is an approximation that's not quite right. This points to the
+ // the expression inside the attribute rather than the attribute itself.
+ //
+ // TODO: Implement logic to find the relevant TypeLoc for the attribute and
+ // get the SourceRange from that (#113582).
+ auto AttrSrcRange = CATy->getCountExpr()->getSourceRange();
----------------
delcypher wrote:
I'm happy to make this change but why is `auto` discouraged here?
https://github.com/llvm/llvm-project/pull/106321
More information about the cfe-commits
mailing list