================ @@ -0,0 +1,116 @@ +//===- 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/TUSummary/EntitySummary.h" +#include "clang/Analysis/Scalable/TUSummary/TUSummaryBuilder.h" +#include "clang/Analysis/Scalable/TUSummary/TUSummaryExtractor.h" +#include "llvm/ADT/SmallVector.h" +#include <limits> +#include <memory> +#include <set> + +namespace clang::ssaf { + +/// A PointerKindVariable is associated with a pointer type as (a spelling part +/// of) the declared type of an entity. In other words, a PointerKindVariable +/// is associated with a `*` in the fully expanded spelling of the declared +/// type. +/// +/// For example, for `int **p;`, there are two PointerKindVariables. One is +/// associated with `int **` and the other is associated with `int *`. +/// +/// A PointerKindVariable can be identified by an EntityId, of which the +/// declared type is a pointer type, and an unsigned integer indicating the +/// pointer level with 1 referring to the whole declared pointer type. +/// +/// For the same example `int **p;`, the two PointerKindVariables are: +/// `(p, 1)` for `int **` and `(p, 2)` for `int *`. +/// +/// Reserve pointer level value 0 for implementation-internal use. +class PointerKindVariable { + const EntityId Entity; + const unsigned PointerLevel; ---------------- steakhal wrote:
While it's tempting to add `const` to fields, it's also poisonous and disables assignments, and usually types like that feels alien in C++. For example, one could no longer decompose a `std::pair` of these using `std::tie()` because of this. (This concrete use-case is not exercised, but serves as an example for why it's not great to have const fields) https://github.com/llvm/llvm-project/pull/181067 _______________________________________________ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
