[PATCH] D139737: [-Wunsafe-buffer-usage] Initiate Fix-it generation for local variable declarations

Yitzhak Mandelbaum via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Dec 14 07:56:48 PST 2022


ymandel added a comment.

In D139737#3993813 <https://reviews.llvm.org/D139737#3993813>, @NoQ wrote:

> In D139737#3991699 <https://reviews.llvm.org/D139737#3991699>, @ymandel wrote:
>
>> 2. We (google) have a tool for changing the type of a variable which takes into account all cascading changes to other declarations that result from that type change. It is built on Transformer and another library that builds a graph of relationships in the AST, relevant to the type-rewriting problem.  Unfortunately, that's all internal -- not for IP reasons but simply because we never had reason to upstream it (nor an obvioius place to put it). So, I'd say that this advanced tooling is useful here if you want to _selectively_ change type T to type S, so you need tooling to tell you specifically which S's to update. If you're changing all T to S, then the problem is simpler.
>
> Yeah we want to be selective, so in our case there's an extra analysis step between noticing that the variable is of a certain type and realizing that we want to change it to a different type.
>
> I guess I'm curious if there are smaller building blocks of your machine that we could reuse. Like, for instance, the procedure of updating the type of the variable (without even updating all uses): it's a somewhat self-contained problem, and it's difficult enough on its own (you need to split up multi-variable `DeclStmt`s in two or three, find the right source locations for everything, and so on). I wonder if we could avoid reinventing the wheel there somehow.

Sure. I'll try to get you some sample code later today.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D139737/new/

https://reviews.llvm.org/D139737



More information about the cfe-commits mailing list