This is an archive of the discontinued LLVM Phabricator instance.

[analyzer]FieldRegion in getStaticSize should return size of pointee type
AbandonedPublic

Authored by jcsxky on Sep 3 2023, 7:45 PM.

Details

Summary

In getStaticSize, case of FieldRegionKind should return size of pointee type of the member. In the following example:

struct B {
	int x;
	int y;
	int z;
};

class A{
public:
	void foo(){
		m++;
	}
private:
	B *m;
};

getDynamicElementCount of m region, if getDynamicExtent return the pointer size, getDynamicElementCount returns 0 in 64bit architecture(since pointer size is 8 while size of pointee type is 12). Use pointee type instead, it will return 1.

Diff Detail

Event Timeline

jcsxky created this revision.Sep 3 2023, 7:45 PM
Herald added a project: Restricted Project. · View Herald TranscriptSep 3 2023, 7:45 PM
jcsxky requested review of this revision.Sep 3 2023, 7:45 PM

Please add a testcase that demonstrates this issue (fails when your change in MemRegion.cpp isn't added) and shows that your commit fixes it.

jcsxky added a comment.Sep 4 2023, 9:50 PM

Please add a testcase that demonstrates this issue (fails when your change in MemRegion.cpp isn't added) and shows that your commit fixes it.

Thanks for your advice. We use this api in our own project and miss some cases which leads the incorrect result. I will abandon this patch later.

jcsxky abandoned this revision.Sep 4 2023, 9:52 PM