<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/154762>154762</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
Clang-tidy invalid suggestion: readability-container-size-empty
</td>
</tr>
<tr>
<th>Labels</th>
<td>
clang-tidy
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
joker-eph
</td>
</tr>
</table>
<pre>
With clang-tidy built at current head and applying it on MLIR:
```
$ clang-tidy -p build mlir/lib/Conversion/LLVMCommon/TypeConverter.cpp --checks=-*,readability-container-size-empty -fix -fix-errors
```
Yields this diff:
```
diff --git a/mlir/lib/Conversion/LLVMCommon/TypeConverter.cpp b/mlir/lib/Conversion/LLVMCommon/TypeConverter.cpp
index 7659481cd607..6d482f35eb31 100644
--- a/mlir/lib/Conversion/LLVMCommon/TypeConverter.cpp
+++ b/mlir/lib/Conversion/LLVMCommon/TypeConverter.cpp
@@ -183,7 +183,7 @@ LLVMTypeConverter::LLVMTypeConverter(MLIRContext *ctx,
// If it has been initialized, has the same body and packed bit, just use
// it. This ensures that recursive structs keep being recursive rather
// than including a non-updated name.
- if (TypeRange(convertedType.getBody()) == TypeRange(convertedElemTypes) &&
+ if (TypeRange(convertedElemTypes).empty() &&
convertedType.isPacked() == type.isPacked()) {
results.push_back(convertedType);
return success();
```
I don't quite get the logic that clang-tidy applied, but that's not equivalent (this lead to a test failure).
</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJykVU1v2zgQ_TX0ZSBBoiRLOuhgO2sgQAosimIXe1pQ5FhiQlEqOTTi_voF5XSdJkUPjUH4gzPzNB9vnoX3erCIHav2rLrbiEDj7LrH-Qldgsu46Wd16f7WNII0wg4JaXWBPmhDIAhkcA4twYhCgbAKxLKYi7YDaILZwqeH-8-s2LFsPdvs5WQ7xsvXgMmyYiqYjHaMH43uGT8eZntG5_VsGT8-PPz16TBP0_rjy2XBq5XQpXJZI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