[clang] [LifetimeSafety] Add missing origins stats for lifetime analysis (PR #166568)

Utkarsh Saxena via cfe-commits cfe-commits at lists.llvm.org
Thu Nov 27 05:57:55 PST 2025


================
@@ -7,8 +7,51 @@
 //===----------------------------------------------------------------------===//
 
 #include "clang/Analysis/Analyses/LifetimeSafety/Origins.h"
+#include "clang/AST/Expr.h"
+#include "clang/AST/RecursiveASTVisitor.h"
+#include "clang/AST/TypeBase.h"
+#include "clang/Analysis/Analyses/LifetimeSafety/LifetimeAnnotations.h"
+#include "clang/Analysis/Analyses/LifetimeSafety/LifetimeStats.h"
+#include "llvm/ADT/StringMap.h"
 
 namespace clang::lifetimes::internal {
+namespace {
+bool isPointerType(QualType QT) {
+  return QT->isPointerOrReferenceType() || isGslPointerType(QT);
+}
+// Check if a type has an origin.
+bool hasOrigin(const Expr *E) {
+  return E->isGLValue() || isPointerType(E->getType());
+}
+/// An utility class to traverse the function body in the analysis
----------------
usx95 wrote:

nit: A utility

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


More information about the cfe-commits mailing list