]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - include/clang/Sema/Lookup.h
Vendor import of clang trunk r239412:
[FreeBSD/FreeBSD.git] / include / clang / Sema / Lookup.h
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:
32   enum LookupResultKind {
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.
39     NotFoundInCurrentInstantiation,
40     
41     /// @brief Name lookup found a single declaration that met the
42     /// criteria.  getFoundDecl() will return this declaration.
43     Found,
44
45     /// @brief Name lookup found a set of overloaded functions that
46     /// met the criteria.
47     FoundOverloaded,
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.
52     FoundUnresolvedValue,
53
54     /// @brief Name lookup results in an ambiguity; use
55     /// getAmbiguityKind to figure out what kind of ambiguity
56     /// we have.
57     Ambiguous
58   };
59
60   enum AmbiguityKind {
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
73     AmbiguousBaseSubobjectTypes,
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
87     AmbiguousBaseSubobjects,
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
102     AmbiguousReference,
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
119     AmbiguousTagHiding
120   };
121
122   /// A little identifier for flagging temporary lookup results.
123   enum TemporaryToken {
124     Temporary
125   };
126
127   typedef UnresolvedSetImpl::iterator iterator;
128
129   LookupResult(Sema &SemaRef, const DeclarationNameInfo &NameInfo,
130                Sema::LookupNameKind LookupKind,
131                Sema::RedeclarationKind Redecl = Sema::NotForRedeclaration)
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.
151   LookupResult(Sema &SemaRef, DeclarationName Name,
152                SourceLocation NameLoc, Sema::LookupNameKind LookupKind,
153                Sema::RedeclarationKind Redecl = Sema::NotForRedeclaration)
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.
173   LookupResult(TemporaryToken _, const LookupResult &Other)
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
188   ~LookupResult() {
189     if (Diagnose) diagnose();
190     if (Paths) deletePaths(Paths);
191   }
192
193   /// Gets the name info to look up.
194   const DeclarationNameInfo &getLookupNameInfo() const {
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.
204   DeclarationName getLookupName() const {
205     return NameInfo.getName();
206   }
207
208   /// \brief Sets the name to look up.
209   void setLookupName(DeclarationName Name) {
210     NameInfo.setName(Name);
211   }
212
213   /// Gets the kind of lookup to perform.
214   Sema::LookupNameKind getLookupKind() const {
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.
231   bool isHiddenDeclarationVisible() const {
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 {
258     return getResultKind() == FoundUnresolvedValue;
259   }
260
261   LookupResultKind getResultKind() const {
262     assert(sanity());
263     return ResultKind;
264   }
265
266   AmbiguityKind getAmbiguityKind() const {
267     assert(isAmbiguous());
268     return Ambiguity;
269   }
270
271   const UnresolvedSetImpl &asUnresolvedSet() const {
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.
283   CXXBasePaths *getBasePaths() const {
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.
301   NamedDecl *getAcceptableDecl(NamedDecl *D) const {
302     if (!D->isInIdentifierNamespace(IDNS))
303       return nullptr;
304
305     if (isVisible(getSema(), D))
306       return D;
307
308     if (auto *Visible = getAcceptableDeclSlow(D))
309       return Visible;
310
311     // Even if hidden declarations are visible, prefer a visible declaration.
312     return isHiddenDeclarationVisible() ? D : nullptr;
313   }
314
315 private:
316   static bool isVisibleSlow(Sema &SemaRef, NamedDecl *D);
317   NamedDecl *getAcceptableDeclSlow(NamedDecl *D) const;
318
319 public:
320   /// \brief Returns the identifier namespace mask for this lookup.
321   unsigned getIdentifierNamespace() const {
322     return IDNS;
323   }
324
325   /// \brief Returns whether these results arose from performing a
326   /// lookup into a class.
327   bool isClassLookup() const {
328     return NamingClass != nullptr;
329   }
330
331   /// \brief Returns the 'naming class' for this lookup, i.e. the
332   /// class which was looked into to find these results.
333   ///
334   /// C++0x [class.access.base]p5:
335   ///   The access to a member is affected by the class in which the
336   ///   member is named. This naming class is the class in which the
337   ///   member name was looked up and found. [Note: this class can be
338   ///   explicit, e.g., when a qualified-id is used, or implicit,
339   ///   e.g., when a class member access operator (5.2.5) is used
340   ///   (including cases where an implicit "this->" is added). If both
341   ///   a class member access operator and a qualified-id are used to
342   ///   name the member (as in p->T::m), the class naming the member
343   ///   is the class named by the nested-name-specifier of the
344   ///   qualified-id (that is, T). -- end note ]
345   ///
346   /// This is set by the lookup routines when they find results in a class.
347   CXXRecordDecl *getNamingClass() const {
348     return NamingClass;
349   }
350
351   /// \brief Sets the 'naming class' for this lookup.
352   void setNamingClass(CXXRecordDecl *Record) {
353     NamingClass = Record;
354   }
355
356   /// \brief Returns the base object type associated with this lookup;
357   /// important for [class.protected].  Most lookups do not have an
358   /// associated base object.
359   QualType getBaseObjectType() const {
360     return BaseObjectType;
361   }
362
363   /// \brief Sets the base object type for this lookup.
364   void setBaseObjectType(QualType T) {
365     BaseObjectType = T;
366   }
367
368   /// \brief Add a declaration to these results with its natural access.
369   /// Does not test the acceptance criteria.
370   void addDecl(NamedDecl *D) {
371     addDecl(D, D->getAccess());
372   }
373
374   /// \brief Add a declaration to these results with the given access.
375   /// Does not test the acceptance criteria.
376   void addDecl(NamedDecl *D, AccessSpecifier AS) {
377     Decls.addDecl(D, AS);
378     ResultKind = Found;
379   }
380
381   /// \brief Add all the declarations from another set of lookup
382   /// results.
383   void addAllDecls(const LookupResult &Other) {
384     Decls.append(Other.Decls.begin(), Other.Decls.end());
385     ResultKind = Found;
386   }
387
388   /// \brief Determine whether no result was found because we could not
389   /// search into dependent base classes of the current instantiation.
390   bool wasNotFoundInCurrentInstantiation() const {
391     return ResultKind == NotFoundInCurrentInstantiation;
392   }
393   
394   /// \brief Note that while no result was found in the current instantiation,
395   /// there were dependent base classes that could not be searched.
396   void setNotFoundInCurrentInstantiation() {
397     assert(ResultKind == NotFound && Decls.empty());
398     ResultKind = NotFoundInCurrentInstantiation;
399   }
400
401   /// \brief Determine whether the lookup result was shadowed by some other
402   /// declaration that lookup ignored.
403   bool isShadowed() const { return Shadowed; }
404
405   /// \brief Note that we found and ignored a declaration while performing
406   /// lookup.
407   void setShadowed() { Shadowed = true; }
408
409   /// \brief Resolves the result kind of the lookup, possibly hiding
410   /// decls.
411   ///
412   /// This should be called in any environment where lookup might
413   /// generate multiple lookup results.
414   void resolveKind();
415
416   /// \brief Re-resolves the result kind of the lookup after a set of
417   /// removals has been performed.
418   void resolveKindAfterFilter() {
419     if (Decls.empty()) {
420       if (ResultKind != NotFoundInCurrentInstantiation)
421         ResultKind = NotFound;
422
423       if (Paths) {
424         deletePaths(Paths);
425         Paths = nullptr;
426       }
427     } else {
428       AmbiguityKind SavedAK;
429       bool WasAmbiguous = false;
430       if (ResultKind == Ambiguous) {
431         SavedAK = Ambiguity;
432         WasAmbiguous = true;
433       }
434       ResultKind = Found;
435       resolveKind();
436
437       // If we didn't make the lookup unambiguous, restore the old
438       // ambiguity kind.
439       if (ResultKind == Ambiguous) {
440         (void)WasAmbiguous;
441         assert(WasAmbiguous);
442         Ambiguity = SavedAK;
443       } else if (Paths) {
444         deletePaths(Paths);
445         Paths = nullptr;
446       }
447     }
448   }
449
450   template <class DeclClass>
451   DeclClass *getAsSingle() const {
452     if (getResultKind() != Found) return nullptr;
453     return dyn_cast<DeclClass>(getFoundDecl());
454   }
455
456   /// \brief Fetch the unique decl found by this lookup.  Asserts
457   /// that one was found.
458   ///
459   /// This is intended for users who have examined the result kind
460   /// and are certain that there is only one result.
461   NamedDecl *getFoundDecl() const {
462     assert(getResultKind() == Found
463            && "getFoundDecl called on non-unique result");
464     return (*begin())->getUnderlyingDecl();
465   }
466
467   /// Fetches a representative decl.  Useful for lazy diagnostics.
468   NamedDecl *getRepresentativeDecl() const {
469     assert(!Decls.empty() && "cannot get representative of empty set");
470     return *begin();
471   }
472
473   /// \brief Asks if the result is a single tag decl.
474   bool isSingleTagDecl() const {
475     return getResultKind() == Found && isa<TagDecl>(getFoundDecl());
476   }
477
478   /// \brief Make these results show that the name was found in
479   /// base classes of different types.
480   ///
481   /// The given paths object is copied and invalidated.
482   void setAmbiguousBaseSubobjectTypes(CXXBasePaths &P);
483
484   /// \brief Make these results show that the name was found in
485   /// distinct base classes of the same type.
486   ///
487   /// The given paths object is copied and invalidated.
488   void setAmbiguousBaseSubobjects(CXXBasePaths &P);
489
490   /// \brief Make these results show that the name was found in
491   /// different contexts and a tag decl was hidden by an ordinary
492   /// decl in a different context.
493   void setAmbiguousQualifiedTagHiding() {
494     setAmbiguous(AmbiguousTagHiding);
495   }
496
497   /// \brief Clears out any current state.
498   void clear() {
499     ResultKind = NotFound;
500     Decls.clear();
501     if (Paths) deletePaths(Paths);
502     Paths = nullptr;
503     NamingClass = nullptr;
504     Shadowed = false;
505   }
506
507   /// \brief Clears out any current state and re-initializes for a
508   /// different kind of lookup.
509   void clear(Sema::LookupNameKind Kind) {
510     clear();
511     LookupKind = Kind;
512     configure();
513   }
514
515   /// \brief Change this lookup's redeclaration kind.
516   void setRedeclarationKind(Sema::RedeclarationKind RK) {
517     Redecl = RK;
518     AllowHidden = (RK == Sema::ForRedeclaration);
519     configure();
520   }
521
522   void print(raw_ostream &);
523
524   /// Suppress the diagnostics that would normally fire because of this
525   /// lookup.  This happens during (e.g.) redeclaration lookups.
526   void suppressDiagnostics() {
527     Diagnose = false;
528   }
529
530   /// Determines whether this lookup is suppressing diagnostics.
531   bool isSuppressingDiagnostics() const {
532     return !Diagnose;
533   }
534
535   /// Sets a 'context' source range.
536   void setContextRange(SourceRange SR) {
537     NameContextRange = SR;
538   }
539
540   /// Gets the source range of the context of this name; for C++
541   /// qualified lookups, this is the source range of the scope
542   /// specifier.
543   SourceRange getContextRange() const {
544     return NameContextRange;
545   }
546
547   /// Gets the location of the identifier.  This isn't always defined:
548   /// sometimes we're doing lookups on synthesized names.
549   SourceLocation getNameLoc() const {
550     return NameInfo.getLoc();
551   }
552
553   /// \brief Get the Sema object that this lookup result is searching
554   /// with.
555   Sema &getSema() const { return *SemaPtr; }
556
557   /// A class for iterating through a result set and possibly
558   /// filtering out results.  The results returned are possibly
559   /// sugared.
560   class Filter {
561     LookupResult &Results;
562     LookupResult::iterator I;
563     bool Changed;
564     bool CalledDone;
565     
566     friend class LookupResult;
567     Filter(LookupResult &Results)
568       : Results(Results), I(Results.begin()), Changed(false), CalledDone(false)
569     {}
570
571   public:
572     ~Filter() {
573       assert(CalledDone &&
574              "LookupResult::Filter destroyed without done() call");
575     }
576
577     bool hasNext() const {
578       return I != Results.end();
579     }
580
581     NamedDecl *next() {
582       assert(I != Results.end() && "next() called on empty filter");
583       return *I++;
584     }
585
586     /// Restart the iteration.
587     void restart() {
588       I = Results.begin();
589     }
590
591     /// Erase the last element returned from this iterator.
592     void erase() {
593       Results.Decls.erase(--I);
594       Changed = true;
595     }
596
597     /// Replaces the current entry with the given one, preserving the
598     /// access bits.
599     void replace(NamedDecl *D) {
600       Results.Decls.replace(I-1, D);
601       Changed = true;
602     }
603
604     /// Replaces the current entry with the given one.
605     void replace(NamedDecl *D, AccessSpecifier AS) {
606       Results.Decls.replace(I-1, D, AS);
607       Changed = true;
608     }
609
610     void done() {
611       assert(!CalledDone && "done() called twice");
612       CalledDone = true;
613
614       if (Changed)
615         Results.resolveKindAfterFilter();
616     }
617   };
618
619   /// Create a filter for this result set.
620   Filter makeFilter() {
621     return Filter(*this);
622   }
623
624   void setFindLocalExtern(bool FindLocalExtern) {
625     if (FindLocalExtern)
626       IDNS |= Decl::IDNS_LocalExtern;
627     else
628       IDNS &= ~Decl::IDNS_LocalExtern;
629   }
630
631 private:
632   void diagnose() {
633     if (isAmbiguous())
634       getSema().DiagnoseAmbiguousLookup(*this);
635     else if (isClassLookup() && getSema().getLangOpts().AccessControl)
636       getSema().CheckLookupAccess(*this);
637   }
638
639   void setAmbiguous(AmbiguityKind AK) {
640     ResultKind = Ambiguous;
641     Ambiguity = AK;
642   }
643
644   void addDeclsFromBasePaths(const CXXBasePaths &P);
645   void configure();
646
647   // Sanity checks.
648   bool sanity() const;
649
650   bool sanityCheckUnresolved() const {
651     for (iterator I = begin(), E = end(); I != E; ++I)
652       if (isa<UnresolvedUsingValueDecl>((*I)->getUnderlyingDecl()))
653         return true;
654     return false;
655   }
656
657   static void deletePaths(CXXBasePaths *);
658
659   // Results.
660   LookupResultKind ResultKind;
661   AmbiguityKind Ambiguity; // ill-defined unless ambiguous
662   UnresolvedSet<8> Decls;
663   CXXBasePaths *Paths;
664   CXXRecordDecl *NamingClass;
665   QualType BaseObjectType;
666
667   // Parameters.
668   Sema *SemaPtr;
669   DeclarationNameInfo NameInfo;
670   SourceRange NameContextRange;
671   Sema::LookupNameKind LookupKind;
672   unsigned IDNS; // set by configure()
673
674   bool Redecl;
675
676   /// \brief True if tag declarations should be hidden if non-tags
677   ///   are present
678   bool HideTags;
679
680   bool Diagnose;
681
682   /// \brief True if we should allow hidden declarations to be 'visible'.
683   bool AllowHidden;
684
685   /// \brief True if the found declarations were shadowed by some other
686   /// declaration that we skipped. This only happens when \c LookupKind
687   /// is \c LookupRedeclarationWithLinkage.
688   bool Shadowed;
689 };
690
691 /// \brief Consumes visible declarations found when searching for
692 /// all visible names within a given scope or context.
693 ///
694 /// This abstract class is meant to be subclassed by clients of \c
695 /// Sema::LookupVisibleDecls(), each of which should override the \c
696 /// FoundDecl() function to process declarations as they are found.
697 class VisibleDeclConsumer {
698 public:
699   /// \brief Destroys the visible declaration consumer.
700   virtual ~VisibleDeclConsumer();
701
702   /// \brief Determine whether hidden declarations (from unimported
703   /// modules) should be given to this consumer. By default, they
704   /// are not included.
705   virtual bool includeHiddenDecls() const;
706
707   /// \brief Invoked each time \p Sema::LookupVisibleDecls() finds a
708   /// declaration visible from the current scope or context.
709   ///
710   /// \param ND the declaration found.
711   ///
712   /// \param Hiding a declaration that hides the declaration \p ND,
713   /// or NULL if no such declaration exists.
714   ///
715   /// \param Ctx the original context from which the lookup started.
716   ///
717   /// \param InBaseClass whether this declaration was found in base
718   /// class of the context we searched.
719   virtual void FoundDecl(NamedDecl *ND, NamedDecl *Hiding, DeclContext *Ctx,
720                          bool InBaseClass) = 0;
721 };
722
723 /// \brief A class for storing results from argument-dependent lookup.
724 class ADLResult {
725 private:
726   /// A map from canonical decls to the 'most recent' decl.
727   llvm::DenseMap<NamedDecl*, NamedDecl*> Decls;
728
729 public:
730   /// Adds a new ADL candidate to this map.
731   void insert(NamedDecl *D);
732
733   /// Removes any data associated with a given decl.
734   void erase(NamedDecl *D) {
735     Decls.erase(cast<NamedDecl>(D->getCanonicalDecl()));
736   }
737
738   class iterator
739       : public llvm::iterator_adaptor_base<
740             iterator, llvm::DenseMap<NamedDecl *, NamedDecl *>::iterator,
741             std::forward_iterator_tag, NamedDecl *> {
742     friend class ADLResult;
743
744     iterator(llvm::DenseMap<NamedDecl *, NamedDecl *>::iterator Iter)
745         : iterator_adaptor_base(std::move(Iter)) {}
746
747   public:
748     iterator() {}
749
750     value_type operator*() const { return I->second; }
751   };
752
753   iterator begin() { return iterator(Decls.begin()); }
754   iterator end() { return iterator(Decls.end()); }
755 };
756
757 }
758
759 #endif