<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/65108>65108</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
Clang-Tidy not reporting errors with -MD cl option
</td>
</tr>
<tr>
<th>Labels</th>
<td>
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
snweiss
</td>
</tr>
</table>
<pre>
We recently noticed some clang-tidy errors that only surfaced after our compiler flags were modified.
I was able to create a minimal reproducible example with the following source file -
``` code.cpp
#include <string>
class A {
public:
A(std::string aa, std::string bb) : b(std::move(bb)), a(std::move(aa)) {}
private:
std::string a;
std::string b;
};
```
Running `clang-tify` with `-MT` generates the expected error -
```
C:\Dev\clang-repro>clang-tidy --extra-arg-before=--driver-mode=cl code.cpp -- cl.exe -MT /W4 /C code.cpp
1 warning generated.
C:\Dev\clang-repro\code.cpp:5:41: warning: field 'b' will be initialized after field 'a' [clang-diagnostic-reorder-ctor]
A(std::string aa, std::string bb) : b(std::move(bb)), a(std::move(aa)) {}
^~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~
a(std::move(aa)) b(std::move(bb))
```
But when changing `-MT` to `-MD`, nothing is generated -
```
C:\Dev\clang-repro>clang-tidy --extra-arg-before=--driver-mode=cl code.cpp -- cl.exe -MD /W4 /C code.cpp
C:\Dev\clang-repro>
```
There's also something fishy going on with the argument parsing itself, because the tool gives different results when mixing/changing slashes and hyphens in these cl options.
This issue reproduces on LLVM 15 (bundled with Visual Studio 2022) as well as LLVM 16 obtained via `pip install clang-tools`
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzMVU2P2zgP_jXKhXDgyHE-DjlkkgZ4gfby7qA9yxJtcyFLhignkz30ty9kJ2k62851NwhsfZCPHpGPScVMjUPcifJFlMeZGmLrw47dBYl5Vnlz3X1DCKjRRXsF5yNpNMC-Q9BWuSaLZK6AIfjAEFsVwTt7BR5CrZKlq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