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

Artem Dergachev via cfe-commits cfe-commits at lists.llvm.org
Tue May 14 13:37:02 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)) {
----------------
haoNoQ wrote:

This should be a hard `cast<>()` because you don't really handle the else-branch so it results in an invalid source location. We can make it dynamic again later if we want.

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


More information about the cfe-commits mailing list