This is an archive of the discontinued LLVM Phabricator instance.

[analyzer] refactor makeIntValWithPtrWidth, remove getZeroWithPtrWidth (NFC)
ClosedPublic

Authored by vabridgers on Feb 18 2022, 8:26 AM.

Details

Summary

This is a NFC refactoring to change makeIntValWithPtrWidth
and remove getZeroWithPtrWidth to use types when forming values to match
pointer widths. Some targets may have different pointer widths depending
upon address space, so this needs to be comprehended.

Diff Detail

Event Timeline

vabridgers created this revision.Feb 18 2022, 8:26 AM
vabridgers requested review of this revision.Feb 18 2022, 8:26 AM
Herald added a project: Restricted Project. · View Herald TranscriptFeb 18 2022, 8:26 AM
Herald added a subscriber: cfe-commits. · View Herald Transcript
steakhal added inline comments.Feb 18 2022, 1:59 PM
clang/include/clang/StaticAnalyzer/Core/PathSensitive/SValBuilder.h
335–336

This function should have a different name.
Probbaly the makeIntValWithWidth() is a better alternative.
Ah but even this is far less than ideal.

clang/lib/StaticAnalyzer/Checkers/MallocChecker.cpp
2613

We peobably wanted to use a different tspe for this expressuon. 'getArrayIndexType()' is a better fit IMO.
We shall see.

Update per @steakhal comments

vabridgers marked 2 inline comments as done.Feb 22 2022, 3:04 AM

I believe the comments have been addressed. Thank you - Vince

steakhal accepted this revision.Feb 22 2022, 5:33 AM

Thanks for the patch. LGTM on my part.
@NoQ WDYT?

This revision is now accepted and ready to land.Feb 22 2022, 5:33 AM
Herald added a project: Restricted Project. · View Herald TranscriptMar 1 2022, 5:09 PM
Herald added a subscriber: manas. · View Herald Transcript

Is it ok to land this change? Or shall we continue to wait on @NoQ ?

ping! @steakhal accepted, should we wait for @NoQ before landing? Thanks!

NoQ added a comment.Mar 22 2022, 10:15 AM

Looks like the API was used incorrectly 50% of the time anyway :)

I have one nit but other than that looks good.

clang/lib/StaticAnalyzer/Checkers/MallocChecker.cpp
2613

TotalSize is literally size_t so ASTContext.getSizeType() is the right type. getArrayIndexType() is signed so it's different.

update per @NoQ's latest comments

vabridgers marked an inline comment as done.Mar 22 2022, 3:40 PM
vabridgers added inline comments.
clang/lib/StaticAnalyzer/Checkers/MallocChecker.cpp
2613

Thanks @NoQ , the review is update. Best