[clang] [lldb] [Clang] Improve Sema diagnostic performance for __builtin_counted_by_ref (PR #116719)
Bill Wendling via cfe-commits
cfe-commits at lists.llvm.org
Tue Nov 26 16:10:33 PST 2024
================
@@ -14690,6 +14690,13 @@ void Sema::FinalizeDeclaration(Decl *ThisDecl) {
}
}
+ // The result of __builtin_counted_by_ref cannot be assigned to a variable.
+ // It allows leaking and modification of bounds safety information.
+ if (IsBuiltinCountedByRef(VD->getInit()))
+ Diag(VD->getInit()->getExprLoc(),
+ diag::err_builtin_counted_by_ref_cannot_leak_reference)
+ << VD->getInit()->getSourceRange();
----------------
bwendling wrote:
I'm not sure I agree. The diagnostic isn't the same in all places. And one of them takes arguments not available from the `Expr`. I would say that if we were adding several more diagnostics then a separate function would make sense. But for four, it's probably a bit more trouble than it's worth.
https://github.com/llvm/llvm-project/pull/116719
More information about the cfe-commits
mailing list