@@ -36,6 +36,79 @@ namespace clang {
36
36
37
37
class CXXBasePaths ;
38
38
39
+ enum class LookupAmbiguityKind {
40
+ // / Name lookup results in an ambiguity because multiple
41
+ // / entities that meet the lookup criteria were found in
42
+ // / subobjects of different types. For example:
43
+ // / @code
44
+ // / struct A { void f(int); }
45
+ // / struct B { void f(double); }
46
+ // / struct C : A, B { };
47
+ // / void test(C c) {
48
+ // / c.f(0); // error: A::f and B::f come from subobjects of different
49
+ // / // types. overload resolution is not performed.
50
+ // / }
51
+ // / @endcode
52
+ AmbiguousBaseSubobjectTypes,
53
+
54
+ // / Name lookup results in an ambiguity because multiple
55
+ // / nonstatic entities that meet the lookup criteria were found
56
+ // / in different subobjects of the same type. For example:
57
+ // / @code
58
+ // / struct A { int x; };
59
+ // / struct B : A { };
60
+ // / struct C : A { };
61
+ // / struct D : B, C { };
62
+ // / int test(D d) {
63
+ // / return d.x; // error: 'x' is found in two A subobjects (of B and C)
64
+ // / }
65
+ // / @endcode
66
+ AmbiguousBaseSubobjects,
67
+
68
+ // / Name lookup results in an ambiguity because multiple definitions
69
+ // / of entity that meet the lookup criteria were found in different
70
+ // / declaration contexts.
71
+ // / @code
72
+ // / namespace A {
73
+ // / int i;
74
+ // / namespace B { int i; }
75
+ // / int test() {
76
+ // / using namespace B;
77
+ // / return i; // error 'i' is found in namespace A and A::B
78
+ // / }
79
+ // / }
80
+ // / @endcode
81
+ AmbiguousReference,
82
+
83
+ // / Name lookup results in an ambiguity because multiple placeholder
84
+ // / variables were found in the same scope.
85
+ // / @code
86
+ // / void f() {
87
+ // / int _ = 0;
88
+ // / int _ = 0;
89
+ // / return _; // ambiguous use of placeholder variable
90
+ // / }
91
+ // / @endcode
92
+ AmbiguousReferenceToPlaceholderVariable,
93
+
94
+ // / Name lookup results in an ambiguity because an entity with a
95
+ // / tag name was hidden by an entity with an ordinary name from
96
+ // / a different context.
97
+ // / @code
98
+ // / namespace A { struct Foo {}; }
99
+ // / namespace B { void Foo(); }
100
+ // / namespace C {
101
+ // / using namespace A;
102
+ // / using namespace B;
103
+ // / }
104
+ // / void test() {
105
+ // / C::Foo(); // error: tag 'A::Foo' is hidden by an object in a
106
+ // / // different namespace
107
+ // / }
108
+ // / @endcode
109
+ AmbiguousTagHiding
110
+ };
111
+
39
112
// / Represents the results of name lookup.
40
113
// /
41
114
// / An instance of the LookupResult class captures the results of a
@@ -73,79 +146,6 @@ class LookupResult {
73
146
Ambiguous
74
147
};
75
148
76
- enum AmbiguityKind {
77
- // / Name lookup results in an ambiguity because multiple
78
- // / entities that meet the lookup criteria were found in
79
- // / subobjects of different types. For example:
80
- // / @code
81
- // / struct A { void f(int); }
82
- // / struct B { void f(double); }
83
- // / struct C : A, B { };
84
- // / void test(C c) {
85
- // / c.f(0); // error: A::f and B::f come from subobjects of different
86
- // / // types. overload resolution is not performed.
87
- // / }
88
- // / @endcode
89
- AmbiguousBaseSubobjectTypes,
90
-
91
- // / Name lookup results in an ambiguity because multiple
92
- // / nonstatic entities that meet the lookup criteria were found
93
- // / in different subobjects of the same type. For example:
94
- // / @code
95
- // / struct A { int x; };
96
- // / struct B : A { };
97
- // / struct C : A { };
98
- // / struct D : B, C { };
99
- // / int test(D d) {
100
- // / return d.x; // error: 'x' is found in two A subobjects (of B and C)
101
- // / }
102
- // / @endcode
103
- AmbiguousBaseSubobjects,
104
-
105
- // / Name lookup results in an ambiguity because multiple definitions
106
- // / of entity that meet the lookup criteria were found in different
107
- // / declaration contexts.
108
- // / @code
109
- // / namespace A {
110
- // / int i;
111
- // / namespace B { int i; }
112
- // / int test() {
113
- // / using namespace B;
114
- // / return i; // error 'i' is found in namespace A and A::B
115
- // / }
116
- // / }
117
- // / @endcode
118
- AmbiguousReference,
119
-
120
- // / Name lookup results in an ambiguity because multiple placeholder
121
- // / variables were found in the same scope.
122
- // / @code
123
- // / void f() {
124
- // / int _ = 0;
125
- // / int _ = 0;
126
- // / return _; // ambiguous use of placeholder variable
127
- // / }
128
- // / @endcode
129
- AmbiguousReferenceToPlaceholderVariable,
130
-
131
- // / Name lookup results in an ambiguity because an entity with a
132
- // / tag name was hidden by an entity with an ordinary name from
133
- // / a different context.
134
- // / @code
135
- // / namespace A { struct Foo {}; }
136
- // / namespace B { void Foo(); }
137
- // / namespace C {
138
- // / using namespace A;
139
- // / using namespace B;
140
- // / }
141
- // / void test() {
142
- // / C::Foo(); // error: tag 'A::Foo' is hidden by an object in a
143
- // / // different namespace
144
- // / }
145
- // / @endcode
146
- AmbiguousTagHiding
147
- };
148
-
149
149
// / A little identifier for flagging temporary lookup results.
150
150
enum TemporaryToken {
151
151
Temporary
@@ -346,7 +346,7 @@ class LookupResult {
346
346
return ResultKind;
347
347
}
348
348
349
- AmbiguityKind getAmbiguityKind () const {
349
+ LookupAmbiguityKind getAmbiguityKind () const {
350
350
assert (isAmbiguous ());
351
351
return Ambiguity;
352
352
}
@@ -532,7 +532,7 @@ class LookupResult {
532
532
Paths = nullptr ;
533
533
}
534
534
} else {
535
- std::optional<AmbiguityKind > SavedAK;
535
+ std::optional<LookupAmbiguityKind > SavedAK;
536
536
bool WasAmbiguous = false ;
537
537
if (ResultKind == Ambiguous) {
538
538
SavedAK = Ambiguity;
@@ -598,7 +598,7 @@ class LookupResult {
598
598
// / different contexts and a tag decl was hidden by an ordinary
599
599
// / decl in a different context.
600
600
void setAmbiguousQualifiedTagHiding () {
601
- setAmbiguous (AmbiguousTagHiding);
601
+ setAmbiguous (LookupAmbiguityKind:: AmbiguousTagHiding);
602
602
}
603
603
604
604
// / Clears out any current state.
@@ -769,7 +769,7 @@ class LookupResult {
769
769
getSema ().DiagnoseAmbiguousLookup (*this );
770
770
}
771
771
772
- void setAmbiguous (AmbiguityKind AK) {
772
+ void setAmbiguous (LookupAmbiguityKind AK) {
773
773
ResultKind = Ambiguous;
774
774
Ambiguity = AK;
775
775
}
@@ -792,7 +792,7 @@ class LookupResult {
792
792
LookupResultKind ResultKind = NotFound;
793
793
// ill-defined unless ambiguous. Still need to be initialized it will be
794
794
// copied/moved.
795
- AmbiguityKind Ambiguity = {};
795
+ LookupAmbiguityKind Ambiguity = {};
796
796
UnresolvedSet<8 > Decls;
797
797
CXXBasePaths *Paths = nullptr ;
798
798
CXXRecordDecl *NamingClass = nullptr ;
0 commit comments