-
Notifications
You must be signed in to change notification settings - Fork 789
[SYCL] Cleanup the deprecated Intel attribute logic #3036
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
We previously sprinkled deprecated attribute logic around to a few places when we could instead use a single helper function to do the work for us. This also adds a fix-it hint when we find a deprecated attribute to help the user convert to the new spelling.
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.
Other than that question, the changes look good to me.
return S.Diag(Attr.getLoc(), diag::warn_attribute_spelling_deprecated) | ||
<< "'" + Attr.getNormalizedFullName() + "'"; | ||
return false; | ||
void Sema::CheckDeprecatedSYCLAttributeSpelling(const ParsedAttr &A, |
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.
A question for you. One of the new developers had mentioned that they found it difficult to figure out what the single letter variable names meant in a function; and I think we had changed to using slightly longer spellings to make that clearer. What is the clang convention, if there is any, for this? Are single letter variable names considered acceptable in "obvious" situations?
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.
The community convention is to match whatever surrounding code is doing, to some extent. In the olden days, almost everything was given terrible acronym names like A
for Attr
, FD
for FunctionDecl
and whatnot, so older code often uses poorer names. Newer code will sometimes use more descriptive names, or sometimes continue with the poor conventions.
The community is fine accepting single-letter names when they're obvious or their scope is highly limited. I tend to use them still, but probably should break that habit. The only reason I was changing the names here is because Attr
is also a type name and that sometimes makes for worse error reporting when modifying the code (you see this a lot with using Decl
as a variable name too).
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.
Hi @AaronBallman , FYI, when I started contributing to this repo, @pvchupin pointed the Contribution-guide, which suggests a few pointers to be followed while preparing our patch ( See section "Prepare your patch"). One of them lists following the LLVM coding standards and for this specific case Naming-conventions lists how we could better name variables, functions etc.
class VehicleMaker {
...
Factory<Tire> F; // Avoid: a non-descriptive abbreviation.
Factory<Tire> Factory; // Better: more descriptive.
Factory<Tire> TireFactory; // Even better: if VehicleMaker has more than one kind of factories.
};
I am not aware of cases where these guidelines are relaxed by the community, but thought I would just share.
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.
Thank you for the links @srividya-sundaram!
I am not aware of cases where these guidelines are relaxed by the community, but thought I would just share.
The relaxation I was talking about is in the Introduction of the coding standard document (https://llvm.org/docs/CodingStandards.html#introduction): "If you are extending, enhancing, or bug fixing already implemented code, use the style that is already being used so that the source is uniform and easy to follow."
That said, I agree that more descriptive names would be better in cases where the naming matters for understanding the code.
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.
If you are extending, enhancing, or bug fixing already implemented code, use the style that is already being used so that the source is uniform and easy to follow.
Thanks for pointing this out. I am myself in the midst of updating FE tests to be more readable/maintainable and found updating the non-descriptive variable names exhausting (made the code more understandable though IMO) . I could apply this rule for some cases I guess.
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.
FWIW, my usual rule of thumb is to use the ridiculously short names for variables and parameters that are only used in a limited scope, and go with more verbose names for member variables or within larger function body scopes.
People tend not to complain about code like:
if (const auto *FD = dyn_cast<FunctionDecl>(D)) {
FD->whatever();
}
or similarly restricted contexts. However, I also started back when the project used these short names more exclusively and so I picked up some bad habits. ;-)
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.
Looks good to me. Thanks for cleanup the logic.
6ffbd2a
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 Thanks!
* sycl: [SYCL][NFC] Fix warnings reported by Clang (intel#3050) [SYCL] Enhance device libraries filename check when constructing llvm-link commands (intel#2944) [SYCL][NFC] Add vtable ABI checks (intel#3032) [SYCL] Cleanup the deprecated Intel attribute logic (intel#3036)
… -1) (#3036) Corrected sunormal checking logic in is_fpclass intrinsic issubnormal(V) ==> unsigned(abs(V) - 1) < (all mantissa bits set) corrected the testfile to check the corrected logic Original commit: KhronosGroup/SPIRV-LLVM-Translator@a3a498db77dc532
We previously sprinkled deprecated attribute logic around to a few places
when we could instead use a single helper function to do the work for us.
This also adds a fix-it hint when we find a deprecated attribute to help
the user convert to the new spelling.
As a drive-by, this fixes functions that were using
Attr
as a variable name.