<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/80854>80854</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
Create bugprone-string-view-data-usage check
</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>
PiotrZSL
</td>
</tr>
</table>
<pre>
I'm adding this here so, i wouldn't forget.
I run into this issue personally.
Background:
```
void something(std::string s);
int main()
{
std::string_view sv("something");
sv = sv.substr(0, 5);
something(sv.data());
}
```
Because constructor in std::string that take std::string_view is implicit, this forces developer to be more ... productive.
Problem is that in such case .data() may not be null terminated or may not point to proper string.
Enforce:
Find all calls to std::string_view::data, that are passed to method/function, where other parameter isnt an std::string_view::length/size.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJxsU8GO4zYM_Rr5QsSwFSdODj7sTBpggR4W6K2XgpYZWx1ZckXKg-nXF3KCbTodIIhginx875FCZjt6ok4dXtThUmCSKcTuhw0Sf__t16IPw0f3Xel2BhwG60eQyTJMFAk4KP0KFt5DcoNXuhW4hTiSlKq6qOrbd4jJg_US7kWWOREsFDl4dO7jkXb_f0HzNsaQ_KD2j5A6Vo_f9rkGOwCHmWSyflT6xLLl7r-xxMyMlT6r_cszqvUCM1qv9Clf3m_aRwoAfIL4Y7X0Drxu6fqpl36GznUrqP0FeC059SxR6VOVzTh8znumu5YDCj6oPFNtL18KfhhDBhMTmOBZYjISIlj_mTnIhAKCb_S1pmz_vDhrrGSe2zxuIRpiGGglFxaKIAF6gjlEgrIsYYlhSEbsSo9J_YihdzRnsK1dppHMBAaZ4EkczPgBPkhG88k5EIqz9Sg0QIg_b5eQxyMhN8rt73z_sxW_-I3kz5W4Wj8AOgcGneNc-5Xae-DO5_VOFSPBgsw05KI8lDAofb0lb8QGn_Pet6UOMlGEBSPOJBTBshfA__n91MeRH2VS-sr2byqLodsP5_0ZC-rqtmr1vtmf6mLqaqS6bW6n5nbA-tBqc24qvCHpVucDC9vpSjeVro71oTnquuzro6lOxuiKjrXpz6qpaEbrSufWuQxxLLYX1Z2q06EpHPbkeHvHWhuHftyJHT623X3NoYnM2y7SX4lYcvRwKWKXoXZ9Glk1lbMs_C-4WHHUvUZCIejTuMTgaXeXv8vyd9nhXWIcCTb0IkXXTSILZ2f0VenraGVKfWnCrPQ1Qz-O3RLDn2RE6esmgpW-bjr-CQAA___O-HHm">