-
Notifications
You must be signed in to change notification settings - Fork 773
[SYCL] Move diagnostic from integration header emission #2644
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Question 1: The code in "
Note that " The diagnostic message is incorrect in that the kernel name in the above example is actually not in the "std" namespace, and yet the message implies otherwise. Question 2: This patch has unified the include style for sycl mock header for FE tests in clang/test/CodeGenSYCL and clang/test/SemaSYCL. Is this the universal style to be followed for all FE tests? |
Incorrectness of this diagnostic actually depends on the exact text message that this diagnostic emits. Because
Yes, please. |
Thanks! I did not know this and was wondering why the diagnostic mentions "std" in this context?!
Yes, this would be a more helpful message. I will add a new entry for this, since |
I don't think this is necessary actually. What is unclear right now? That nullptr_t1 is an alias for nullptr? |
The keyword nullptr denotes the pointer literal. It is a prvalue of type std::nullptr_t. |
Not quite. nullptr is a value, its type is std::nullptr_t; similar to 0 being a value of type int. I don't believe this is unclear. |
When user code has: And the diagnostic emits a message: kernel name cannot be a type in the "std" namespace, is it obvious and clear from this message that nullptr, a pointer literal, is actually of type std::nullptr_t and hence we prohibit this? How does explicitly mentioning this in the message not helpful or unnecessary? |
Yes to the first part. The additional information does not add too much information to a user who used it in the construct to begin with. |
I don't get this statement? Also, I am not convinced with your rationale for why we shouldn't give users the exact information/reason for an error. |
The compiler did give the exact reason for the error - i.e the kernel name, in this case nullptr_t1, has a type in std namespace. What was unclear to you was that nullptr (a C++ keyword) has type std::nullptr. If you would like to provide that as additional information, I don't see the harm. I personally don't think it is necessary but if you disagree, I have no problem with the additional note as well. |
To be precise, when the compiler says: kernel name cannot be a type in the "std" namespace, my immediate reaction is to look at the kernel name and look for any usage of "std" namespace in the kernel name. The fact that "nullptr" has a type "std:nullptr_t" which is in a std namespace and hence we prohibit its usage is not obvious from the original message. While this maybe just my ignorance, I still think it doesn't cause any harm to provide this little detail in the message we emit. |
This is too long. I would prefer you add the additional information as a separate 'note' diagnostic. You can just say something like "nullptr is a prvalue of type std::nullptr_t" @premanandrao is that alright with you? |
I agree that it is too long. I think a note would be helpful, but I still don't feel that saying 'nullptr is ... of type std::nullptr_t' is particularly helpful. If instead it pointed to where the type got aliased, that might be helpful. For example:
pointing out where my_nullptr is aliased to nullptr, may be helpful in the note. |
I prefer to keep this PR specific to improving the diagnostic message by adding an additional note. I understand that this is not everyone's personal choice, but I don't see any real problem in doing so. Re: @premanandrao's suggestion, I will consider that in a separate patch. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a couple of nits to the tests, otherwise lgtm.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
This patch moves the diagnostic for the kernel name (kernel name cannot be a type in the "std" namespace) to the point in which the kernel is called, rather than during integration header emission.