[-Wunsafe-buffer-usage] FixableGadget for handling stand alone pointers under UPC
This patch introduces UPCStandalonePointerGadget, a FixableGadget that emits fixits to handle cases where a pointer identified as unsafe is simply referenced. An example of such a case is when the pointer is input as an argument to a method call, where we can not change the type of the argument. For cases where the strategy for the unsafe pointer is to use std::span, the idea is to extract the underlying pointer by invoking the "data()" method on the span instance. For example, the gadget emits a fixit for S3, where S1, S2 are handled by other gadgets: S1: int *ptr = new int[10]; S2: int val1 = ptr[k]; // Unsafe operation on ptr S3: foo(ptr); // Some method that accepts raw pointer => FIXIT: foo(ptr.data()); Reviewed by: NoQ, ziqingluo-90, jkorous Differential revision: https://reviews.llvm.org/D143676
Loading
Please sign in to comment