[clang] Respect the [[clang::unsafe_buffer_usage]] attribute for constructors (PR #91777)

Dana Jansens via cfe-commits cfe-commits at lists.llvm.org
Tue May 14 13:51:40 PDT 2024


================
@@ -2295,6 +2292,23 @@ class UnsafeBufferUsageReporter : public UnsafeBufferUsageHandler {
     }
   }
 
+  void handleUnsafeOperationInContainer(const Stmt *Operation,
+                                        bool IsRelatedToDecl,
+                                        ASTContext &Ctx) override {
+    SourceLocation Loc;
+    SourceRange Range;
+    unsigned MsgParam = 0;
+    if (const auto *CtorExpr = dyn_cast<CXXConstructExpr>(Operation)) {
----------------
danakj wrote:

Got it. The old code was dyn but that was because it handled other cases too. Once this function handles other gadgets we'll adjust it.

https://github.com/llvm/llvm-project/pull/91777


More information about the cfe-commits mailing list