Commit fa31ace
authored
[NFCI][analyzer] Simplify NodeBuilder constructors (llvm#181875)
This commit simplifies the construction of `NodeBuilder` and its
subclasses in three ways:
- It removes an assertion that only appeared in one of the two
constructors of `NodeBuilder`. While the asserted "no sinks in the
`Frontier`" invariant apparently holds, this assertion was not the right
place for expressing it. (In the future I might re-add a similar
assertion in a more reasonable location.)
- It adds a new constructor for `NodeBuilder` that doesn't take a
"source node(s)" argument, because this argument was often irrelevant.
- It removes the "source node(s)" arguments from the subclasses of
`NodeBuilder` because it was always completely irrelevant in those
situations.
Before this commit, constructors of `NodeBuilder` took three arguments:
- the source node or nodes,
- the destination node set where the freshly built nodes are placed,
- the `NodeBuilderContext` that provides access to the exploded graph.
Among these, the latter two were saved in data members, but the only use
of the source node(s) was that the constructor inserted them into the
destination node set (= the data member `Frontier`).
However, adding the source node(s) to the `Frontier` is usually
irrelevant, because later set operations almost always remove them from
the `Frontier`. This is especially clear in the subclasses derived from
`NodeBuilder` whose constructor immediately remove the source node(s)
from the `Frontier`. (In other situations, the source node(s) are
usually removed from the `Frontier` by the calls to `generateNode()`.)
This commit introduces a new constructor for `NodeBuilder` that doesn't
have a "source node(s)" parameter, then uses this constructor to
implement the constructors of the subclasses without pointless insertion
and then removal of nodes from the destination set.
Note that if a node `N` was already present in the destination set, then
its insertion+removal would remove it from the set; but I verified that
the destination set passed to constructors of subclasses of
`NodeBuilder` is always an empty set (at this point).
The new constructor of `NodeBuiler` is public because later it will be
also useful for simplifying other code that uses `NodeBuilder` directly.1 parent 0786f2d commit fa31ace
3 files changed
Lines changed: 19 additions & 45 deletions
File tree
- clang
- include/clang/StaticAnalyzer/Core/PathSensitive
- lib/StaticAnalyzer/Core
Lines changed: 13 additions & 39 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
245 | 245 | | |
246 | 246 | | |
247 | 247 | | |
248 | | - | |
249 | | - | |
250 | | - | |
251 | | - | |
252 | | - | |
253 | | - | |
254 | | - | |
255 | 248 | | |
256 | 249 | | |
257 | 250 | | |
258 | 251 | | |
259 | 252 | | |
260 | 253 | | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
261 | 257 | | |
262 | 258 | | |
263 | | - | |
| 259 | + | |
264 | 260 | | |
265 | 261 | | |
266 | 262 | | |
267 | 263 | | |
268 | 264 | | |
269 | | - | |
| 265 | + | |
270 | 266 | | |
271 | | - | |
272 | 267 | | |
273 | 268 | | |
274 | 269 | | |
| |||
333 | 328 | | |
334 | 329 | | |
335 | 330 | | |
336 | | - | |
337 | | - | |
338 | | - | |
339 | | - | |
340 | | - | |
341 | | - | |
342 | | - | |
343 | | - | |
344 | | - | |
345 | | - | |
346 | | - | |
347 | | - | |
348 | | - | |
349 | | - | |
350 | | - | |
| 331 | + | |
| 332 | + | |
| 333 | + | |
351 | 334 | | |
352 | 335 | | |
353 | 336 | | |
| |||
358 | 341 | | |
359 | 342 | | |
360 | 343 | | |
361 | | - | |
362 | | - | |
363 | | - | |
364 | | - | |
365 | | - | |
366 | | - | |
367 | | - | |
368 | | - | |
| 344 | + | |
| 345 | + | |
| 346 | + | |
369 | 347 | | |
370 | 348 | | |
371 | 349 | | |
| |||
386 | 364 | | |
387 | 365 | | |
388 | 366 | | |
389 | | - | |
390 | | - | |
391 | | - | |
392 | | - | |
393 | | - | |
394 | | - | |
| 367 | + | |
| 368 | + | |
395 | 369 | | |
396 | 370 | | |
397 | 371 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
428 | 428 | | |
429 | 429 | | |
430 | 430 | | |
431 | | - | |
| 431 | + | |
432 | 432 | | |
433 | 433 | | |
434 | 434 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1650 | 1650 | | |
1651 | 1651 | | |
1652 | 1652 | | |
1653 | | - | |
| 1653 | + | |
1654 | 1654 | | |
1655 | 1655 | | |
1656 | 1656 | | |
| |||
2850 | 2850 | | |
2851 | 2851 | | |
2852 | 2852 | | |
2853 | | - | |
| 2853 | + | |
2854 | 2854 | | |
2855 | 2855 | | |
2856 | 2856 | | |
| |||
2870 | 2870 | | |
2871 | 2871 | | |
2872 | 2872 | | |
2873 | | - | |
| 2873 | + | |
2874 | 2874 | | |
2875 | 2875 | | |
2876 | 2876 | | |
| |||
2979 | 2979 | | |
2980 | 2980 | | |
2981 | 2981 | | |
2982 | | - | |
| 2982 | + | |
2983 | 2983 | | |
2984 | 2984 | | |
2985 | 2985 | | |
| |||
3108 | 3108 | | |
3109 | 3109 | | |
3110 | 3110 | | |
3111 | | - | |
| 3111 | + | |
3112 | 3112 | | |
3113 | 3113 | | |
3114 | 3114 | | |
| |||
0 commit comments