[PATCH] D158499: [analyzer] Compute FAM dynamic size

Ding Fei via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Aug 22 20:24:25 PDT 2023


danix800 added a comment.

We have `getDynamicExtentWithOffset` to use, which can handle more general
dynamic memory based cases than this fix.

I'll abandon this one.

There are issues worth clarifying and fixing:

1). Debugging APIs like `clang_analyzer_dumpExtent` in `ExprInspection` might be expanded
to use `getDynamicExtentWithOffset` if it's intended to be used on not only dynamic allocated
regions but more general ones, and more testcases are needed to demonstrate the usage.

2). Fix type-inconsistency of several size-related `SVal`s, e.g.

  FAM fam;
  clang_analyzer_dump(clang_analyzer_getExtent(&fam));
  clang_analyzer_dump(clang_analyzer_getExtent(fam.data));
  // expected-warning at -2 {{4 S64b}}  // U64b is more reasonable when used as an extent
  // expected-warning at -2 {{0 U64b}}

`ArrayIndexType` might be misused here.

Simple searching results listed here (might not be complete):

1. `getDynamicExtentWithOffset` return value
2. `getElementExtent` return value
3. `ExprEngineCallAndReturn.cpp` when calling `setDynamicExtent` the `Size` arg


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D158499



More information about the cfe-commits mailing list