llvm-project
0c655008 - [analyzer] Generalize MemRegion::getDescriptiveName (#213991)

Commit
16 days ago
[analyzer] Generalize MemRegion::getDescriptiveName (#213991) Previously `ArrayBoundChecker` had a utility function called `getRegionName` that acted as a wrapper around `MemRegion::getDescriptiveName` and provided fallback descriptions like "the heap area" or "the string literal" in cases when there was no exact name and `Memregion::getDescriptiveName` just returned an empty string. As this functionality may be useful for other checkers in the future, this commit moves it to `getDescriptiveName`, which now gains a second optional parameter called `AllowFallback` (which defaults to false). Calling `getDescriptiveName` with `AllowFallback == true` is almost equivalent to the utility function `getRegionName`: the only difference is that `getDescriptiveName` uses `getRawMemorySpace()` to remain independent of the current `State` -- while `getRegionName` took the `Space` (calculated with `Reg->getMemorySpace(State)`) as an argument. This introduces a very minor functional change in `security.ArrayBoundChecker`: if a symbolic region was originally created in the Unknown memory space but later we deduced that it is on the heap, then before this commit it was described as "the heap area" but now it is referred to as "the region". As this is a very rare situation and the new, less specific message is also completely acceptable, I don't think that we need to complicate the code to preserve the old behavior. This commit eliminates the useless variable `VariableName` from `getDescriptiveName`, other technical debt is left unchanged.
Author
Parents
Loading