<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/69749>69749</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
No way using libclang to get a string literal that contains zero bytes
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
xTachyon
</td>
</tr>
</table>
<pre>
Code:
```cpp
const char BUFFER[] = "a\0b";
```
Using `clang_Cursor_Evaluate` + `clang_EvalResult_getAsStr` at least, there's no way to get the full literal.
Doing some debugging I found [this strncpy](https://github.com/llvm/llvm-project/blob/main/clang/tools/libclang/CIndex.cpp#L4384) which doesn't copy anything after the first \0, stripping the actual literal.
Even more, the `clang_EvalResult_getAsStr` only returns a `const char*` and no size, relying on the \0 to get the size of the string.
Is there any other way to get the actual literal? Is adding a new function that can do this something acceptable?
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJyUk99q4zoQxp9GvhlOcMaxE1_4In9qCBzORc_2usjWxNaiSEYat3WffpGdbLdlYVkIsaQZRt_85pMMQXeWqBL5QeSnRI7cO1-9fZNtPzmbNE5N1dEpEtlepCeR7kWRLr92GJaT1tnA0PbSw-Gprh8el1ogshMIRCnyY9oIRJEdvpRYtk9B2w5iRSNt93wcfXD--eFFmlEyiSIFgYePeAw8UhgNP3fE-_A_-5gjGQzJwAKPwD15ErgNYB28ygnYQUccz-EyGgNGM3lpVjc98__JRRnBXQkUNWPXxe0ZLm60CkR-4F4HCOxtO0wiPwnc9cxDiGCwFlh3mvuxWbXuKrA25uX--Wfw7ju1LLBujGsE1leprcB6bkdgzc6ZEJN1cz86nq2it1VEjNm_m2y3EVjCa6_bHpSjYAVuGVo3TCDtxH2UKi9MfmlR-8AQsUcYgb0ehpgRY7LlUf4ewMMLWbi6SG5G-EfkzpoJPPHobQA5p_-0gsD9PBWr4gyCfp-rejJTVOLsckF-TH-dTUwDd1nW7LXtPgk8h2WysWdwcfl1uJ-7E1kN5wBSqZkPWHqFy2hb1vP9kqGVFpSDZbTuSjeSbUsDy8aQyOpEVZkqs1ImVK2LcrvDLeaY9JVal4W67C47bLY7JCpUWWSFbMuyyEhtMdEVppitU0zXu02a44qoaYoSSamsVLIsxSalq9RmFW2ycr5LdAgjVUW53ZSJkQ2ZMD9MxCh9DsZ3lJ8SX83WasYuiE1qdODwUYU1G6r-W6w_zq_r7q07LHnje0d1w-EsS20DvJN30ExMIRm9qf7a6LPU6Om5lR8BAAD__-labY8">