Commit 8d55de4
Fix RULE-6-9-1 false positives for consistent type-alias redeclarations
RULE-6-9-1 reported false positives on entities that use identical type
alias spellings in every declaration (e.g. a function prototype in a
header and its definition in a .cpp both returning the same aliased
type).
The query decides that two declaration entries disagree using
`t.getATypeNameUse() = decl1 and not t.getATypeNameUse() = decl2`.
`TypedefType.getATypeNameUse()` is documented as incomplete and, in
whole-program extraction, is inconsistent across translation units: the
same header line yields one DeclarationEntry per including TU, and the
alias is associated with some copies but not others. The query then
pairs a "use" entry with a "no-use" entry and reports a spurious
divergence.
Add three guards, backed by helper predicates:
- sameSourceLocation: drop pairs that are the same source declaration
seen from different TUs (same file/line/column).
- template-instantiation exclusion: synthesised instantiation entries
duplicate the template's entries without recording type-name uses.
- typeAliasMentionedIn: before reporting that decl2 fails to use the
alias, confirm via TypeMention (which records every syntactic type
mention). Match by qualified name so a generic alias template
(Result) is recognised as the instantiated result (Result<X>), and
extend the search range to the function body start to catch trailing
return types.
Validated on a real codebase: 234 -> 30 findings (87% reduction, all
eliminated findings verified as false positives). The existing unit
test still passes, so no true positives are lost. No qltest regression
test is added because the false positive is an emergent property of
multi-TU whole-program extraction and does not reproduce in the
single/two-TU test harness.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>1 parent 464c304 commit 8d55de4
1 file changed
Lines changed: 77 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
17 | 17 | | |
18 | 18 | | |
19 | 19 | | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
20 | 79 | | |
21 | 80 | | |
22 | 81 | | |
23 | 82 | | |
24 | 83 | | |
25 | 84 | | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
26 | 97 | | |
27 | 98 | | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
28 | 105 | | |
29 | 106 | | |
30 | 107 | | |
| |||
0 commit comments