This is an archive of the discontinued LLVM Phabricator instance.

[analyzer] Fix assertion failure on code with transparent unions
ClosedPublic

Authored by vsavchenko on Jun 22 2021, 8:01 AM.

Diff Detail

Event Timeline

vsavchenko created this revision.Jun 22 2021, 8:01 AM
vsavchenko requested review of this revision.Jun 22 2021, 8:01 AM
Herald added a project: Restricted Project. · View Herald TranscriptJun 22 2021, 8:01 AM
Herald added a subscriber: cfe-commits. · View Herald Transcript
NoQ added a comment.Jun 22 2021, 11:39 PM

Thx a lot for the fix!

clang/lib/StaticAnalyzer/Core/CallEvent.cpp
482–483

Maybe at least processParameter?

496–497

I think this check could be implemented more reliably on the AST. I.e., ask what's the type of the argument expression instead.

It's typically better to query the AST types instead of SVal types because AST types are richer (cf. lvalue/rvalue confusion from D104550#inline-993348 - which is a very common source of bugs) and also significantly less likely to be buggy / improperly modeled. So i'm very much in favor of knowing in advance which type do we expect according to the AST and then later asserting that we got something compatible from the SVal.

clang/test/Analysis/transparent_union_bug.c
5

Unused :P

Use argument expression's type instead of SVal's type

vsavchenko marked 2 inline comments as done.

Remove printState from the test

vsavchenko marked an inline comment as done.Jun 25 2021, 6:09 AM
NoQ accepted this revision.Jun 25 2021, 10:13 AM

Thanks again!~

This revision is now accepted and ready to land.Jun 25 2021, 10:13 AM