<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/124379>124379</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[clang-tidy] Create a check that expands TAB characters in code, but not in strnigs
</td>
</tr>
<tr>
<th>Labels</th>
<td>
clang-tidy,
check-request
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
LegalizeAdulthood
</td>
</tr>
</table>
<pre>
I'm manually expanding tabs in a code base (`git clone https://github.com/LegalizeAdulthood/trn.git`; `git checkout a34a4b0120ee729aad8a13920fde4af1cf037c05`) and it's quite tedious.
First of all, you might think that an IDE would do this for you, but it turns out that Visual Studio will only untabify the indentation at the beginning of a line, so the tabs between statements and comments don't get expanded.
Secondly, you might think "Why don't you use the unix `expand` command?" and while that's good for files containing plain text, it isn't so good for code that might contain embedded tab characters in string or character literals. For character literals, you don't want the tab character expanded at all, as that would introduce a syntax error. For string literals, you don't want tabs expanded to modulo 8 column (or whatever your tab size is) in the source file because the start of the string literal can be at any column, and you have to worry about the presence of escaped newline characters and so-on. You can't guarantee that expanding the tabs in a string literal is a behavior-preserving transformation.
So what we're left with is the need for a tool that understands the difference between string literals and source code. You might think that `clang-format` would be the right tool for the job, but I don't think you can get clang-format to leave your code alone **EXCEPT** for expanding tabs, so we're back to the need for a tool to do this one, single operation.
</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJx8VV1v2zwP_TXKDdHAkZs6uchF1i7AgPfiBTY8H5e0RdvaFDGTqKbZr38g2WmzrdhFEFsyycNzjiiM0Q6eaKfWH9T6aYFJRg67_9GAzv6gvUlORmazaNlcdp-Ubo5wRJ_QuQvQywm9sX4AwTaC9YDQsSFoMRIovVEP1WAFOseeYBQ5RVXvlT4ofRisjKlddnxU-vBbOaUPEvxysKIeKlV_gGumkbpvnASwvsf7tlrpiqjRW0SzwVW91VVv6B77VddXddNV6xyut4DegBWlmwjfkxUCI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