kakkoko wrote:

@mydeveloperday 

> However what you are saying is, its not using that assume-filename to locate 
> the .clang-format-ignore file?
> 
> Hence in the IDE it reformats myfile.* meaning you can't save it unformatted

Yes, that is correct.

You can see that in [the following file of `Clang-Format.cpp`, 
`main()`](https://github.com/llvm/llvm-project/blob/llvmorg-19.1.2/clang/tools/clang-format/ClangFormat.cpp#L709-L735):

```c++
  // If no file name is specified on the command line to be processed,
  // formatting is performed on standard input and terminates.
  if (FileNames.empty())
    return clang::format::format("-", FailOnIncompleteFormat);

  ...

  // Sequentially process each file specified on the command line
  for (const auto &FileName : FileNames) {
    // Check for .clang-format-ignore
    const bool Ignored = isIgnored(FileName);
    ...
    // If the pattern matches the pattern written in .clang-format-ignore,
    // do nothing and proceed to the next file
    if (Ignored)
      continue;
    ...
    // do formatting
    Error |= clang::format::format(FileName, FailOnIncompleteFormat);
  }
```

The `isIgnored()` function, which determines whether or not to ignore using 
`.clang-format-ignore`, is only called in the part that processes the files 
enumerated on the command line in order.


https://github.com/llvm/llvm-project/pull/113100
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to