clang  3.7.0
Lookup.h
Go to the documentation of this file.
1 //===--- Lookup.h - Classes for name lookup ---------------------*- C++ -*-===//
2 //
3 // The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 // This file defines the LookupResult class, which is integral to
11 // Sema's name-lookup subsystem.
12 //
13 //===----------------------------------------------------------------------===//
14 
15 #ifndef LLVM_CLANG_SEMA_LOOKUP_H
16 #define LLVM_CLANG_SEMA_LOOKUP_H
17 
18 #include "clang/AST/DeclCXX.h"
19 #include "clang/Sema/Sema.h"
20 
21 namespace clang {
22 
23 /// @brief Represents the results of name lookup.
24 ///
25 /// An instance of the LookupResult class captures the results of a
26 /// single name lookup, which can return no result (nothing found),
27 /// a single declaration, a set of overloaded functions, or an
28 /// ambiguity. Use the getKind() method to determine which of these
29 /// results occurred for a given lookup.
30 class LookupResult {
31 public:
33  /// @brief No entity found met the criteria.
34  NotFound = 0,
35 
36  /// @brief No entity found met the criteria within the current
37  /// instantiation,, but there were dependent base classes of the
38  /// current instantiation that could not be searched.
40 
41  /// @brief Name lookup found a single declaration that met the
42  /// criteria. getFoundDecl() will return this declaration.
44 
45  /// @brief Name lookup found a set of overloaded functions that
46  /// met the criteria.
48 
49  /// @brief Name lookup found an unresolvable value declaration
50  /// and cannot yet complete. This only happens in C++ dependent
51  /// contexts with dependent using declarations.
53 
54  /// @brief Name lookup results in an ambiguity; use
55  /// getAmbiguityKind to figure out what kind of ambiguity
56  /// we have.
58  };
59 
61  /// Name lookup results in an ambiguity because multiple
62  /// entities that meet the lookup criteria were found in
63  /// subobjects of different types. For example:
64  /// @code
65  /// struct A { void f(int); }
66  /// struct B { void f(double); }
67  /// struct C : A, B { };
68  /// void test(C c) {
69  /// c.f(0); // error: A::f and B::f come from subobjects of different
70  /// // types. overload resolution is not performed.
71  /// }
72  /// @endcode
74 
75  /// Name lookup results in an ambiguity because multiple
76  /// nonstatic entities that meet the lookup criteria were found
77  /// in different subobjects of the same type. For example:
78  /// @code
79  /// struct A { int x; };
80  /// struct B : A { };
81  /// struct C : A { };
82  /// struct D : B, C { };
83  /// int test(D d) {
84  /// return d.x; // error: 'x' is found in two A subobjects (of B and C)
85  /// }
86  /// @endcode
88 
89  /// Name lookup results in an ambiguity because multiple definitions
90  /// of entity that meet the lookup criteria were found in different
91  /// declaration contexts.
92  /// @code
93  /// namespace A {
94  /// int i;
95  /// namespace B { int i; }
96  /// int test() {
97  /// using namespace B;
98  /// return i; // error 'i' is found in namespace A and A::B
99  /// }
100  /// }
101  /// @endcode
103 
104  /// Name lookup results in an ambiguity because an entity with a
105  /// tag name was hidden by an entity with an ordinary name from
106  /// a different context.
107  /// @code
108  /// namespace A { struct Foo {}; }
109  /// namespace B { void Foo(); }
110  /// namespace C {
111  /// using namespace A;
112  /// using namespace B;
113  /// }
114  /// void test() {
115  /// C::Foo(); // error: tag 'A::Foo' is hidden by an object in a
116  /// // different namespace
117  /// }
118  /// @endcode
120  };
121 
122  /// A little identifier for flagging temporary lookup results.
125  };
126 
128 
129  LookupResult(Sema &SemaRef, const DeclarationNameInfo &NameInfo,
130  Sema::LookupNameKind LookupKind,
132  : ResultKind(NotFound),
133  Paths(nullptr),
134  NamingClass(nullptr),
135  SemaPtr(&SemaRef),
136  NameInfo(NameInfo),
137  LookupKind(LookupKind),
138  IDNS(0),
139  Redecl(Redecl != Sema::NotForRedeclaration),
140  HideTags(true),
141  Diagnose(Redecl == Sema::NotForRedeclaration),
142  AllowHidden(Redecl == Sema::ForRedeclaration),
143  Shadowed(false)
144  {
145  configure();
146  }
147 
148  // TODO: consider whether this constructor should be restricted to take
149  // as input a const IndentifierInfo* (instead of Name),
150  // forcing other cases towards the constructor taking a DNInfo.
152  SourceLocation NameLoc, Sema::LookupNameKind LookupKind,
154  : ResultKind(NotFound),
155  Paths(nullptr),
156  NamingClass(nullptr),
157  SemaPtr(&SemaRef),
158  NameInfo(Name, NameLoc),
159  LookupKind(LookupKind),
160  IDNS(0),
161  Redecl(Redecl != Sema::NotForRedeclaration),
162  HideTags(true),
163  Diagnose(Redecl == Sema::NotForRedeclaration),
164  AllowHidden(Redecl == Sema::ForRedeclaration),
165  Shadowed(false)
166  {
167  configure();
168  }
169 
170  /// Creates a temporary lookup result, initializing its core data
171  /// using the information from another result. Diagnostics are always
172  /// disabled.
174  : ResultKind(NotFound),
175  Paths(nullptr),
176  NamingClass(nullptr),
177  SemaPtr(Other.SemaPtr),
178  NameInfo(Other.NameInfo),
179  LookupKind(Other.LookupKind),
180  IDNS(Other.IDNS),
181  Redecl(Other.Redecl),
182  HideTags(Other.HideTags),
183  Diagnose(false),
184  AllowHidden(Other.AllowHidden),
185  Shadowed(false)
186  {}
187 
189  if (Diagnose) diagnose();
190  if (Paths) deletePaths(Paths);
191  }
192 
193  /// Gets the name info to look up.
195  return NameInfo;
196  }
197 
198  /// \brief Sets the name info to look up.
199  void setLookupNameInfo(const DeclarationNameInfo &NameInfo) {
200  this->NameInfo = NameInfo;
201  }
202 
203  /// Gets the name to look up.
205  return NameInfo.getName();
206  }
207 
208  /// \brief Sets the name to look up.
210  NameInfo.setName(Name);
211  }
212 
213  /// Gets the kind of lookup to perform.
215  return LookupKind;
216  }
217 
218  /// True if this lookup is just looking for an existing declaration.
219  bool isForRedeclaration() const {
220  return Redecl;
221  }
222 
223  /// \brief Specify whether hidden declarations are visible, e.g.,
224  /// for recovery reasons.
225  void setAllowHidden(bool AH) {
226  AllowHidden = AH;
227  }
228 
229  /// \brief Determine whether this lookup is permitted to see hidden
230  /// declarations, such as those in modules that have not yet been imported.
232  return AllowHidden || LookupKind == Sema::LookupTagName;
233  }
234 
235  /// Sets whether tag declarations should be hidden by non-tag
236  /// declarations during resolution. The default is true.
237  void setHideTags(bool Hide) {
238  HideTags = Hide;
239  }
240 
241  bool isAmbiguous() const {
242  return getResultKind() == Ambiguous;
243  }
244 
245  /// Determines if this names a single result which is not an
246  /// unresolved value using decl. If so, it is safe to call
247  /// getFoundDecl().
248  bool isSingleResult() const {
249  return getResultKind() == Found;
250  }
251 
252  /// Determines if the results are overloaded.
253  bool isOverloadedResult() const {
254  return getResultKind() == FoundOverloaded;
255  }
256 
257  bool isUnresolvableResult() const {
259  }
260 
262  assert(sanity());
263  return ResultKind;
264  }
265 
267  assert(isAmbiguous());
268  return Ambiguity;
269  }
270 
272  return Decls;
273  }
274 
275  iterator begin() const { return iterator(Decls.begin()); }
276  iterator end() const { return iterator(Decls.end()); }
277 
278  /// \brief Return true if no decls were found
279  bool empty() const { return Decls.empty(); }
280 
281  /// \brief Return the base paths structure that's associated with
282  /// these results, or null if none is.
284  return Paths;
285  }
286 
287  /// \brief Determine whether the given declaration is visible to the
288  /// program.
289  static bool isVisible(Sema &SemaRef, NamedDecl *D) {
290  // If this declaration is not hidden, it's visible.
291  if (!D->isHidden())
292  return true;
293 
294  // During template instantiation, we can refer to hidden declarations, if
295  // they were visible in any module along the path of instantiation.
296  return isVisibleSlow(SemaRef, D);
297  }
298 
299  /// \brief Retrieve the accepted (re)declaration of the given declaration,
300  /// if there is one.
302  if (!D->isInIdentifierNamespace(IDNS))
303  return nullptr;
304 
306  return D;
307 
308  return getAcceptableDeclSlow(D);
309  }
310 
311 private:
312  static bool isVisibleSlow(Sema &SemaRef, NamedDecl *D);
313  NamedDecl *getAcceptableDeclSlow(NamedDecl *D) const;
314 
315 public:
316  /// \brief Returns the identifier namespace mask for this lookup.
317  unsigned getIdentifierNamespace() const {
318  return IDNS;
319  }
320 
321  /// \brief Returns whether these results arose from performing a
322  /// lookup into a class.
323  bool isClassLookup() const {
324  return NamingClass != nullptr;
325  }
326 
327  /// \brief Returns the 'naming class' for this lookup, i.e. the
328  /// class which was looked into to find these results.
329  ///
330  /// C++0x [class.access.base]p5:
331  /// The access to a member is affected by the class in which the
332  /// member is named. This naming class is the class in which the
333  /// member name was looked up and found. [Note: this class can be
334  /// explicit, e.g., when a qualified-id is used, or implicit,
335  /// e.g., when a class member access operator (5.2.5) is used
336  /// (including cases where an implicit "this->" is added). If both
337  /// a class member access operator and a qualified-id are used to
338  /// name the member (as in p->T::m), the class naming the member
339  /// is the class named by the nested-name-specifier of the
340  /// qualified-id (that is, T). -- end note ]
341  ///
342  /// This is set by the lookup routines when they find results in a class.
344  return NamingClass;
345  }
346 
347  /// \brief Sets the 'naming class' for this lookup.
349  NamingClass = Record;
350  }
351 
352  /// \brief Returns the base object type associated with this lookup;
353  /// important for [class.protected]. Most lookups do not have an
354  /// associated base object.
356  return BaseObjectType;
357  }
358 
359  /// \brief Sets the base object type for this lookup.
361  BaseObjectType = T;
362  }
363 
364  /// \brief Add a declaration to these results with its natural access.
365  /// Does not test the acceptance criteria.
366  void addDecl(NamedDecl *D) {
367  addDecl(D, D->getAccess());
368  }
369 
370  /// \brief Add a declaration to these results with the given access.
371  /// Does not test the acceptance criteria.
373  Decls.addDecl(D, AS);
374  ResultKind = Found;
375  }
376 
377  /// \brief Add all the declarations from another set of lookup
378  /// results.
379  void addAllDecls(const LookupResult &Other) {
380  Decls.append(Other.Decls.begin(), Other.Decls.end());
381  ResultKind = Found;
382  }
383 
384  /// \brief Determine whether no result was found because we could not
385  /// search into dependent base classes of the current instantiation.
387  return ResultKind == NotFoundInCurrentInstantiation;
388  }
389 
390  /// \brief Note that while no result was found in the current instantiation,
391  /// there were dependent base classes that could not be searched.
393  assert(ResultKind == NotFound && Decls.empty());
394  ResultKind = NotFoundInCurrentInstantiation;
395  }
396 
397  /// \brief Determine whether the lookup result was shadowed by some other
398  /// declaration that lookup ignored.
399  bool isShadowed() const { return Shadowed; }
400 
401  /// \brief Note that we found and ignored a declaration while performing
402  /// lookup.
403  void setShadowed() { Shadowed = true; }
404 
405  /// \brief Resolves the result kind of the lookup, possibly hiding
406  /// decls.
407  ///
408  /// This should be called in any environment where lookup might
409  /// generate multiple lookup results.
410  void resolveKind();
411 
412  /// \brief Re-resolves the result kind of the lookup after a set of
413  /// removals has been performed.
415  if (Decls.empty()) {
416  if (ResultKind != NotFoundInCurrentInstantiation)
417  ResultKind = NotFound;
418 
419  if (Paths) {
420  deletePaths(Paths);
421  Paths = nullptr;
422  }
423  } else {
424  AmbiguityKind SavedAK;
425  bool WasAmbiguous = false;
426  if (ResultKind == Ambiguous) {
427  SavedAK = Ambiguity;
428  WasAmbiguous = true;
429  }
430  ResultKind = Found;
431  resolveKind();
432 
433  // If we didn't make the lookup unambiguous, restore the old
434  // ambiguity kind.
435  if (ResultKind == Ambiguous) {
436  (void)WasAmbiguous;
437  assert(WasAmbiguous);
438  Ambiguity = SavedAK;
439  } else if (Paths) {
440  deletePaths(Paths);
441  Paths = nullptr;
442  }
443  }
444  }
445 
446  template <class DeclClass>
447  DeclClass *getAsSingle() const {
448  if (getResultKind() != Found) return nullptr;
449  return dyn_cast<DeclClass>(getFoundDecl());
450  }
451 
452  /// \brief Fetch the unique decl found by this lookup. Asserts
453  /// that one was found.
454  ///
455  /// This is intended for users who have examined the result kind
456  /// and are certain that there is only one result.
458  assert(getResultKind() == Found
459  && "getFoundDecl called on non-unique result");
460  return (*begin())->getUnderlyingDecl();
461  }
462 
463  /// Fetches a representative decl. Useful for lazy diagnostics.
465  assert(!Decls.empty() && "cannot get representative of empty set");
466  return *begin();
467  }
468 
469  /// \brief Asks if the result is a single tag decl.
470  bool isSingleTagDecl() const {
471  return getResultKind() == Found && isa<TagDecl>(getFoundDecl());
472  }
473 
474  /// \brief Make these results show that the name was found in
475  /// base classes of different types.
476  ///
477  /// The given paths object is copied and invalidated.
479 
480  /// \brief Make these results show that the name was found in
481  /// distinct base classes of the same type.
482  ///
483  /// The given paths object is copied and invalidated.
485 
486  /// \brief Make these results show that the name was found in
487  /// different contexts and a tag decl was hidden by an ordinary
488  /// decl in a different context.
490  setAmbiguous(AmbiguousTagHiding);
491  }
492 
493  /// \brief Clears out any current state.
494  void clear() {
495  ResultKind = NotFound;
496  Decls.clear();
497  if (Paths) deletePaths(Paths);
498  Paths = nullptr;
499  NamingClass = nullptr;
500  Shadowed = false;
501  }
502 
503  /// \brief Clears out any current state and re-initializes for a
504  /// different kind of lookup.
506  clear();
507  LookupKind = Kind;
508  configure();
509  }
510 
511  /// \brief Change this lookup's redeclaration kind.
513  Redecl = RK;
514  AllowHidden = (RK == Sema::ForRedeclaration);
515  configure();
516  }
517 
518  void print(raw_ostream &);
519 
520  /// Suppress the diagnostics that would normally fire because of this
521  /// lookup. This happens during (e.g.) redeclaration lookups.
523  Diagnose = false;
524  }
525 
526  /// Determines whether this lookup is suppressing diagnostics.
528  return !Diagnose;
529  }
530 
531  /// Sets a 'context' source range.
533  NameContextRange = SR;
534  }
535 
536  /// Gets the source range of the context of this name; for C++
537  /// qualified lookups, this is the source range of the scope
538  /// specifier.
540  return NameContextRange;
541  }
542 
543  /// Gets the location of the identifier. This isn't always defined:
544  /// sometimes we're doing lookups on synthesized names.
546  return NameInfo.getLoc();
547  }
548 
549  /// \brief Get the Sema object that this lookup result is searching
550  /// with.
551  Sema &getSema() const { return *SemaPtr; }
552 
553  /// A class for iterating through a result set and possibly
554  /// filtering out results. The results returned are possibly
555  /// sugared.
556  class Filter {
557  LookupResult &Results;
559  bool Changed;
560  bool CalledDone;
561 
562  friend class LookupResult;
563  Filter(LookupResult &Results)
564  : Results(Results), I(Results.begin()), Changed(false), CalledDone(false)
565  {}
566 
567  public:
569  assert(CalledDone &&
570  "LookupResult::Filter destroyed without done() call");
571  }
572 
573  bool hasNext() const {
574  return I != Results.end();
575  }
576 
578  assert(I != Results.end() && "next() called on empty filter");
579  return *I++;
580  }
581 
582  /// Restart the iteration.
583  void restart() {
584  I = Results.begin();
585  }
586 
587  /// Erase the last element returned from this iterator.
588  void erase() {
589  Results.Decls.erase(--I);
590  Changed = true;
591  }
592 
593  /// Replaces the current entry with the given one, preserving the
594  /// access bits.
595  void replace(NamedDecl *D) {
596  Results.Decls.replace(I-1, D);
597  Changed = true;
598  }
599 
600  /// Replaces the current entry with the given one.
602  Results.Decls.replace(I-1, D, AS);
603  Changed = true;
604  }
605 
606  void done() {
607  assert(!CalledDone && "done() called twice");
608  CalledDone = true;
609 
610  if (Changed)
611  Results.resolveKindAfterFilter();
612  }
613  };
614 
615  /// Create a filter for this result set.
617  return Filter(*this);
618  }
619 
620  void setFindLocalExtern(bool FindLocalExtern) {
621  if (FindLocalExtern)
622  IDNS |= Decl::IDNS_LocalExtern;
623  else
624  IDNS &= ~Decl::IDNS_LocalExtern;
625  }
626 
627 private:
628  void diagnose() {
629  if (isAmbiguous())
631  else if (isClassLookup() && getSema().getLangOpts().AccessControl)
632  getSema().CheckLookupAccess(*this);
633  }
634 
635  void setAmbiguous(AmbiguityKind AK) {
636  ResultKind = Ambiguous;
637  Ambiguity = AK;
638  }
639 
640  void addDeclsFromBasePaths(const CXXBasePaths &P);
641  void configure();
642 
643  // Sanity checks.
644  bool sanity() const;
645 
646  bool sanityCheckUnresolved() const {
647  for (iterator I = begin(), E = end(); I != E; ++I)
648  if (isa<UnresolvedUsingValueDecl>((*I)->getUnderlyingDecl()))
649  return true;
650  return false;
651  }
652 
653  static void deletePaths(CXXBasePaths *);
654 
655  // Results.
656  LookupResultKind ResultKind;
657  AmbiguityKind Ambiguity; // ill-defined unless ambiguous
658  UnresolvedSet<8> Decls;
659  CXXBasePaths *Paths;
660  CXXRecordDecl *NamingClass;
661  QualType BaseObjectType;
662 
663  // Parameters.
664  Sema *SemaPtr;
665  DeclarationNameInfo NameInfo;
666  SourceRange NameContextRange;
667  Sema::LookupNameKind LookupKind;
668  unsigned IDNS; // set by configure()
669 
670  bool Redecl;
671 
672  /// \brief True if tag declarations should be hidden if non-tags
673  /// are present
674  bool HideTags;
675 
676  bool Diagnose;
677 
678  /// \brief True if we should allow hidden declarations to be 'visible'.
679  bool AllowHidden;
680 
681  /// \brief True if the found declarations were shadowed by some other
682  /// declaration that we skipped. This only happens when \c LookupKind
683  /// is \c LookupRedeclarationWithLinkage.
684  bool Shadowed;
685 };
686 
687 /// \brief Consumes visible declarations found when searching for
688 /// all visible names within a given scope or context.
689 ///
690 /// This abstract class is meant to be subclassed by clients of \c
691 /// Sema::LookupVisibleDecls(), each of which should override the \c
692 /// FoundDecl() function to process declarations as they are found.
694 public:
695  /// \brief Destroys the visible declaration consumer.
696  virtual ~VisibleDeclConsumer();
697 
698  /// \brief Determine whether hidden declarations (from unimported
699  /// modules) should be given to this consumer. By default, they
700  /// are not included.
701  virtual bool includeHiddenDecls() const;
702 
703  /// \brief Invoked each time \p Sema::LookupVisibleDecls() finds a
704  /// declaration visible from the current scope or context.
705  ///
706  /// \param ND the declaration found.
707  ///
708  /// \param Hiding a declaration that hides the declaration \p ND,
709  /// or NULL if no such declaration exists.
710  ///
711  /// \param Ctx the original context from which the lookup started.
712  ///
713  /// \param InBaseClass whether this declaration was found in base
714  /// class of the context we searched.
715  virtual void FoundDecl(NamedDecl *ND, NamedDecl *Hiding, DeclContext *Ctx,
716  bool InBaseClass) = 0;
717 };
718 
719 /// \brief A class for storing results from argument-dependent lookup.
720 class ADLResult {
721 private:
722  /// A map from canonical decls to the 'most recent' decl.
723  llvm::DenseMap<NamedDecl*, NamedDecl*> Decls;
724 
725 public:
726  /// Adds a new ADL candidate to this map.
727  void insert(NamedDecl *D);
728 
729  /// Removes any data associated with a given decl.
730  void erase(NamedDecl *D) {
731  Decls.erase(cast<NamedDecl>(D->getCanonicalDecl()));
732  }
733 
734  class iterator
735  : public llvm::iterator_adaptor_base<
736  iterator, llvm::DenseMap<NamedDecl *, NamedDecl *>::iterator,
737  std::forward_iterator_tag, NamedDecl *> {
738  friend class ADLResult;
739 
740  iterator(llvm::DenseMap<NamedDecl *, NamedDecl *>::iterator Iter)
741  : iterator_adaptor_base(std::move(Iter)) {}
742 
743  public:
744  iterator() {}
745 
746  value_type operator*() const { return I->second; }
747  };
748 
749  iterator begin() { return iterator(Decls.begin()); }
750  iterator end() { return iterator(Decls.end()); }
751 };
752 
753 }
754 
755 #endif
Name lookup found a set of overloaded functions that met the criteria.
Definition: Lookup.h:47
void restart()
Restart the iteration.
Definition: Lookup.h:583
bool isSuppressingDiagnostics() const
Determines whether this lookup is suppressing diagnostics.
Definition: Lookup.h:527
UnresolvedSetImpl::iterator iterator
Definition: Lookup.h:127
void setLookupName(DeclarationName Name)
Sets the name to look up.
Definition: Lookup.h:209
DeclClass * getAsSingle() const
Definition: Lookup.h:447
NamedDecl * getRepresentativeDecl() const
Fetches a representative decl. Useful for lazy diagnostics.
Definition: Lookup.h:464
Filter makeFilter()
Create a filter for this result set.
Definition: Lookup.h:616
void erase()
Erase the last element returned from this iterator.
Definition: Lookup.h:588
iterator begin() const
Definition: Lookup.h:275
RedeclarationKind
Specifies whether (or how) name lookup is being performed for a redeclaration (vs. a reference).
Definition: Sema.h:2625
AccessSpecifier
A C++ access specifier (public, private, protected), plus the special value "none" which means differ...
Definition: Specifiers.h:83
bool isHiddenDeclarationVisible() const
Determine whether this lookup is permitted to see hidden declarations, such as those in modules that ...
Definition: Lookup.h:231
void resolveKindAfterFilter()
Re-resolves the result kind of the lookup after a set of removals has been performed.
Definition: Lookup.h:414
Consumes visible declarations found when searching for all visible names within a given scope or cont...
Definition: Lookup.h:693
QualType getBaseObjectType() const
Returns the base object type associated with this lookup; important for [class.protected]. Most lookups do not have an associated base object.
Definition: Lookup.h:355
bool hasNext() const
Definition: Lookup.h:573
AccessSpecifier getAccess() const
Definition: DeclBase.h:416
bool isUnresolvableResult() const
Definition: Lookup.h:257
void CheckLookupAccess(const LookupResult &R)
Checks access to all the declarations in the given result set.
void setNotFoundInCurrentInstantiation()
Note that while no result was found in the current instantiation, there were dependent base classes t...
Definition: Lookup.h:392
bool isSingleTagDecl() const
Asks if the result is a single tag decl.
Definition: Lookup.h:470
DeclarationName getName() const
getName - Returns the embedded declaration name.
iterator end() const
Definition: Lookup.h:276
Name lookup results in an ambiguity; use getAmbiguityKind to figure out what kind of ambiguity we hav...
Definition: Lookup.h:57
void replace(NamedDecl *D)
Definition: Lookup.h:595
LookupResult(TemporaryToken _, const LookupResult &Other)
Definition: Lookup.h:173
void setAmbiguousBaseSubobjectTypes(CXXBasePaths &P)
Make these results show that the name was found in base classes of different types.
Definition: SemaLookup.cpp:499
bool isInIdentifierNamespace(unsigned NS) const
Definition: DeclBase.h:674
SourceRange getContextRange() const
Definition: Lookup.h:539
void setName(DeclarationName N)
setName - Sets the embedded declaration name.
bool isForRedeclaration() const
True if this lookup is just looking for an existing declaration.
Definition: Lookup.h:219
No entity found met the criteria within the current instantiation,, but there were dependent base cla...
Definition: Lookup.h:39
void resolveKind()
Resolves the result kind of the lookup, possibly hiding decls.
Definition: SemaLookup.cpp:358
Represents the results of name lookup.
Definition: Lookup.h:30
void setAmbiguousBaseSubobjects(CXXBasePaths &P)
Make these results show that the name was found in distinct base classes of the same type...
Definition: SemaLookup.cpp:491
AmbiguityKind getAmbiguityKind() const
Definition: Lookup.h:266
virtual bool includeHiddenDecls() const
Determine whether hidden declarations (from unimported modules) should be given to this consumer...
A set of unresolved declarations.
Definition: UnresolvedSet.h:55
void DiagnoseAmbiguousLookup(LookupResult &Result)
Produce a diagnostic describing the ambiguity that resulted from name lookup.
void append(iterator I, iterator E)
CXXBasePaths * getBasePaths() const
Return the base paths structure that's associated with these results, or null if none is...
Definition: Lookup.h:283
void setRedeclarationKind(Sema::RedeclarationKind RK)
Change this lookup's redeclaration kind.
Definition: Lookup.h:512
void addDecl(NamedDecl *D)
Add a declaration to these results with its natural access. Does not test the acceptance criteria...
Definition: Lookup.h:366
virtual Decl * getCanonicalDecl()
Retrieves the "canonical" declaration of the given declaration.
Definition: DeclBase.h:733
The lookup results will be used for redeclaration of a name, if an entity by that name already exists...
Definition: Sema.h:2631
const UnresolvedSetImpl & asUnresolvedSet() const
Definition: Lookup.h:271
SourceLocation getLoc() const
getLoc - Returns the main location of the declaration name.
AnnotatingParser & P
Sema - This implements semantic analysis and AST building for C.
Definition: Sema.h:258
void setNamingClass(CXXRecordDecl *Record)
Sets the 'naming class' for this lookup.
Definition: Lookup.h:348
value_type operator*() const
Definition: Lookup.h:746
virtual void FoundDecl(NamedDecl *ND, NamedDecl *Hiding, DeclContext *Ctx, bool InBaseClass)=0
Invoked each time Sema::LookupVisibleDecls() finds a declaration visible from the current scope or co...
const DeclarationNameInfo & getLookupNameInfo() const
Gets the name info to look up.
Definition: Lookup.h:194
void erase(NamedDecl *D)
Removes any data associated with a given decl.
Definition: Lookup.h:730
DeclarationName getLookupName() const
Gets the name to look up.
Definition: Lookup.h:204
LookupNameKind
Describes the kind of name lookup to perform.
Definition: Sema.h:2578
CXXRecordDecl * getNamingClass() const
Returns the 'naming class' for this lookup, i.e. the class which was looked into to find these result...
Definition: Lookup.h:343
void setHideTags(bool Hide)
Definition: Lookup.h:237
SourceLocation getNameLoc() const
Definition: Lookup.h:545
NamedDecl * getFoundDecl() const
Fetch the unique decl found by this lookup. Asserts that one was found.
Definition: Lookup.h:457
void erase(unsigned I)
NamedDecl * getAcceptableDecl(NamedDecl *D) const
Retrieve the accepted (re)declaration of the given declaration, if there is one.
Definition: Lookup.h:301
LookupResult(Sema &SemaRef, DeclarationName Name, SourceLocation NameLoc, Sema::LookupNameKind LookupKind, Sema::RedeclarationKind Redecl=Sema::NotForRedeclaration)
Definition: Lookup.h:151
Sema & getSema() const
Get the Sema object that this lookup result is searching with.
Definition: Lookup.h:551
bool replace(const NamedDecl *Old, NamedDecl *New)
Definition: UnresolvedSet.h:88
bool isAmbiguous() const
Definition: Lookup.h:241
TemporaryToken
A little identifier for flagging temporary lookup results.
Definition: Lookup.h:123
#define false
Definition: stdbool.h:33
Kind
Encodes a location in the source. The SourceManager can decode this to get at the full include stack...
bool isShadowed() const
Determine whether the lookup result was shadowed by some other declaration that lookup ignored...
Definition: Lookup.h:399
Name lookup found an unresolvable value declaration and cannot yet complete. This only happens in C++...
Definition: Lookup.h:52
void addDecl(NamedDecl *D)
Definition: UnresolvedSet.h:77
No entity found met the criteria.
Definition: Lookup.h:34
NamedDecl * next()
Definition: Lookup.h:577
A class for storing results from argument-dependent lookup.
Definition: Lookup.h:720
void addDecl(NamedDecl *D, AccessSpecifier AS)
Add a declaration to these results with the given access. Does not test the acceptance criteria...
Definition: Lookup.h:372
iterator begin()
Definition: Lookup.h:749
void setAllowHidden(bool AH)
Specify whether hidden declarations are visible, e.g., for recovery reasons.
Definition: Lookup.h:225
LookupResult(Sema &SemaRef, const DeclarationNameInfo &NameInfo, Sema::LookupNameKind LookupKind, Sema::RedeclarationKind Redecl=Sema::NotForRedeclaration)
Definition: Lookup.h:129
void setContextRange(SourceRange SR)
Sets a 'context' source range.
Definition: Lookup.h:532
Sema::LookupNameKind getLookupKind() const
Gets the kind of lookup to perform.
Definition: Lookup.h:214
unsigned getIdentifierNamespace() const
Returns the identifier namespace mask for this lookup.
Definition: Lookup.h:317
void replace(NamedDecl *D, AccessSpecifier AS)
Replaces the current entry with the given one.
Definition: Lookup.h:601
void setAmbiguousQualifiedTagHiding()
Make these results show that the name was found in different contexts and a tag decl was hidden by an...
Definition: Lookup.h:489
void insert(NamedDecl *D)
Adds a new ADL candidate to this map.
void setShadowed()
Note that we found and ignored a declaration while performing lookup.
Definition: Lookup.h:403
bool isClassLookup() const
Returns whether these results arose from performing a lookup into a class.
Definition: Lookup.h:323
bool isSingleResult() const
Definition: Lookup.h:248
bool empty() const
Return true if no decls were found.
Definition: Lookup.h:279
Name lookup found a single declaration that met the criteria. getFoundDecl() will return this declara...
Definition: Lookup.h:43
The lookup is a reference to this name that is not for the purpose of redeclaring the name...
Definition: Sema.h:2628
bool wasNotFoundInCurrentInstantiation() const
Determine whether no result was found because we could not search into dependent base classes of the ...
Definition: Lookup.h:386
Defines the C++ Decl subclasses, other than those for templates (found in DeclTemplate.h) and friends (in DeclFriend.h).
Represents a C++ struct/union/class.
Definition: DeclCXX.h:285
void addAllDecls(const LookupResult &Other)
Add all the declarations from another set of lookup results.
Definition: Lookup.h:379
void print(raw_ostream &)
Definition: SemaLookup.cpp:507
LookupResultKind getResultKind() const
Definition: Lookup.h:261
virtual ~VisibleDeclConsumer()
Destroys the visible declaration consumer.
iterator end()
Definition: Lookup.h:750
void setBaseObjectType(QualType T)
Sets the base object type for this lookup.
Definition: Lookup.h:360
void suppressDiagnostics()
Definition: Lookup.h:522
#define true
Definition: stdbool.h:32
A trivial tuple used to represent a source range.
void clear(Sema::LookupNameKind Kind)
Clears out any current state and re-initializes for a different kind of lookup.
Definition: Lookup.h:505
void setLookupNameInfo(const DeclarationNameInfo &NameInfo)
Sets the name info to look up.
Definition: Lookup.h:199
void clear()
Clears out any current state.
Definition: Lookup.h:494
void setFindLocalExtern(bool FindLocalExtern)
Definition: Lookup.h:620
bool isOverloadedResult() const
Determines if the results are overloaded.
Definition: Lookup.h:253
bool isHidden() const
Determine whether this declaration is hidden from name lookup.
Definition: Decl.h:236
static bool isVisible(Sema &SemaRef, NamedDecl *D)
Determine whether the given declaration is visible to the program.
Definition: Lookup.h:289