[PATCH] D134791: [clang] Unify Sema and CodeGen implementation of isFlexibleArrayMemberExpr

Balázs Benics via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Nov 10 02:29:53 PST 2022


steakhal added a comment.

I wonder if we could come up with an overload or something for cases when we only have a `FieldDecl`.
For example, in the Clang Static Analyzer, we have something similar at MemRegion.cpp#L784-L811 <https://github.com/llvm/llvm-project/blob/af0f151bd38ef783397a3c3040a59bf2126447a5/clang/lib/StaticAnalyzer/Core/MemRegion.cpp#L784-L811>, and it would be great if we could also make use of this harmonized flexible-array-members detection.

Actually, @serge-sans-paille inserted a FIXME about this, and I believe it's correct.

  const AnalyzerOptions &Opts = SVB.getAnalyzerOptions();
  // FIXME: this option is probably redundant with -fstrict-flex-arrays=1.
  if (Opts.ShouldConsiderSingleElementArraysAsFlexibleArrayMembers && Size.isOne())
    return true;

Unfortunately, in this context we don't have an `Expr`; we only have a `FieldDecl`, so I'm looking for some way to plug this `isFlexibleArrayMemberLike()` into this.
I'm thinking of like introducing another overload for it accepting `FieldDecl` instead of `Expr` along with the current one.

@serge-sans-paille what do you think about this?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D134791



More information about the cfe-commits mailing list