[PATCH] D34824: clang-format: add an option -verbose to list the files being processed

Daniel Jasper via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Jul 18 00:08:46 PDT 2017


djasper added inline comments.


================
Comment at: tools/clang-format/ClangFormat.cpp:377
     break;
   case 1:
     Error = clang::format::format(FileNames[0]);
----------------
sylvestre.ledru wrote:
> djasper wrote:
> > I think we should restructure the code to not have to duplicate what you are adding here. I think fundamentally, we should be able to change this to:
> > 
> >   if (FileNames.empty()) {
> >     Error = clang::format::format("-");
> >     return Error ? 1 : 0;
> >   }
> >   if (FileNames.size() == 1 && (!Offsets.empty() || !Lengths.empty() || !LineRanges.empty())) {
> >     errs() << "error: -offset .... "
> >     return 1;
> >   }
> >   for (const auto& FileName : FileNames) {
> >     if (Verbose.getNumOccurences() != 0)
> >       errs() << "Formatting " << Filename << "\n";
> >     Error |= clang::format::format(FileName);
> >   }
> >   return Error ? 1 : 0;
> This isn't correct.
> You can have
> 
> ```
> bin/clang-format  -lines=1:1 foo-1.cpp foo-2.cpp 
> ```
> we won't enter into the "error: -offset" error
> 
Right. In my code I had a bug s/== 1/ != 1/. But I don't think you can drop that part entirely. As it is now, you cannot specify any -lines/offsets/lenghts even for a single file?


https://reviews.llvm.org/D34824





More information about the cfe-commits mailing list