This is an archive of the discontinued LLVM Phabricator instance.

[OpenCL] Added diagnostic for checking length of vector
ClosedPublic

Authored by echuraev on Mar 14 2017, 6:47 AM.

Diff Detail

Event Timeline

echuraev created this revision.Mar 14 2017, 6:47 AM
echuraev retitled this revision from Added diagnostic for checking length of vector to [OpenCL] Added diagnostic for checking length of vector.
Anastasia added inline comments.Mar 14 2017, 8:14 AM
lib/Sema/SemaExprMember.cpp
287

The format is normally: OpenCL v1.1, s6.1.7

288

Does this text have much relation to the function? I don't feel that copying it from the spec is helping much in understanding of this function. It's probably just Ok to have the reference to the spec section and concisely summarize that the component swizzle length must be in accordance with the acceptable vector sizes.

Also would it be better to rename this to something like:

IsValidOpenCLComponentSwizzleLength
389

I think the logic in this function is all for OpenCL, but we didn't check it . Anyways, let's leave it for now.

395

Variable name doesn't adhere the coding style:
http://llvm.org/docs/CodingStandards.html#name-types-functions-variables-and-enumerators-properly

Also you could use CompName->getLength() instead of constructing a new StringRef object.

test/SemaOpenCL/vector_swizzle_length.cl
8

Could we add a non-numeric swizzle too?

echuraev updated this revision to Diff 91890.Mar 15 2017, 9:24 AM
echuraev marked 5 inline comments as done.
bader removed a reviewer: bader.Mar 16 2017, 8:53 AM
bader added a subscriber: bader.
Anastasia accepted this revision.Mar 20 2017, 8:19 AM

LGTM! Thanks!

This revision is now accepted and ready to land.Mar 20 2017, 8:19 AM
echuraev closed this revision.Mar 21 2017, 6:33 AM