<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/133955>133955</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[libclang] Theoretical ABI break in `libclang.so` 20.1.1
</td>
</tr>
<tr>
<th>Labels</th>
<td>
clang:as-a-library
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
isuckatcs
</td>
</tr>
</table>
<pre>
In `libclang.so.20.1.0` we have the following `Sema` class.
```c++
class Sema final : public SemaBase {
...
private:
/// Function or variable declarations to be checked for whether the deferred
/// diagnostics should be emitted.
llvm::SmallSetVector<Decl *, 4> DeclsToCheckForDeferredDiags;
/// Map of current shadowing declarations to shadowed declarations. Warn if
/// it looks like the user is trying to modify the shadowing declaration.
llvm::DenseMap<const NamedDecl *, const NamedDecl *> ShadowingDecls;
...
};
```
In `libclang.so.20.1.1` this definition is changed the way below.
```c++
class Sema final : public SemaBase {
...
public:
...
/// Function or variable declarations to be checked for whether the deferred
/// diagnostics should be emitted.
llvm::SmallSetVector<Decl *, 4> DeclsToCheckForDeferredDiags;
private:
/// Map of current shadowing declarations to shadowed declarations. Warn if
/// it looks like the user is trying to modify the shadowing declaration.
llvm::DenseMap<const NamedDecl *, const NamedDecl *> ShadowingDecls;
...
};
```
In other words, `DeclsToCheckForDeferredDiags` is made `public` in 20.1.1, when it was `private` in 20.1.0.
Until C++23 the C++ standard said the following about this.
> [Note: Non-static data members of a (non-union) class with the same access control (11.9) and non-zero
> size (6.7.2) are allocated so that later members have higher addresses within a class object. **The order of
> allocation of non-static data members with different access control is unspecified**.
>
> N4849 § 11.4 19
With C++23 however this restriction was removed though.
> [Note 8 : Non-variant non-static data members of non-zero size (6.7.2) are allocated so that later members
> have higher addresses within a class object (7.6.9).
>
> N4950 § 11.4.1 20
LLVM is still compiled targeting the C++17 standard, which means, the first quote of the standard applies and compilers have the right to change the field order of `Sema` IIUC. I'm not sure if there are compilers taking advantage of this, but if they do, the resulting `libclang.so` will not be ABI compatible with it's previous release.
</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJzsVk2P2zgP_jXKhRjDlvN5yCGT6QADtHOZfpxpibH5jizlleQE01-_kOy0abZdoIs9LRYIMBiJJvk8fEgKQ-DWEm3F4l4sHmY4xM75LYdBvWJUYdY4_bZ9siCWpeFGGbRtEVwhy6IqSrEs4UzQ4YkgdgQHZ4w7s22T-Qv1mAyUwRAKUe7Eshx_Ssj79Ct3-Q6SJRzYogFR7-A4NIZVPr3HQCBWyRSgKLKXcnf0fMJIot7lcyEfxx88DlZFdhachxN6xsYQaFIGPabzANFBQ6A6Uq-k4eA8nDuKHfmcv6YDeU_6xq1mbK0LkVWA0LnB6OSEeo6RdJGNjTn1KZ9699KjMS8UP5OKzot6_0DKgJA7IfcwF_U7SAfho9unJB6df5iCPjC2QdT3I8br-B_wCO4AavCebITQoR5ZvoU23pD-4aKAL-gt8OHGK0cwzr0GMPw6lm8I5IEDRP-WvEcHvdN8eMuXP416C_6BbKAPeBT1XjkbIjxjT_qagZ8d1-_g5eI9k3PFwlT01cN0dtHQeP8LYVZJd7HjkCrKlrMmOIDq0LakM54zvkFDxp0nUf1z6swGozh_vPmXSvW2Hf_T7-_o1-WSnp3XIfkXy_IvSV-WCWGPmpLppLV0aGGSvtwnodjEzxlDtpoKdGVWTpL8ZCMb2I-Sl3VmavoPQkSr0WsIyPpmvmPjhphbLDuq34FY3D-7rAJ4dvYuRIysQGNE6KlvyIekAQQh19bZu8Gys0JuxvUAZ47dWCbsCVApCiFxHb1LHK-rqtgka7Qa0udfybspcOCvlEyWxaqQ2cYToDFOYSQNwUHsMILBSP5bKnllddwm7lFrTyHQmAVbwCkp1_yPVCzG0u8-dgTOa_LgDlPoKUpu40PO62ewMzbNhwNl-d-A4wCDDUdSfGDSY6iJ0ynK83w934DYS7FbQVUVc6g2Y_W-JM_fi9e5M53yfOAAnkL0PM6YpANPvTvl2eeGtrupGqz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