<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/110160>110160</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            [clang-format] .clang-format-ignore does not match `/` with `*` wildcard
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            clang-format
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          ameerj
      </td>
    </tr>
</table>

<pre>
    When using a `.clang-format-ignore` file, a `*` wildcard is expected to match a directory separator. 
For example, a line containing `*g_*` should match any file in the current directory and all subdirectories that match the pattern `*g_*`

Currently, the `*` does not match the path separator. So a `*g_*` in the .clang-format-ignore file will only match this pattern for the current working directory. There does not seem to be a way to match the pattern for the current dir and subdirs.

Looking into the source code, it seems that this behavior is from the `matchFilePath` function, which is based on the POSIX `fnmatch()` function
https://github.com/llvm/llvm-project/blob/d4d38bcc3931d28d8b97d055258e27772119d0fe/clang/lib/Format/MatchFilePath.cpp#L10-L11


All of the following tests added to `MatchFilePathTest.cpp` fail:
```c++
 EXPECT_TRUE(match("some/nested/dir/file.cpp", "*nested*"));
 EXPECT_TRUE(match("some/nested/dir/file.cpp", "*/nested/*"));
 EXPECT_TRUE(match("some/nested/dir/g_file.cpp", "*g_*"));
 EXPECT_TRUE(match("some/nested/dir/g_file.cpp", "*/g_*"));
```

The `fnmatch()` function matches these cases:
https://godbolt.org/z/6qxYW41Yv

@owenca is this expected behavior?

P.S. I am seeing this behavior on Windows/MSVC, not sure if this affects all environments or is Windows specific.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJy0VcFu4zYQ_RrqQkSQKMmyDjp4kwhYIEWDJm12TwFFjixuKdIlqTju1xckbUcO3EOBLSBYiMJ5M--9mSG1VmwVQIuqL6i6S-jsRm1aOgGYH0mv-aF9GUHh2Qq1xRSjVZYySdX2ZtBmou5GbJU2gFYZHoQERG7jI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