@@ -148,20 +148,22 @@ class LookupResult {
148
148
: SemaPtr(&SemaRef), NameInfo(NameInfo), LookupKind(LookupKind),
149
149
Redecl (Redecl != Sema::NotForRedeclaration),
150
150
ExternalRedecl(Redecl == Sema::ForExternalRedeclaration),
151
- Diagnose(Redecl == Sema::NotForRedeclaration) {
151
+ DiagnoseAccess(Redecl == Sema::NotForRedeclaration),
152
+ DiagnoseAmbiguous(Redecl == Sema::NotForRedeclaration) {
152
153
configure ();
153
154
}
154
155
155
156
// TODO: consider whether this constructor should be restricted to take
156
157
// as input a const IdentifierInfo* (instead of Name),
157
158
// forcing other cases towards the constructor taking a DNInfo.
158
- LookupResult (Sema &SemaRef, DeclarationName Name,
159
- SourceLocation NameLoc, Sema::LookupNameKind LookupKind,
159
+ LookupResult (Sema &SemaRef, DeclarationName Name, SourceLocation NameLoc,
160
+ Sema::LookupNameKind LookupKind,
160
161
Sema::RedeclarationKind Redecl = Sema::NotForRedeclaration)
161
162
: SemaPtr(&SemaRef), NameInfo(Name, NameLoc), LookupKind(LookupKind),
162
163
Redecl(Redecl != Sema::NotForRedeclaration),
163
164
ExternalRedecl(Redecl == Sema::ForExternalRedeclaration),
164
- Diagnose(Redecl == Sema::NotForRedeclaration) {
165
+ DiagnoseAccess(Redecl == Sema::NotForRedeclaration),
166
+ DiagnoseAmbiguous(Redecl == Sema::NotForRedeclaration) {
165
167
configure ();
166
168
}
167
169
@@ -192,12 +194,14 @@ class LookupResult {
192
194
Redecl(std::move(Other.Redecl)),
193
195
ExternalRedecl(std::move(Other.ExternalRedecl)),
194
196
HideTags(std::move(Other.HideTags)),
195
- Diagnose(std::move(Other.Diagnose)),
197
+ DiagnoseAccess(std::move(Other.DiagnoseAccess)),
198
+ DiagnoseAmbiguous(std::move(Other.DiagnoseAmbiguous)),
196
199
AllowHidden(std::move(Other.AllowHidden)),
197
200
Shadowed(std::move(Other.Shadowed)),
198
201
TemplateNameLookup(std::move(Other.TemplateNameLookup)) {
199
202
Other.Paths = nullptr ;
200
- Other.Diagnose = false ;
203
+ Other.DiagnoseAccess = false ;
204
+ Other.DiagnoseAmbiguous = false ;
201
205
}
202
206
203
207
LookupResult &operator =(LookupResult &&Other) {
@@ -215,17 +219,22 @@ class LookupResult {
215
219
Redecl = std::move (Other.Redecl );
216
220
ExternalRedecl = std::move (Other.ExternalRedecl );
217
221
HideTags = std::move (Other.HideTags );
218
- Diagnose = std::move (Other.Diagnose );
222
+ DiagnoseAccess = std::move (Other.DiagnoseAccess );
223
+ DiagnoseAmbiguous = std::move (Other.DiagnoseAmbiguous );
219
224
AllowHidden = std::move (Other.AllowHidden );
220
225
Shadowed = std::move (Other.Shadowed );
221
226
TemplateNameLookup = std::move (Other.TemplateNameLookup );
222
227
Other.Paths = nullptr ;
223
- Other.Diagnose = false ;
228
+ Other.DiagnoseAccess = false ;
229
+ Other.DiagnoseAmbiguous = false ;
224
230
return *this ;
225
231
}
226
232
227
233
~LookupResult () {
228
- if (Diagnose) diagnose ();
234
+ if (DiagnoseAccess)
235
+ diagnoseAccess ();
236
+ if (DiagnoseAmbiguous)
237
+ diagnoseAmbiguous ();
229
238
if (Paths) deletePaths (Paths);
230
239
}
231
240
@@ -607,13 +616,20 @@ class LookupResult {
607
616
// / Suppress the diagnostics that would normally fire because of this
608
617
// / lookup. This happens during (e.g.) redeclaration lookups.
609
618
void suppressDiagnostics () {
610
- Diagnose = false ;
619
+ DiagnoseAccess = false ;
620
+ DiagnoseAmbiguous = false ;
611
621
}
612
622
613
- // / Determines whether this lookup is suppressing diagnostics.
614
- bool isSuppressingDiagnostics () const {
615
- return !Diagnose;
616
- }
623
+ // / Suppress the diagnostics that would normally fire because of this
624
+ // / lookup due to access control violations.
625
+ void suppressAccessDiagnostics () { DiagnoseAccess = false ; }
626
+
627
+ // / Determines whether this lookup is suppressing access control diagnostics.
628
+ bool isSuppressingAccessDiagnostics () const { return !DiagnoseAccess; }
629
+
630
+ // / Determines whether this lookup is suppressing ambiguous lookup
631
+ // / diagnostics.
632
+ bool isSuppressingAmbiguousDiagnostics () const { return !DiagnoseAmbiguous; }
617
633
618
634
// / Sets a 'context' source range.
619
635
void setContextRange (SourceRange SR) {
@@ -726,11 +742,14 @@ class LookupResult {
726
742
}
727
743
728
744
private:
729
- void diagnose () {
745
+ void diagnoseAccess () {
746
+ if (isClassLookup () && getSema ().getLangOpts ().AccessControl )
747
+ getSema ().CheckLookupAccess (*this );
748
+ }
749
+
750
+ void diagnoseAmbiguous () {
730
751
if (isAmbiguous ())
731
752
getSema ().DiagnoseAmbiguousLookup (*this );
732
- else if (isClassLookup () && getSema ().getLangOpts ().AccessControl )
733
- getSema ().CheckLookupAccess (*this );
734
753
}
735
754
736
755
void setAmbiguous (AmbiguityKind AK) {
@@ -776,7 +795,8 @@ class LookupResult {
776
795
// / are present
777
796
bool HideTags = true ;
778
797
779
- bool Diagnose = false ;
798
+ bool DiagnoseAccess = false ;
799
+ bool DiagnoseAmbiguous = false ;
780
800
781
801
// / True if we should allow hidden declarations to be 'visible'.
782
802
bool AllowHidden = false ;
0 commit comments