[clang] [clang][ssaf] Add UnsafeBufferUsage summary data structures (PR #181067)
Jan Korous via cfe-commits
cfe-commits at lists.llvm.org
Tue Feb 17 17:10:01 PST 2026
================
@@ -0,0 +1,120 @@
+//===- UnsafeBufferUsage.h --------------------------------------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_CLANG_ANALYSIS_SCALABLE_ANALYSES_UNSAFEBUFFERUSAGE_H
+#define LLVM_CLANG_ANALYSIS_SCALABLE_ANALYSES_UNSAFEBUFFERUSAGE_H
+
+#include "clang/Analysis/Scalable/Model/EntityId.h"
+#include "clang/Analysis/Scalable/Model/SummaryName.h"
+#include "clang/Analysis/Scalable/TUSummary/EntitySummary.h"
+#include "llvm/ADT/iterator_range.h"
+#include <set>
+
+namespace clang::ssaf {
+
+/// An EntityPointerLevel represents a level of the declared pointer
+/// type of an entity. In the fully-expanded spelling of the declared type, a
+/// EntityPointerLevel is associated with a '*' in that declaration.
+///
+/// For example, for 'int **p;', there are two EntityPointerLevels. One
+/// is associated with 'int **' of 'p' and the other is associated with 'int *'
+/// of 'p'.
+///
+/// An EntityPointerLevel can be identified by an EntityId and an unsigned
+/// integer indicating the pointer level: '(EntityId, PointerLevel)'. A
+/// EntityPointerLevel 'P' is valid iff
+/// - 'P.EntityId' has a pointer type with at least 'P.PointerLevel' levels
+/// (This implies 'P.PointerLevel > 0');
+/// - 'P.EntityId' identifies an lvalue object and 'P.PointerLevel == 0'.
+/// The latter case represents address-of expressions.
----------------
jkorous-apple wrote:
I think reserving zero is a clever idea.
I don't expect to see expressions referred in the summaries and I wonder what is it motivated by.
https://github.com/llvm/llvm-project/pull/181067
More information about the cfe-commits
mailing list