Skip to content
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

Attributes on line preceding the function are not parsed #53

Open
javster101 opened this issue Nov 30, 2021 · 2 comments
Open

Attributes on line preceding the function are not parsed #53

javster101 opened this issue Nov 30, 2021 · 2 comments
Labels
bug Something isn't working PR Welcome Extra attention is needed

Comments

@javster101
Copy link

I'm working with custom attributes for a serializer, and for readability purposes I'd like to have attributes on the line before the function the attribute is for, eg:

[[test::attr]]
void myFunc();

Unfortunately, CppAst cannot correctly identify the attribute in that case.

However, if I put the attribute on the same line:

[[test::attr]] void myFunc();

it works fine. As far as I know, the standard does allow the attributes to be before as per the former example. I'm not sure if this is an issue with CppAst or with libclang itself, but it would be great if attributes could be on the line before the function.

@javster101 javster101 changed the title Function attributes not on the same line are not parsed Attributes on line preceding the function are not parsed Nov 30, 2021
@xoofx xoofx added bug Something isn't working PR Welcome Extra attention is needed labels Feb 13, 2022
@xoofx
Copy link
Owner

xoofx commented Feb 13, 2022

Definitely possible, as attributes have to be parsed manually, so there might be some bugs.

@fangfang1984
Copy link
Contributor

Definitely possible, as attributes have to be parsed manually, so there might be some bugs.

Yes, it seems custom attribute is act as a ignore cursor here, but in now version of ClangSharp, it has no feature to query custom attribute here. I'm try to do it by manual use SourceLocation and offset. The on the line feature is important for not let code easy to read. Our project is try to use annoute with custom string to do this, but it will need many macros, and it is not controllable. It used looks like struct RCLASS(Ignore=true, DisplayName="abc") MyClass, where RCLASS is a macro at last will replace to a annotate attribute here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working PR Welcome Extra attention is needed
Projects
None yet
Development

No branches or pull requests

3 participants