[clang] [NFC][analyzer] Improve tracking of the current Block & LocCtx (PR #185107)

DonĂ¡t Nagy via cfe-commits cfe-commits at lists.llvm.org
Tue Mar 10 07:12:55 PDT 2026


NagyDonat wrote:

> I'd propose merging this as it's reviewed.

OK, then I won't add anything significant in this PR.

However, I added four small commits that really belong here:
- https://github.com/llvm/llvm-project/pull/185107/commits/0b42672016317382d856605f3aee55fbf54c27d9 fixes some mistakes in comments (from previous commits) and adds some new comments;
- https://github.com/llvm/llvm-project/pull/185107/commits/8fb72e4161bc4d068651c6a990f27d148a3fd08b adds the assertion that you suggested;
- https://github.com/llvm/llvm-project/pull/185107/commits/f647ee9229a6c3d9dd78708a7f7a1cd22e88f10e removes three defensive assignments (`currBldrCtx = nullptr`) to keep this change together with the addition of the new defensive assignment (`resetCurrLocationContextAndBlock()` at the beginning of `dispatchWorkItem`)
  - also these defensive assignments were "left dangling" when I moved the `currBldrCtx = <something>` assignments away from the beginning of those methods
- https://github.com/llvm/llvm-project/pull/185107/commits/6548af8da1e85c03777576ffab458c021c23830d is minor cleanup after one of the earlier commits

Also, I thought about shortening some of the freshly introduced function names:
- `(re)setCurrLocationContextAndBlock` to `(re)setCurrLocCtxAndBlock`
- `getCurrentLocationContext` to `getCurrLocationContext` or `getCurrentLocCtx` or `getCurrLocCtx`
- `getCurrentBlock` to `getCurrBlock`
Personally I feel that it would be good to shorten `Current` to `Curr` everywhere (it is already shortened in   `setCurrLocationContextAndBlock` because it was simply too long otherwise). I'm ambivalent about shortening `LocationContext` to `LocCtx` in these method names -- it would help the unwieldy `setCurrLocationContextAndBlock`, but that method is rarely used, so it may not be necessary.

Obviously if we rename some methods, it would be more elegant to do so before merging this commit with the "bad" names.

@steakhal @ others what do you think about this?

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


More information about the cfe-commits mailing list