This is an archive of the discontinued LLVM Phabricator instance.

[scan-build] fix dead store warnings emitted on clang code base
ClosedPublic

Authored by apelete on May 2 2016, 1:36 PM.

Details

Summary

This fixes dead store warnings of the type "dead assignment" reported
by CLang Static Analyzer on the following file:

  • tools/c-index-test/c-index-test.c.

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

Diff Detail

Repository
rL LLVM

Event Timeline

apelete updated this revision to Diff 55886.May 2 2016, 1:36 PM
apelete retitled this revision from to [scan-build] fix dead store warnings emitted on clang code base.
apelete added a reviewer: akyrtzi.
apelete updated this object.
apelete added a subscriber: cfe-commits.

Any reason not to remove the story instead?

Any reason not to remove the story instead?

What do you mean by "remove the story" ?

Sorry, I meant remove the /store/, if it's dead. The do/while loop
overwrites the store immediately, so just remove the assignment to Record?

Sorry, I meant remove the /store/, if it's dead. The do/while loop
overwrites the store immediately, so just remove the assignment to Record?

Makes sense, I overlooked that. Will fix in next revision.

apelete updated this revision to Diff 55952.May 2 2016, 11:40 PM

[scan-build] fix dead store warnings emitted on clang code base

Changes since last revision:

  • remove dead store since the do {} while() loop overwrite it immediatly anyway.

Looks good to me - go ahead & commit whenever you're ready.

apelete added inline comments.May 3 2016, 12:05 PM
tools/c-index-test/c-index-test.c
1440 ↗(On Diff #55952)

This line now causes a new "uninitialized argument value" warning because Parent variable isn't initialized anymore and Record variable is being passed here without being initialized either consequently.

Will fix in next revision.

apelete updated this revision to Diff 56042.May 3 2016, 12:08 PM

[scan-build] fix dead store warnings emitted on clang code base

Changes since last revision:

  • Initialize 'CXCursor Parent' variable to avoid passing 'Record' variable as an un-initialized argument thereafter.

Looks good to me - go ahead & commit whenever you're ready.

If this last revision is good for you, please go ahead and commit this for me (I don't have commit access).

Thanks.

dblaikie accepted this revision.May 3 2016, 1:01 PM
dblaikie added a reviewer: dblaikie.
dblaikie added inline comments.
tools/c-index-test/c-index-test.c
1435–1436 ↗(On Diff #56042)

Could you move these two declarations into the if (1438) since they appear to only be used within that scope anyway?

This revision is now accepted and ready to land.May 3 2016, 1:01 PM
apelete updated this revision to Diff 56059.May 3 2016, 1:32 PM
apelete edited edge metadata.

[scan-build] fix dead store warnings emitted on clang code base

Changes since last revision:

  • Move 'Record' and 'Parent' variables into if() {} scope where they are actually used.

Thanks - do you need someone (me) to commit this, or do you have commit
access?

Thanks - do you need someone (me) to commit this, or do you have commit
access?

I would appreciate if you could commit this for me since I don't have commit access.
Thanks.

This revision was automatically updated to reflect the committed changes.