Add location to user defined attributes#9359
Add location to user defined attributes#9359jacob-carlborg wants to merge 2 commits intodlang:masterfrom
Conversation
|
Thanks for your pull request and interest in making D better, @jacob-carlborg! We are looking forward to reviewing it, and you should be hearing from a maintainer soon.
Please see CONTRIBUTING.md for more information. If you have addressed all reviews or aren't sure how to proceed, don't hesitate to ping us with a simple comment. Bugzilla referencesYour PR doesn't reference any Bugzilla issue. If your PR contains non-trivial changes, please reference a Bugzilla issue or create a manual changelog. Testing this PR locallyIf you don't have a local development environment setup, you can use Digger to test this PR: dub fetch digger
dub run digger -- build "master + dmd#9359" |
|
Needs a rebase, otherwise looking good. |
57ae3ad to
e48a971
Compare
|
This needs more work. |
e48a971 to
cf2dee2
Compare
4ac65f5 to
812f3cd
Compare
|
I think this is ready to go now. I turned out it required a bit more code then I initially thought. My original tests were flawed. Now all the tests have the UDA own its line to make sure it's the actual location of the UDA AST node that is used and not the AST node of the declaration. |
thewilsonator
left a comment
There was a problem hiding this comment.
How does this handle multiple UDAs?
Hmm, that's a good question. I'll add a test to find out. |
| * Parse const/immutable/shared/inout/nothrow/pure postfix | ||
| */ | ||
| StorageClass parsePostfix(StorageClass storageClass, AST.Expressions** pudas) | ||
| StorageClass parsePostfix(StorageClass storageClass, AST.Expressions** pudas, Loc* udaLoc) |
There was a problem hiding this comment.
Is there a reason to use * rather than ref?
There was a problem hiding this comment.
It's not actually relying on it being null. Supplying a temporary for the parameter will work fine, and it will remove the null dependence.
There was a problem hiding this comment.
As far as I know, using an out parameter would require to declare a variable at the call site, which would not be used afterwards in a couple of cases.
There was a problem hiding this comment.
That is correct. However, on the plus side:
- It reduces the complexity of the code by eliminating the conditional logic.
- It eliminates use of a pointer, thereby eliminating potential memory corruption.
- It eliminates the need to document that the argument may be null.
- It eliminates the need for the user to check that there's a null check on every dereference on the pointer.
outself-documents that this will be initialized by the function, not the caller.- The compiler optimizer knows (5) too, though currently it does not make use of such information.
Hence it is a better practice to use out.
|
|
||
| case TOK.at: | ||
| { | ||
| if (udaLoc) |
There was a problem hiding this comment.
Avoid null check by using out parameter.
All symbols should have location information. This is important especially when the compiler is used as a library.
This seems a bit more complicated. |
812f3cd to
1ebbc6f
Compare
As far as I can see the parse will combine multiple UDA declarations in the source code into a single AST node, @thewilsonator @WalterBright any advice? |
|
Superseeded by: #12524 |
All symbols should have location information. This is important especially when the compiler is used as a library.