[clang] [LifetimeSafety] Add missing origins stats for lifetime analysis (PR #166568)
via cfe-commits
cfe-commits at lists.llvm.org
Wed Nov 26 22:45:31 PST 2025
================
@@ -7,9 +7,33 @@
//===----------------------------------------------------------------------===//
#include "clang/Analysis/Analyses/LifetimeSafety/Origins.h"
+#include "clang/AST/Expr.h"
+#include "clang/AST/TypeBase.h"
+#include "clang/Analysis/Analyses/LifetimeSafety/LifetimeSafety.h"
+#include "llvm/ADT/StringMap.h"
namespace clang::lifetimes::internal {
+static bool isGslPointerType(QualType QT) {
+ if (const auto *RD = QT->getAsCXXRecordDecl()) {
+ // We need to check the template definition for specializations.
+ if (auto *CTSD = dyn_cast<ClassTemplateSpecializationDecl>(RD))
+ return CTSD->getSpecializedTemplate()
+ ->getTemplatedDecl()
+ ->hasAttr<PointerAttr>();
+ return RD->hasAttr<PointerAttr>();
+ }
+ return false;
+}
----------------
DEBADRIBASAK wrote:
As only the `isGslPointerType` function is part of the new change, I am making these non-static and moviung to anonymous namespace.
https://github.com/llvm/llvm-project/pull/166568
More information about the cfe-commits
mailing list