Fix "Logic error" warnings of the type "Called c++ object pointer is
null" reported by Clang Static Analyzer on the following files:
- lib/CodeGen/CGDebugInfo.cpp,
- lib/CodeGen/CodeGenModule.cpp.
Signed-off-by: Apelete Seketeli <apelete@seketeli.net>
Differential D19960
[scan-build] fix warnings emitted on Clang CodeGen code base apelete on May 5 2016, 3:15 AM. Authored by
Details
Diff Detail Event Timeline
|
It looks like this assertion could actually be a different assertion a little higher up.
For 'V' to be non-null, one of the if/else if chain above must fire.
So change the last else if to an else, and the dyn_cast to a cast, and the cast will fail an internal assertion if it's not valid (& the analyzer can easily then see that at least one of the assignments to V happens - whether or not the analyzer assumes that all the initializers of V are non-null, that's a separate issue...)