[clang] [LifetimeSafety] Support C Language in LifetimeSafety (PR #203270)

Utkarsh Saxena via cfe-commits cfe-commits at lists.llvm.org
Fri Jun 12 06:55:29 PDT 2026


================
@@ -347,6 +351,13 @@ void FactsGenerator::VisitUnaryOperator(const UnaryOperator *UO) {
   switch (UO->getOpcode()) {
   case UO_AddrOf: {
     const Expr *SubExpr = UO->getSubExpr();
+    // Function addresses do not need lifetime tracking.
+    if (SubExpr->getType()->isFunctionType())
+      return;
+    // Skip address-of on void expressions: GNU C permits them, but void itself
+    // has no origins to track.
+    if (IsCMode && SubExpr->getType()->isVoidType())
----------------
usx95 wrote:

Should we do that do C++ as well ? I do not see a strong reason to support address-of void in C++.

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


More information about the cfe-commits mailing list