|
18 | 18 | #include "clang/AST/Expr.h" |
19 | 19 | #include "clang/AST/Stmt.h" |
20 | 20 | #include "clang/Basic/SourceLocation.h" |
| 21 | +#include "llvm/ADT/SmallPtrSet.h" |
21 | 22 | #include "llvm/Support/Debug.h" |
22 | 23 | #include <set> |
23 | 24 |
|
@@ -142,6 +143,53 @@ class UnsafeBufferUsageHandler { |
142 | 143 | ASTContext &Ctx) { |
143 | 144 | handleUnsafeOperation(Arg, IsRelatedToDecl, Ctx); |
144 | 145 | } |
| 146 | + |
| 147 | + virtual void handleStandaloneAssign(const Expr *E, const ValueDecl *VD, |
| 148 | + bool IsRelatedToDecl, ASTContext &Ctx) { |
| 149 | + handleUnsafeOperation(E, IsRelatedToDecl, Ctx); |
| 150 | + } |
| 151 | + |
| 152 | + enum class AssignToImmutableObjectKind { |
| 153 | + PointerToPointer, |
| 154 | + PointerToDependentValue, |
| 155 | + PointerDependingOnInoutValue, |
| 156 | + DependentValueUsedInInoutPointer, |
| 157 | + }; |
| 158 | + |
| 159 | + virtual void handleAssignToImmutableObject(const BinaryOperator *Assign, |
| 160 | + const ValueDecl *VD, |
| 161 | + AssignToImmutableObjectKind Kind, |
| 162 | + bool IsRelatedToDecl, |
| 163 | + ASTContext &Ctx) { |
| 164 | + handleUnsafeOperation(Assign, IsRelatedToDecl, Ctx); |
| 165 | + } |
| 166 | + |
| 167 | + virtual void handleMissingAssignments( |
| 168 | + const Expr *LastAssignInGroup, |
| 169 | + const llvm::SmallPtrSetImpl<const ValueDecl *> &Required, |
| 170 | + const llvm::SmallPtrSetImpl<const ValueDecl *> &Missing, |
| 171 | + bool IsRelatedToDecl, ASTContext &Ctx) { |
| 172 | + handleUnsafeOperation(LastAssignInGroup, IsRelatedToDecl, Ctx); |
| 173 | + } |
| 174 | + |
| 175 | + virtual void handleDuplicatedAssignment(const BinaryOperator *Assign, |
| 176 | + const BinaryOperator *PrevAssign, |
| 177 | + const ValueDecl *VD, |
| 178 | + bool IsRelatedToDecl, |
| 179 | + ASTContext &Ctx) { |
| 180 | + handleUnsafeOperation(Assign, IsRelatedToDecl, Ctx); |
| 181 | + } |
| 182 | + |
| 183 | + virtual void handleAssignedAndUsed(const BinaryOperator *Assign, |
| 184 | + const Expr *Use, const ValueDecl *VD, |
| 185 | + bool IsRelatedToDecl, ASTContext &Ctx) { |
| 186 | + handleUnsafeOperation(Assign, IsRelatedToDecl, Ctx); |
| 187 | + } |
| 188 | + |
| 189 | + virtual void handleUnsafeCountAttributedPointerAssignment( |
| 190 | + const BinaryOperator *Assign, bool IsRelatedToDecl, ASTContext &Ctx) { |
| 191 | + handleUnsafeOperation(Assign, IsRelatedToDecl, Ctx); |
| 192 | + } |
145 | 193 | /* TO_UPSTREAM(BoundsSafety) OFF */ |
146 | 194 |
|
147 | 195 | /// Invoked when a fix is suggested against a variable. This function groups |
@@ -196,7 +244,8 @@ class UnsafeBufferUsageHandler { |
196 | 244 | // This function invokes the analysis and allows the caller to react to it |
197 | 245 | // through the handler class. |
198 | 246 | void checkUnsafeBufferUsage(const Decl *D, UnsafeBufferUsageHandler &Handler, |
199 | | - bool EmitSuggestions); |
| 247 | + bool EmitSuggestions, |
| 248 | + bool BoundsSafetyAttributes = false); |
200 | 249 |
|
201 | 250 | namespace internal { |
202 | 251 | // Tests if any two `FixItHint`s in `FixIts` conflict. Two `FixItHint`s |
|
0 commit comments