Commit 10d99ad
Disable unique-object-duplication warning in templates (llvm#129120)
I've been trying to resolve instances of the unique-object-duplication
warning in chromium code. Unfortunately, I've found that practically
speaking, it's near-impossible to actually fix the problem when
templates are involved.
My understanding is that the warning is correct -- the variables it's
flagging are indeed duplicated and potentially causing bugs as a result.
The problem is that hiddenness is contagious: if a templated class or
variable depends on something hidden, then it itself must also be
hidden, even if the user explicitly marked it visible. In order to make
it actually visible, the user must manually figure out everything that
it depends on, mark them as visible, and do so recursively until all of
its ancestors are visible.
This process is extremely difficult and unergonomic, negating much of
the benefits of templates since now each new use requires additional
work. Furthermore, the process doesn't work if the user can't edit some
of the files, e.g. if they're in a third-party library.
Since a warning that can't practically be fixed isn't useful, this PR
disables the warning for _all_ templated code by inverting the check.
The warning remains active (and, in my experience, easily fixable) in
non-templated code.1 parent f749146 commit 10d99ad
File tree
2 files changed
+15
-75
lines changed- clang
- lib/Sema
- test/SemaCXX
2 files changed
+15
-75
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
13427 | 13427 | | |
13428 | 13428 | | |
13429 | 13429 | | |
13430 | | - | |
13431 | | - | |
13432 | | - | |
| 13430 | + | |
| 13431 | + | |
| 13432 | + | |
| 13433 | + | |
| 13434 | + | |
| 13435 | + | |
| 13436 | + | |
13433 | 13437 | | |
13434 | 13438 | | |
13435 | 13439 | | |
| |||
13469 | 13473 | | |
13470 | 13474 | | |
13471 | 13475 | | |
13472 | | - | |
13473 | | - | |
| 13476 | + | |
| 13477 | + | |
13474 | 13478 | | |
13475 | 13479 | | |
13476 | 13480 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
165 | 165 | | |
166 | 166 | | |
167 | 167 | | |
168 | | - | |
169 | | - | |
170 | | - | |
171 | | - | |
172 | | - | |
173 | | - | |
174 | | - | |
175 | | - | |
176 | | - | |
177 | | - | |
178 | | - | |
179 | | - | |
180 | | - | |
181 | | - | |
| 168 | + | |
| 169 | + | |
182 | 170 | | |
183 | | - | |
184 | 171 | | |
185 | | - | |
186 | | - | |
187 | | - | |
188 | | - | |
189 | | - | |
190 | | - | |
191 | | - | |
192 | | - | |
193 | | - | |
| 172 | + | |
194 | 173 | | |
195 | | - | |
196 | | - | |
197 | | - | |
198 | | - | |
199 | | - | |
200 | | - | |
201 | | - | |
| 174 | + | |
202 | 175 | | |
203 | 176 | | |
204 | | - | |
| 177 | + | |
205 | 178 | | |
206 | | - | |
207 | | - | |
208 | | - | |
209 | | - | |
210 | | - | |
211 | | - | |
212 | | - | |
213 | | - | |
214 | | - | |
215 | | - | |
216 | | - | |
217 | | - | |
218 | | - | |
219 | | - | |
220 | | - | |
221 | | - | |
222 | | - | |
223 | | - | |
224 | | - | |
225 | | - | |
226 | | - | |
227 | | - | |
228 | | - | |
229 | | - | |
230 | | - | |
231 | | - | |
232 | | - | |
233 | | - | |
234 | | - | |
235 | | - | |
236 | | - | |
237 | | - | |
238 | | - | |
239 | | - | |
240 | | - | |
241 | | - | |
242 | | - | |
| 179 | + | |
243 | 180 | | |
244 | | - | |
245 | 181 | | |
0 commit comments