<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/88641>88641</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
May I know whether returning "VersionMismatch" outside of its guarding condition is a potential logic error?
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
DongjieHe
</td>
</tr>
</table>
<pre>
https://github.com/llvm/llvm-project/blame/ef9446bd2d362ec90cd681ae59463d16bf671fe8/clang/lib/Serialization/ASTReader.cpp#L3022
In file clang/lib/Serialization/ASTReader.cpp and method "ASTReader::ReadControlBlock", the following code snippet seems to be logically incorrect:
```cpp
const std::string &CurBranch = getClangFullRepositoryVersion();
StringRef ASTBranch = Blob;
if (StringRef(CurBranch) != ASTBranch && !DisableValidation) {
if ((ClientLoadCapabilities & ARR_VersionMismatch) == 0)
Diag(diag::err_pch_different_branch) << ASTBranch << CurBranch;
return VersionMismatch;
}
```
When `ClientLoadCapabilities` is set to be `ARR_VersionMismatch` , the code still return `VersionMismatch`, which is very likely to be unexpected.
Please help to check. Thanks.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJyUlNFunDoTx59muBl9K7BZL1xwsdkV-iq10lES9VxGBg_gxmsj2zRnz9MfGTZJ0_amEsJgD7-Z_zAzMgQ9WqIG9newP2dyiZPzzdnZ8Zum_1PWOXVtphjnAPwIrAXWjjpOS7fr3QVYa8z31-V_s3ffqI_A2s7ICwFraajLUnSKKS4Y9XXeK1EVkvZ1KbgqRDeIQzFQBaztjbRjIukOWPtAXkuj_5VROwusPT483pNU5Hf9PAPjn3nOGORnyI_b_ZPFQRvCP8CgtAovFCenEBh7O0tC-TE9n5yN3pk74_pnYAzYCeNEODhj3Iu2I_ZOEQar55kiBqJLwOiwIzRu1L005ora9s77lBZ-CxVEvl1JyrqDiL2zIWKIavMeok98YOK0-DsvbT8h8DOOFE9JYbsYc0-zCzo6f_1KPqwCK2A18Ls3KiI-rKR7GvD48PgD6c647t1UDwiserMFVr35BVYjsCJ98wOBCWAi7Z91kJ2hr9JodUtzjXD4EAPe-AlrNNn42Ul1krPstNFRU0g8PN7fP92UfNHhIuPNNz8n33mStjHPWo7AKpWWNVvk_dPcT09KDwN5svGpew-dn4CfPohfN971vSXBU1y8xZ9j-JhPOJx_-o3b698TWQSR_14giBx1wEDxViAg8t_pFTm-VtlWW1Eb8xoYiPxX-2T-Mul-Svzv5K9o9DOZ683PYumfmfpIaodboH8ZkoFwIjMnm36i_nmHj5O0z2GXqYarmtcyo6Y4FDwXe1azbGqq_UHxquuKmgsSnSyHsiurg6Qur0RHQ6YblrMyL4sy56wq2K7m1A9lT3UlS5nvCcqcLlKbXZoVO-fHTIewUFNVoiwyIzsyYR1DjFl6wfUwNd3-nPlmnS_dMgYoc6NDDO-UqKOh5ou84id8tu4FXyaKE_lb1rY2Yr8UFkO3xKAVoRtQx4DjIr3amtoqnSo5ZVTi7CLZqKXZmhrJe-eBt9nizZ9PxlVWANausv8LAAD___LyvoU">