@@ -42,6 +42,43 @@ class VariableGroupsManager {
42
42
virtual VarGrpRef getGroupOfParms () const =0;
43
43
};
44
44
45
+ // FixitStrategy is a map from variables to the way we plan to emit fixes for
46
+ // these variables. It is figured out gradually by trying different fixes
47
+ // for different variables depending on gadgets in which these variables
48
+ // participate.
49
+ class FixitStrategy {
50
+ public:
51
+ enum class Kind {
52
+ Wontfix, // We don't plan to emit a fixit for this variable.
53
+ Span, // We recommend replacing the variable with std::span.
54
+ Iterator, // We recommend replacing the variable with std::span::iterator.
55
+ Array, // We recommend replacing the variable with std::array.
56
+ Vector // We recommend replacing the variable with std::vector.
57
+ };
58
+
59
+ private:
60
+ using MapTy = llvm::DenseMap<const VarDecl *, Kind>;
61
+
62
+ MapTy Map;
63
+
64
+ public:
65
+ FixitStrategy () = default ;
66
+ FixitStrategy (const FixitStrategy &) = delete ; // Let's avoid copies.
67
+ FixitStrategy &operator =(const FixitStrategy &) = delete ;
68
+ FixitStrategy (FixitStrategy &&) = default ;
69
+ FixitStrategy &operator =(FixitStrategy &&) = default ;
70
+
71
+ void set (const VarDecl *VD, Kind K) { Map[VD] = K; }
72
+
73
+ Kind lookup (const VarDecl *VD) const {
74
+ auto I = Map.find (VD);
75
+ if (I == Map.end ())
76
+ return Kind::Wontfix;
77
+
78
+ return I->second ;
79
+ }
80
+ };
81
+
45
82
// / The interface that lets the caller handle unsafe buffer usage analysis
46
83
// / results by overriding this class's handle... methods.
47
84
class UnsafeBufferUsageHandler {
0 commit comments