[PATCH] D153409: [clang][dataflow] Treat fields of anonymous records as being part of their parent.
Martin Böhme via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Tue Jun 27 03:05:53 PDT 2023
mboehme marked 2 inline comments as done.
mboehme added a comment.
PTAL
================
Comment at: clang/lib/Analysis/FlowSensitive/DataflowAnalysisContext.cpp:305
+ if (Field->isAnonymousStructOrUnion())
+ getFieldsFromClassHierarchy(Field->getType(), Fields);
+ else
----------------
gribozavr2 wrote:
> Could we somehow take advantage of the IndirectFieldDecl instead of recursing ourselves? Seems like that way we would be delegating to Clang the questions of the name injection/lookup.
Thanks for pointing this out.
I realized I was really working against the grain of the Clang AST. I've changed this patch so that it merely adds a new test (to demonstrate that we are already representing fields of anonymous records correctly).
The thing that actually needs to be fixed is the handling of `CXXCtorInitializer`; I'll do this in a followup patch.
================
Comment at: clang/unittests/Analysis/FlowSensitive/TransferTest.cpp:5427
+ const ValueDecl *SDecl = findValueDecl(ASTCtx, "s");
+ const ValueDecl *IDecl = findValueDecl(ASTCtx, "i");
+
----------------
gribozavr2 wrote:
> Could we make some stronger assertion to prove that the transfer function works? It seems to me that getChild() by itself does not prove that.
>
> For example, store and load the value and assert that it is the same.
Good point, done.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D153409/new/
https://reviews.llvm.org/D153409
More information about the cfe-commits
mailing list