Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
clang/include/clang/Analysis/FlowSensitive/Value.h | ||
---|---|---|
315 ↗ | (On Diff #511366) | Modifying already-created values is wrong since values are supposed to be immutable (I know we already do it in setChild above, but let's not add more?) A value can be stored in multiple locations, and if one of them is deleted, the other users of the same value shouldn't observe the change. |
clang/lib/Analysis/FlowSensitive/Transfer.cpp | ||
485 | I'm not convinced that we need to break the loc/value association for deleted heap allocations. After all, we don't do that for stack allocations that go out of scope. So why bother for the heap? Especially since "delete" is very rare in modern idiomatic C++. | |
490 | It is correct that we shouldn't deallocate PointerValue, but the reasons for that are different: (1) The code being analyzed might have multiple copies of the pointer, and it might have a double-free or a use-after-free. The analyzer shouldn't execute UB when the program being analyzed has UB. (2) The PointerValue is needed to analyze other basic blocks. (3) The downstream code that is going to inspect the environments at various program points will need the PointerValues (like the test in this patch). |
@gribozavr2 Just to make sure I understand you correctly here (before I make any changes to the code): IIUC you recommend simply doing nothing on a delete expression? (Your arguments for this make sense to me, just want to double-check I understood correctly.)
clang/include/clang/Analysis/FlowSensitive/Value.h | ||
---|---|---|
315 ↗ | (On Diff #511366) |
Good point -- removed.
No longer relevant, but just to complete the discussion: I don't believe this is true for StructValues because of the way that prvalues of class type get materialized into result objects. I believe this causes every StructValue to be materialized into exactly one AggregateStorageLocation. |
clang/lib/Analysis/FlowSensitive/Transfer.cpp | ||
485 | Good point. This makes everything much simpler. Done. | |
490 |
That's what I was trying to say with my comment here -- but this is now moot anyway, as we no longer do anything for deletes. |
I'm not convinced that we need to break the loc/value association for deleted heap allocations. After all, we don't do that for stack allocations that go out of scope. So why bother for the heap? Especially since "delete" is very rare in modern idiomatic C++.