This is an archive of the discontinued LLVM Phabricator instance.

[scan-build] fix warnings emitted on Clang StaticAnalyzer code base
Needs RevisionPublic

Authored by apelete on May 5 2016, 3:27 AM.

Details

Summary

This patch fixes a few "Logic error" warnings of the type "Called c++
object pointer is null" reported by Clang Static Analyzer on the
following files:

  • lib/StaticAnalyzer/Checkers/NullabilityChecker.cpp,
  • lib/StaticAnalyzer/Core/PlistDiagnostics.cpp.

Signed-off-by: Apelete Seketeli <apelete@seketeli.net>

Diff Detail

Event Timeline

apelete updated this revision to Diff 56257.May 5 2016, 3:27 AM
apelete retitled this revision from to [scan-build] fix warnings emitted on Clang StaticAnalyzer code base.
apelete added a reviewer: zaks.anna.
apelete updated this object.
apelete added a subscriber: cfe-commits.
dblaikie added inline comments.
lib/StaticAnalyzer/Core/PlistDiagnostics.cpp
298

This assertion seems to be equivalent to replacing the prior 'if' with an assertion of the same condition, no? Is that correct? (& if it is, we should just do that)

apelete added inline comments.May 9 2016, 5:15 AM
lib/StaticAnalyzer/Core/PlistDiagnostics.cpp
298

You're right, I overlooked the simplification.
Will fix in next revision.

apelete updated this revision to Diff 56556.May 9 2016, 5:19 AM

[scan-build] fix warnings emitted on Clang StaticAnalyzer code base

  • lib/StaticAnalyzer/Core/PlistDiagnostics.cpp: factorize assert and check on '!Diags.empty' condition.
zaks.anna added inline comments.
lib/StaticAnalyzer/Checkers/NullabilityChecker.cpp
686

This conditional will assert if:

assert(Arg < NumArgs && "Arg access out of range!");

So removing this conditional will assert in the same cases as the assert you are adding.

696

Asserting might not be the right thing to do here.

zaks.anna requested changes to this revision.Sep 12 2016, 11:11 AM
zaks.anna edited edge metadata.
This revision now requires changes to proceed.Sep 12 2016, 11:11 AM