This is an archive of the discontinued LLVM Phabricator instance.

[analyzer] WIP: trackNullOrUndefValue: peel off ParenImpCasts before tracking.
ClosedPublic

Authored by NoQ on Dec 14 2017, 12:43 PM.

Details

Summary

Continuing experiments in D41253, i'm looking into unwrapping parentheses and implicit casts from the tracked expression. The peelOffOuterExpr method already does more, so the current situation where we're not doing this when there's no explicit outer expression looks like an accidental omission; i'd try to provide actual justification for this stuff.

This gives a lot of fancy improvements in the diagnostics and suppressions:

  • uninit-const.cpp: We unwrap an implicit LValueToRValue cast around a reference, which allows us to track the undefined value through the pass-by-reference function call back to the original uninitialized variable.
  • false-positive-suppression.m: ARCReclaimReturnedObject is unwrapped, so the respective suppression now works correctly under Objective-C automatic reference counting.
  • inlining/path-notes.m: By unwrapping another LValueToRValueCast, we display the specific diagnostic for the interesting value, instead of the generic diagnostic. It's still surprising that we don't display the same diagnostic in the non-interesting value case, so this remains to be fixed.
  • In the newly added test, parentheses are unwrapped.
  • inlining/path-notes.cpp: A regression here! This one is similar to uninit-const.cpp, but here when we unwrap LValueToRValueCast and dive into the function we suddenly get a duplicate diagnostic. Here FindLastStoreBRVisitor is not de-duplicated correctly. I'd explain what's going on in a follow-up patch that works around the problem, and for now i mark this test as FIXME so that all changes remain tested.

Diff Detail

Repository
rL LLVM