@@ -148,20 +148,22 @@ class LookupResult {
148148 : SemaPtr(&SemaRef), NameInfo(NameInfo), LookupKind(LookupKind),
149149 Redecl (Redecl != Sema::NotForRedeclaration),
150150 ExternalRedecl(Redecl == Sema::ForExternalRedeclaration),
151- Diagnose(Redecl == Sema::NotForRedeclaration) {
151+ DiagnoseAccess(Redecl == Sema::NotForRedeclaration),
152+ DiagnoseAmbiguous(Redecl == Sema::NotForRedeclaration) {
152153 configure ();
153154 }
154155
155156 // TODO: consider whether this constructor should be restricted to take
156157 // as input a const IdentifierInfo* (instead of Name),
157158 // 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,
160161 Sema::RedeclarationKind Redecl = Sema::NotForRedeclaration)
161162 : SemaPtr(&SemaRef), NameInfo(Name, NameLoc), LookupKind(LookupKind),
162163 Redecl(Redecl != Sema::NotForRedeclaration),
163164 ExternalRedecl(Redecl == Sema::ForExternalRedeclaration),
164- Diagnose(Redecl == Sema::NotForRedeclaration) {
165+ DiagnoseAccess(Redecl == Sema::NotForRedeclaration),
166+ DiagnoseAmbiguous(Redecl == Sema::NotForRedeclaration) {
165167 configure ();
166168 }
167169
@@ -192,12 +194,14 @@ class LookupResult {
192194 Redecl(std::move(Other.Redecl)),
193195 ExternalRedecl(std::move(Other.ExternalRedecl)),
194196 HideTags(std::move(Other.HideTags)),
195- Diagnose(std::move(Other.Diagnose)),
197+ DiagnoseAccess(std::move(Other.DiagnoseAccess)),
198+ DiagnoseAmbiguous(std::move(Other.DiagnoseAmbiguous)),
196199 AllowHidden(std::move(Other.AllowHidden)),
197200 Shadowed(std::move(Other.Shadowed)),
198201 TemplateNameLookup(std::move(Other.TemplateNameLookup)) {
199202 Other.Paths = nullptr ;
200- Other.Diagnose = false ;
203+ Other.DiagnoseAccess = false ;
204+ Other.DiagnoseAmbiguous = false ;
201205 }
202206
203207 LookupResult &operator =(LookupResult &&Other) {
@@ -215,17 +219,22 @@ class LookupResult {
215219 Redecl = std::move (Other.Redecl );
216220 ExternalRedecl = std::move (Other.ExternalRedecl );
217221 HideTags = std::move (Other.HideTags );
218- Diagnose = std::move (Other.Diagnose );
222+ DiagnoseAccess = std::move (Other.DiagnoseAccess );
223+ DiagnoseAmbiguous = std::move (Other.DiagnoseAmbiguous );
219224 AllowHidden = std::move (Other.AllowHidden );
220225 Shadowed = std::move (Other.Shadowed );
221226 TemplateNameLookup = std::move (Other.TemplateNameLookup );
222227 Other.Paths = nullptr ;
223- Other.Diagnose = false ;
228+ Other.DiagnoseAccess = false ;
229+ Other.DiagnoseAmbiguous = false ;
224230 return *this ;
225231 }
226232
227233 ~LookupResult () {
228- if (Diagnose) diagnose ();
234+ if (DiagnoseAccess)
235+ diagnoseAccess ();
236+ if (DiagnoseAmbiguous)
237+ diagnoseAmbiguous ();
229238 if (Paths) deletePaths (Paths);
230239 }
231240
@@ -607,13 +616,20 @@ class LookupResult {
607616 // / Suppress the diagnostics that would normally fire because of this
608617 // / lookup. This happens during (e.g.) redeclaration lookups.
609618 void suppressDiagnostics () {
610- Diagnose = false ;
619+ DiagnoseAccess = false ;
620+ DiagnoseAmbiguous = false ;
611621 }
612622
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; }
617633
618634 // / Sets a 'context' source range.
619635 void setContextRange (SourceRange SR) {
@@ -726,11 +742,14 @@ class LookupResult {
726742 }
727743
728744private:
729- void diagnose () {
745+ void diagnoseAccess () {
746+ if (isClassLookup () && getSema ().getLangOpts ().AccessControl )
747+ getSema ().CheckLookupAccess (*this );
748+ }
749+
750+ void diagnoseAmbiguous () {
730751 if (isAmbiguous ())
731752 getSema ().DiagnoseAmbiguousLookup (*this );
732- else if (isClassLookup () && getSema ().getLangOpts ().AccessControl )
733- getSema ().CheckLookupAccess (*this );
734753 }
735754
736755 void setAmbiguous (AmbiguityKind AK) {
@@ -776,7 +795,8 @@ class LookupResult {
776795 // / are present
777796 bool HideTags = true ;
778797
779- bool Diagnose = false ;
798+ bool DiagnoseAccess = false ;
799+ bool DiagnoseAmbiguous = false ;
780800
781801 // / True if we should allow hidden declarations to be 'visible'.
782802 bool AllowHidden = false ;
0 commit comments