This is an archive of the discontinued LLVM Phabricator instance.

[analyzer][solver] Compute adjustment for unsupported symbols as well
Needs RevisionPublic

Authored by vsavchenko on Aug 6 2021, 4:13 AM.

Details

Summary

When the solver sees conditions like a +/- INT cmp INT, it disassembles
such expressions and uses the first integer constant as a so-called "Adjustment".
So it's easier later on to reason about the range of the symbol (a
in this case).

However, conditions of form a +/- INT are not treated the same way,
and we might end up with contradictory constraints.

This patch resolves this issue and extracts "Adjustment" for the
latter case as well.

Diff Detail

Event Timeline

vsavchenko created this revision.Aug 6 2021, 4:13 AM
vsavchenko requested review of this revision.Aug 6 2021, 4:13 AM
Herald added a project: Restricted Project. · View Herald TranscriptAug 6 2021, 4:13 AM
Herald added a subscriber: cfe-commits. · View Herald Transcript
steakhal accepted this revision.Aug 6 2021, 8:15 AM

Seems reasonable to me. Let's wait for someone else as well.
This is a really elegant patch, I should tell!

This revision is now accepted and ready to land.Aug 6 2021, 8:15 AM

Seems reasonable to me. Let's wait for someone else as well.

Sure, NP.

This is a really elegant patch, I should tell!

Thanks! I guess my take on this, that this path to the solver just got forgotten and that's what produced this inconsistency.

I checked the tests file on the latest sources. It passes even without your changes. Maybe this patch is already outdated.

clang/lib/StaticAnalyzer/Core/RangedConstraintManager.cpp
82–86

Do we need the same changes here as below?

Herald added a project: Restricted Project. · View Herald TranscriptApr 11 2022, 9:52 AM
martong requested changes to this revision.Apr 13 2022, 5:57 AM

I am not sure if this patch makes sense at all because the adjustment handling logic is restricted to handle SymInt expressions only.

clang/lib/StaticAnalyzer/Core/RangedConstraintManager.cpp
82–86

I believe, the adjustment is deliberately Zero here. This is because we are dealing with a SymSym expr, and the adjustment logic is capable of handling only a SymInt expr.

This revision now requires changes to proceed.Apr 13 2022, 5:57 AM