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

Sylvestre Ledru via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Jul 13 12:26:23 PDT 2017


sylvestre.ledru added inline comments.


================
Comment at: tools/clang-format/ClangFormat.cpp:377
     break;
   case 1:
     Error = clang::format::format(FileNames[0]);
----------------
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



https://reviews.llvm.org/D34824





More information about the cfe-commits mailing list