[-Wunsafe-buffer-usage] Add Fixable for simple pointer dereference
This patch introduces PointerDereferenceGadget, a FixableGadget that emits fixits to handle cases where a pointer that is identified as unsafe is dereferenced. The current implementation only handles cases where the strategy is to change the type of the raw pointer to std::span. The fixit for this strategy is to fetch the first element from the corresponding span instance. For example for the code below, the PointerDereferenceGadget emits a fixit for S3 (S1, S2 are to be handled by other gadgets): S1: int *ptr = new int[10]; S2: int val1 = ptr[k]; // Unsafe operation S3: int val2 = *ptr; => Fixit: int val2 = ptr[0]; Differential revision: https://reviews.llvm.org/D143206
Loading
Please sign in to comment