This is an archive of the discontinued LLVM Phabricator instance.

[analyzer][NFC] Inline ExprEngine::handleLVectorSplat()
ClosedPublic

Authored by steakhal on Jun 29 2021, 8:08 AM.

Details

Summary

It seems like ExprEngine::handleLVectorSplat() was used at only 2 places.
It might be better to directly inline them for readability.

It seems like these cases were not covered by tests according to my coverage measurement, so I'm adding tests as well.
Besides that, I'm handling CK_MatrixCast similarly to how the rest of the unhandled casts are evaluated.

Previously:


After covering all three labels:

Diff Detail

Event Timeline

steakhal created this revision.Jun 29 2021, 8:08 AM
Szelethus requested changes to this revision.Jun 29 2021, 8:31 AM

It might be better to directly inline them for readability.

Using so many parameters like that is ugly indeed, but this is hardly better, and introduces code duplication. Maybe a fall through?

This revision now requires changes to proceed.Jun 29 2021, 8:31 AM
NoQ added a comment.Jun 29 2021, 1:44 PM

It might be better to directly inline them for readability.

Using so many parameters like that is ugly indeed, but this is hardly better, and introduces code duplication. Maybe a fall through?

Yes, i guess a fallthrough would be appropriate, given that the first call site has nothing to do with vector splats anyway.

+1 for fallthrough

steakhal updated this revision to Diff 355491.Jun 30 2021, 3:24 AM
steakhal edited the summary of this revision. (Show Details)
  • Uses FALLTHROUGH
  • Handles CK_MatrixCast similarly to how the rest of the unhandled casts are evaluated
  • Added tests to cover the switch case
steakhal added inline comments.Jun 30 2021, 3:25 AM
clang/test/Analysis/casts.c
201

BTW I don't know why are these Unknown. I thought it should be some conjured value. The same applies to the other 2.

vsavchenko added inline comments.Jun 30 2021, 3:46 AM
clang/test/Analysis/casts.c
201

Oh, I was (and still am) very sour about this! The store actually has all the required information (we'll have compoundVal{ x } here, but we absolutely cannot read it from the store! The logic there simply doesn't make sense! And whenever we use union objects that we know everything about, we get Unknownalmost every time.

steakhal added inline comments.Jun 30 2021, 4:26 AM
clang/test/Analysis/casts.c
201

Okay, does the same reasoning apply for the rest of the added test-cases?
What do you propose for moving forward?

vsavchenko added inline comments.Jun 30 2021, 4:39 AM
clang/test/Analysis/casts.c
201

It's not about your patch at all! I just saw union and Unknown and decided to rant about it 😅

steakhal added inline comments.Jun 30 2021, 4:51 AM
clang/test/Analysis/casts.c
201

Oh, fine.
What do you think about the other two cases? Shall I debug them, or let them go?

vsavchenko added inline comments.Jun 30 2021, 5:41 AM
clang/test/Analysis/casts.c
201

How was it before the patch?

steakhal added inline comments.Jun 30 2021, 6:04 AM
clang/test/Analysis/casts.c
201

The testfile passes as-is, before and after the patch.
It simply increases the coverage.

vsavchenko added inline comments.Jun 30 2021, 6:28 AM
clang/test/Analysis/casts.c
201

So, I'd say that this particular patch is good to go. And if you want to look into why these are Unknowns, it should probably be another patch. At least this is how I see it.

NoQ accepted this revision.Jun 30 2021, 7:25 PM

Great, thanks!

clang/lib/StaticAnalyzer/Core/ExprEngineC.cpp
523

Dunno, is this the intended formatting for fallthrough? Seems kinda off near those braces.

Thank you @NoQ and @vsavchenko for the review!

clang/lib/StaticAnalyzer/Core/ExprEngineC.cpp
523

I agree.
I'm using clang-format-10 at the moment.
Formats the diff automatically on save, so I assume it's the 'recommended' place.

This revision was not accepted when it landed; it landed in state Needs Review.Jul 1 2021, 1:44 AM
This revision was automatically updated to reflect the committed changes.
steakhal marked an inline comment as done.
Herald added a project: Restricted Project. · View Herald TranscriptJul 1 2021, 1:44 AM
Herald added a subscriber: cfe-commits. · View Herald Transcript
steakhal added inline comments.Jul 1 2021, 1:44 AM
clang/lib/StaticAnalyzer/Core/ExprEngineC.cpp
523

It seems like the most recent clang-format behaves the same.