1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
//! **`macro-redefined`**: a `#define` that changes a name whose definition is already in force.
//!
//! ```cpp
//! #define MAX 10
//! #define MAX 20 // the same name, a different body, no `#undef` between them
//! ```
//!
//! # The four conditions, and why each one is a way to be wrong
//!
//! A name may legally be defined more than once, and every condition below is one of the ways the language allows
//! it. All four have to hold for a finding:
//!
//! ```text
//! 1 the definition is of *this* file a name defined in a header is the header's business, and reporting it
//! here would be reporting another file's line in this one
//! 2 the definition is **in force** a `#define` inside `#if _HAS_CXX23` that nobody takes is not a
//! definition at all — `fact_in_force` is `Known`-valued and `Unknown`
//! keeps the fact out
//! 3 no `#undef` between the two an `#undef` makes the second one the name's first definition again
//! 4 the bodies differ an identical redefinition is legal, and it is what a header that
//! includes another header's `#define` twice produces
//! ```
//!
//! Condition 2 is the one that keeps this check off the standard library: a three-valued answer to "was this
//! definition taken" means a condition nobody can decide makes it answer `false` for **both** definitions, so two
//! `#define`s in mutually exclusive branches are not a redefinition of each other.
//!
//! That direction is the one this layer already documents — *"`Unknown` keeps the fact out … this can lose
//! evidence, never invent it"* — and it is why this check reports nothing on a header that reads correctly rather
//! than reporting the standard library's own idiom.
use cratefact_in_force;
use crateMacroFact;
use ;
/// **`macro-redefined`** — see the module documentation for the four conditions.
;
/// Whether two definitions wrote the same replacement list.
///
/// Read out of the file's own text through [`MacroFact::body_range`], which is what that field exists for — its
/// documentation says so: a consumer slices the body's text out of the defining file rather than re-deriving it by
/// searching the directive, "a search is a second implementation of the same rule, free to disagree with the one
/// that assigned the name".
///
/// Two empty bodies are equal, and a body the fact has no range for is empty: `#define NAME` followed by
/// `#define NAME` is the one redefinition the standard permits, and treating "no range" as "unknown, report it"
/// would fire on it.