clang 23.0.0git
TypeConstrainedPointers.h
Go to the documentation of this file.
1//===- TypeConstrainedPointers.h --------------------------------*- C++ -*-===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8//
9// Declares data structures for the Type Constrained Pointers analysis, which
10// identifies pointer entities that must retain their pointer type throughout
11// the program.
12//
13//===----------------------------------------------------------------------===//
14
15#ifndef LLVM_CLANG_SCALABLESTATICANALYSIS_ANALYSES_TYPECONSTRAINEDPOINTERS_TYPECONSTRAINEDPOINTERS_H
16#define LLVM_CLANG_SCALABLESTATICANALYSIS_ANALYSES_TYPECONSTRAINEDPOINTERS_TYPECONSTRAINEDPOINTERS_H
17
23#include "llvm/ADT/StringRef.h"
24#include <set>
25
26namespace clang::ssaf {
27
28/// Per-contributor set of pointer entities that must retain their pointer type.
29///
30/// From `operator new` / `operator delete` overloads:
31/// -# The return entity of `operator new` overloads.
32/// -# The second parameter of `operator new(size_t, void*)` representing the
33/// pointer to the memory area at which to initialize the object.
34/// -# The first parameter of `operator delete` overloads representing the
35/// pointer to the memory block to deallocate (or a null pointer).
36/// -# The second parameter of `operator delete(void*, void*)` representing
37/// the placement pointer matching the corresponding placement `new`.
38///
39/// From the `main` function:
40/// -# Pointer-typed parameters of `main`.
42 static constexpr llvm::StringLiteral Name = "TypeConstrainedPointers";
43
44 static SummaryName summaryName() { return SummaryName(Name.str()); }
45
46 SummaryName getSummaryName() const override { return summaryName(); }
47
50 return This.Entities == Other.Entities;
51 }
52
53 bool operator==(const std::set<EntityId> &OtherEntities) const {
54 return Entities == OtherEntities;
55 }
56
57 bool empty() const { return Entities.empty(); }
58
59 std::set<EntityId> Entities;
60};
61
62/// Whole-program set of pointer entities that must retain their pointer type.
64 static constexpr llvm::StringLiteral Name =
65 "TypeConstrainedPointersAnalysisResult";
66
67 static AnalysisName analysisName() { return AnalysisName(Name.str()); }
68
69 std::set<EntityId> Entities;
70
71 bool contains(const EntityId &Id) const {
72 return Entities.find(Id) != Entities.end();
73 }
74};
75
76} // namespace clang::ssaf
77
78#endif // LLVM_CLANG_SCALABLESTATICANALYSIS_ANALYSES_TYPECONSTRAINEDPOINTERS_TYPECONSTRAINEDPOINTERS_H
a trap message and trap category.
Uniquely identifies a whole-program analysis and the AnalysisResult it produces.
Base class for whole-program analysis results.
Lightweight opaque handle representing an entity in an EntityIdTable.
Definition EntityId.h:31
Base class for analysis-specific summary data.
Uniquely identifies an analysis summary.
Definition SummaryName.h:22
@ Other
Other implicit parameter.
Definition Decl.h:1774
Whole-program set of pointer entities that must retain their pointer type.
Per-contributor set of pointer entities that must retain their pointer type.
bool operator==(const std::set< EntityId > &OtherEntities) const
bool friend operator==(const TypeConstrainedPointersEntitySummary &This, const TypeConstrainedPointersEntitySummary &Other)