This is an archive of the discontinued LLVM Phabricator instance.

[analyzer][UninitializedObjectChecker] PR41611: Regard vector types as primitive
ClosedPublic

Authored by Szelethus on Apr 28 2019, 4:07 PM.

Details

Summary

https://bugs.llvm.org/show_bug.cgi?id=41611

Similarly to D61106, the checker ran over an llvm_unreachable for vector types:

struct VectorSizeLong {
  VectorSizeLong() {}
  __attribute__((__vector_size__(16))) long x;
};

void __vector_size__LongTest() {
  VectorSizeLong v;
}

Since, according to my short research,

The vector_size attribute is only applicable to integral and float scalars, although arrays, pointers, and function return values are allowed in conjunction with this construct.

vector types are safe to regard as primitive.

Diff Detail

Repository
rL LLVM

Event Timeline

Szelethus created this revision.Apr 28 2019, 4:07 PM

Thank you for the quick fix!

test/Analysis/cxx-uninitialized-object.cpp
1155 ↗(On Diff #197044)

Could you also add tests where the vector member is being subscripted? for example, v.x[0] = 0;

1155 ↗(On Diff #197044)

Should there be a warning about the member being uninitialized?

gribozavr added inline comments.Apr 29 2019, 1:02 AM
test/Analysis/cxx-uninitialized-object.cpp
1155 ↗(On Diff #197044)

Just to be clear -- if there should be a warning, I don't think this patch has to necessarily fix everything in the checker and static analyzer core to support vector types, the fix for the crash is valuable by itself. However, if there should be a warning, this test should have a fixme.

NoQ added inline comments.Apr 29 2019, 3:22 PM
test/Analysis/cxx-uninitialized-object.cpp
1155 ↗(On Diff #197044)

Most of the code in the Static Analyzer that deals with vector types is exactly like this patch: "oh, there are also vector types, right, i've no idea what they are but let's suppress everything just in case". Fixing false positives should be fine, but introducing warnings that are specific to vector types would be hard.

Szelethus updated this revision to Diff 197209.Apr 29 2019, 3:46 PM

Add TODO:s about missing warnings.

Szelethus marked 4 inline comments as done.Apr 29 2019, 3:47 PM
gribozavr accepted this revision.Apr 29 2019, 4:14 PM
This revision is now accepted and ready to land.Apr 29 2019, 4:14 PM
This revision was automatically updated to reflect the committed changes.
Herald added a project: Restricted Project. · View Herald TranscriptApr 30 2019, 1:47 AM