getRawCommentForDeclNoCacheImpl: linemarkers between between comment and declaration

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

getRawCommentForDeclNoCacheImpl: linemarkers between between comment and declaration

Deep Majumder via cfe-dev
Hi,

when looking for comments attached to a declaration, the
implementation aborts if (among other things) it finds a preprocessor
macro.
The problem with that is that when parsing a preprocessed file there
might be linemarkers like this:
> # 4 "bug.c" 3 4
> static inline
> # 4 "bug.c"
>          void fn(void);
Here, "static inline" was expanded from a macro. GCC seems to add
linemarkers if the macro comes from a system header.

I think that as long as the line markers just update the line
information of the current file and are not entering/leaving a
different file it should be okay to attach the comment to the
declaration.

That might be more complicated though because right now the check is
being done using a simple text search:
> if (Text.find_first_of(";{}#@") != StringRef::npos) {
>   printf("preproc\n");
>   return nullptr;
> }

What do you think?

Thanks
Michael
_______________________________________________
cfe-dev mailing list
[hidden email]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev