[all-commits] [llvm/llvm-project] 91c07e: [analyzer] Ignore single element arrays in getStat...

Balazs Benics via All-commits all-commits at lists.llvm.org
Sat Sep 4 01:21:01 PDT 2021


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 91c07eb8ee6ea2d48158dce123bac7b7c30eb294
      https://github.com/llvm/llvm-project/commit/91c07eb8ee6ea2d48158dce123bac7b7c30eb294
  Author: Balazs Benics <balazs.benics at sigmatechnology.se>
  Date:   2021-09-04 (Sat, 04 Sep 2021)

  Changed paths:
    M clang/include/clang/StaticAnalyzer/Core/AnalyzerOptions.def
    M clang/lib/StaticAnalyzer/Core/MemRegion.cpp
    M clang/test/Analysis/analyzer-config.c
    M clang/test/Analysis/flexible-array-members.c

  Log Message:
  -----------
  [analyzer] Ignore single element arrays in getStaticSize() conditionally

Quoting https://gcc.gnu.org/onlinedocs/gcc/Zero-Length.html:
> In the absence of the zero-length array extension, in ISO C90 the contents
> array in the example above would typically be declared to have a single
> element.

We should not assume that the size of the //flexible array member// field has
a single element, because in some cases they use it as a fallback for not
having the //zero-length array// language extension.
In this case, the analyzer should return `Unknown` as the extent of the field
instead.

Reviewed By: martong

Differential Revision: https://reviews.llvm.org/D108230


  Commit: b97a96400a3f9ec33b80d0726111aae1c7b24513
      https://github.com/llvm/llvm-project/commit/b97a96400a3f9ec33b80d0726111aae1c7b24513
  Author: Balazs Benics <balazs.benics at sigmatechnology.se>
  Date:   2021-09-04 (Sat, 04 Sep 2021)

  Changed paths:
    M clang/include/clang/StaticAnalyzer/Core/PathSensitive/SValBuilder.h
    M clang/lib/StaticAnalyzer/Core/MemRegion.cpp
    M clang/lib/StaticAnalyzer/Core/SValBuilder.cpp
    M clang/lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp

  Log Message:
  -----------
  [analyzer] SValBuilder should have an easy access to AnalyzerOptions

`SVB.getStateManager().getOwningEngine().getAnalysisManager().getAnalyzerOptions()`
is quite a mouthful and might involve a few pointer indirections to get
such a simple thing like an analyzer option.

This patch introduces an `AnalyzerOptions` reference to the `SValBuilder`
abstract class, while refactors a few cases to use this /simpler/ accessor.

Reviewed By: martong, Szelethus

Differential Revision: https://reviews.llvm.org/D108824


  Commit: d6ca91ea42455453d08a7922e96fa6685827028d
      https://github.com/llvm/llvm-project/commit/d6ca91ea42455453d08a7922e96fa6685827028d
  Author: Balazs Benics <balazs.benics at sigmatechnology.se>
  Date:   2021-09-04 (Sat, 04 Sep 2021)

  Changed paths:
    M clang/lib/AST/ASTImporter.cpp
    M clang/unittests/AST/ASTImporterTest.cpp

  Log Message:
  -----------
  [clang][AST] Add support for SubstTemplateTypeParmPackType to ASTImporter

Thank you @martong for acquiring a suitable test case!

Reviewed By: shafik, martong

Differential Revision: https://reviews.llvm.org/D109237


Compare: https://github.com/llvm/llvm-project/compare/8f77dc459e31...d6ca91ea4245


More information about the All-commits mailing list