[PATCH] D81444: Make the diagnostic-missing-prototypes put the suggested `static` in front of `const` if exists.
Vy Nguyen via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Tue Jun 9 12:07:33 PDT 2020
oontvoo marked an inline comment as done.
oontvoo added inline comments.
================
Comment at: clang/lib/Sema/SemaDecl.cpp:14252
+ FD->getReturnType().isConstQualified())
+ return FD->getReturnTypeSourceRange().getBegin().getLocWithOffset(
+ /*strlen("const ")=*/-6);
----------------
gribozavr2 wrote:
> Could you add tests for the following cases? I'm not sure the implementation will work.
>
> ```
> // Two spaces between 'const' and 'struct'.
> const struct MyStruct get_struct() ...
>
> const /*comment*/ struct MyStruct get_struct() ...
>
> #define MY_CONST const
> MY_CONST struct MyStruct get_struct() ...
> ```
>
> I think a better way would be to check the token that comes before the type name, and if that token is 'const', then adjust the source location -- otherwise insert the 'static' keyword where we used to insert it in the past.
Done.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D81444/new/
https://reviews.llvm.org/D81444
More information about the cfe-commits
mailing list