This is an archive of the discontinued LLVM Phabricator instance.

[CFG] Add an option to inline CXXDefaultInitExpr into aggregate initialization
ClosedPublic

Authored by xazax.hun on Dec 17 2019, 5:20 PM.

Details

Summary

This is useful for clients that are relying on linearized CFGs for evaluating subexpressions and want the default initializer to be evaluated properly.

The upcoming lifetime analysis is using this but it might also be useful for the static analyzer at some point.

Diff Detail

Event Timeline

xazax.hun created this revision.Dec 17 2019, 5:20 PM
xazax.hun updated this revision to Diff 234427.Dec 17 2019, 5:21 PM
xazax.hun retitled this revision from [CFG] Add on option to inline CXXDefaultInitExpr into aggregate initialization to [CFG] Add an option to inline CXXDefaultInitExpr into aggregate initialization.
  • Add missing tests.
NoQ added inline comments.Dec 17 2019, 5:25 PM
clang/include/clang/StaticAnalyzer/Core/AnalyzerOptions.def
115

Maybe "cfg-expand-default-aggr-inits"?

116

Typo: "aggregate".

xazax.hun updated this revision to Diff 234434.Dec 17 2019, 5:34 PM
xazax.hun marked 2 inline comments as done.
  • Fix review comments.
xazax.hun updated this revision to Diff 234435.Dec 17 2019, 5:37 PM
  • Remove accidentally added files.
NoQ accepted this revision.Dec 17 2019, 5:42 PM

LGTM!

Even though this is probably not the right solution for the static analyzer use-case (because we may end up having duplicate expressions in the CFG), it might actually make the static analyzer perform better than before (because it's still better than not having these expressions at all in the CFG). I guess we could experiment.

clang/lib/Analysis/CFG.cpp
2369–2370

Can this be turned into a foreach loop?

clang/test/Analysis/aggrinit-cfg-output.cpp
22

We should really fix these :/

This revision is now accepted and ready to land.Dec 17 2019, 5:42 PM
xazax.hun updated this revision to Diff 234436.Dec 17 2019, 5:52 PM
xazax.hun marked 2 inline comments as done.
  • Use range based for.
This revision was automatically updated to reflect the committed changes.