This is an archive of the discontinued LLVM Phabricator instance.

[Static Analyzer] Use generics related information to infer dynamic types.
ClosedPublic

Authored by xazax.hun on Sep 16 2015, 5:05 PM.

Details

Summary

This patch makes the DynamicTypePropagation checker utilize the information about generics. Using this additional information more precise inlining can be done. It also fixes an XFAIL test.

The same stored information will be used by a separate general type checker. That checker will make it possible to get rid of the isReturnValueMisused function.

Diff Detail

Repository
rL LLVM

Event Timeline

xazax.hun updated this revision to Diff 34942.Sep 16 2015, 5:05 PM
xazax.hun retitled this revision from to [Static Analyzer] Use generics related information to infer dynamic types..
xazax.hun updated this object.
xazax.hun added a subscriber: cfe-commits.
zaks.anna added inline comments.Sep 17 2015, 12:27 PM
lib/StaticAnalyzer/Checkers/DynamicTypePropagation.cpp
871 ↗(On Diff #34942)

Would it be possible for this to reset the type to a less specific type? (What happens if the method was inlined and we already inferred the value of the returned symbolic region.)
Same question for where we update the type in dynamicTypePropagationOnCasts.

This also introduces a situation where both tables track the type. Maybe we should add a TODO here?

xazax.hun updated this revision to Diff 35027.Sep 17 2015, 12:48 PM

Addressed the comments.

xazax.hun marked an inline comment as done.Sep 17 2015, 12:51 PM
xazax.hun added inline comments.
lib/StaticAnalyzer/Checkers/DynamicTypePropagation.cpp
871 ↗(On Diff #35027)

You are right, I am added the check and the comment.
The dynamicTypePropagationOnCasts should not cause any trouble, it only updates the dynamic type map, when there is new and better information available. See getBetterObjCType function.

We do not need to call getBetterObjCType here, because if there were no information yet, we will populate the table, if a function was inlined and there is a cast before return getBetterObjCType was already called there, so it is safe to just skip updating the DynamicTypeMap.

zaks.anna added inline comments.Sep 17 2015, 5:38 PM
lib/StaticAnalyzer/Checkers/DynamicTypePropagation.cpp
871 ↗(On Diff #35027)

We do not need to call getBetterObjCType here, because if there were no information yet, we will populate the table, if a > function was inlined and there is a cast before return getBetterObjCType was already called there, so it is safe to just
skip updating the DynamicTypeMap.

You should explain this in the comment.

zaks.anna accepted this revision.Sep 17 2015, 5:38 PM
zaks.anna edited edge metadata.
This revision is now accepted and ready to land.Sep 17 2015, 5:38 PM
This revision was automatically updated to reflect the committed changes.