Commit 24ab6dc
committed
fix(detector): TThreadDestroy resolves type via constructor call fallback
False positive on FreeAndNil(gDfmRepoIndex) in uStaticAnalyzer2.pas:585.
TDfmRepoIndex is a plain class, not a TThread descendant - but the
detector's type-resolution only looked at '<Ident> : <Type>;' declarations
in the SAME file. gDfmRepoIndex is declared in uDfmRepoIndex.pas, so no
declaration was found and the conservative-flag path fired.
Fix: when the declaration regex fails, fall back to scanning the same
file for a constructor call '<Ident> := T<Type>.Create...'. That covers
the common cross-unit-global pattern where a TXxx pointer is declared
in one unit and only instantiated/freed in another (caches, repo
indexes, registries).
LooksLikeThreadType then correctly filters TDfmRepoIndex (no 'thread'
substring) and the detector stays silent. TThread descendants whose
type name does contain 'thread' continue to be flagged as before.
Regression test added: FreeAndNilCrossUnitGlobal_NotReported covers
exactly the gDfmRepoIndex pattern.1 parent 60fea52 commit 24ab6dc
2 files changed
Lines changed: 47 additions & 6 deletions
Lines changed: 21 additions & 6 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
218 | 218 | | |
219 | 219 | | |
220 | 220 | | |
221 | | - | |
222 | | - | |
223 | | - | |
224 | | - | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
225 | 230 | | |
226 | 231 | | |
227 | | - | |
228 | 232 | | |
229 | 233 | | |
230 | 234 | | |
231 | 235 | | |
232 | 236 | | |
233 | 237 | | |
234 | 238 | | |
235 | | - | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
236 | 251 | | |
237 | 252 | | |
238 | 253 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
26 | 26 | | |
27 | 27 | | |
28 | 28 | | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
29 | 32 | | |
30 | 33 | | |
31 | 34 | | |
| |||
209 | 212 | | |
210 | 213 | | |
211 | 214 | | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
212 | 238 | | |
213 | 239 | | |
214 | 240 | | |
| |||
0 commit comments