[PATCH] D81444: Make the diagnostic-missing-prototypes put the suggested `static` in front of `const` if exists.
Dmitri Gribenko via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Tue Jun 9 03:15:39 PDT 2020
gribozavr2 added inline comments.
================
Comment at: clang/lib/Sema/SemaDecl.cpp:14252
+ FD->getReturnType().isConstQualified())
+ return FD->getReturnTypeSourceRange().getBegin().getLocWithOffset(
+ /*strlen("const ")=*/-6);
----------------
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.
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