[PATCH] D96725: [clang-tidy] Fix modernize-use-using in extern C code

Stephen Kelly via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Feb 15 14:22:27 PST 2021


steveire accepted this revision.
steveire added inline comments.
This revision is now accepted and ready to land.


================
Comment at: clang-tools-extra/test/clang-tidy/checkers/modernize-use-using.cpp:305
 };
+
+extern "C" {
----------------
njames93 wrote:
> steveire wrote:
> > Can you add tests for typedefs in other scopes like
> > 
> > ```
> > 
> > extern "C" {
> > typedef int CType;
> > 
> > struct CAnother {
> > };
> > 
> > typedef struct {
> >   int b;
> >   typedef struct CAnother AStruct;
> > } CStruct;
> > 
> > void foo()
> > {
> >   typedef struct CAnother AStruct;
> > }
> > }
> > 
> > ```
> I'm not sure those tests add any value. For the struct, you can't have a typedef in a struct in c. The function typedef is valid in c, but I still can't see a reason to use extern C when defining a function in c++
Fair enough - Clang accepts the typedef in the struct with a warning, but it doesn't get transformed by the check anyway. The one in the function doesn't get transformed either, and if functions are so unlikely to appear in extern C, that it doesn't need to be covered, that's fine with me.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D96725/new/

https://reviews.llvm.org/D96725



More information about the cfe-commits mailing list