[clang] [Clang][UnsafeBufferUsage] Warn about two-arg string_view constructors. (PR #180471)

Rohan Jacob-Rao via cfe-commits cfe-commits at lists.llvm.org
Tue Feb 10 10:47:12 PST 2026


================
@@ -2568,6 +2568,26 @@ class UnsafeBufferUsageReporter : public UnsafeBufferUsageHandler {
     }
   }
 
+  void handleUnsafeOperationInStringView(const Stmt *Operation,
+                                         bool IsRelatedToDecl,
+                                         ASTContext &Ctx) override {
+    SourceLocation Loc;
+    SourceRange Range;
+    unsigned MsgParam = 0;
----------------
rohanjr wrote:

I see this is copied from above, but it seems it would make more sense to declare these where they are defined, if at all? I.e. declare `Loc` where it is defined below, and maybe inline the values of `MsgParam` and `Range` at their use (or define them in the `if` block they are needed).

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


More information about the cfe-commits mailing list