@@ -113,7 +113,22 @@ struct DependencyCollector {
113113 llvm::SmallVector<evaluator::DependencySource, 8 > dependencySources;
114114
115115public:
116- DependencyCollector () = default ;
116+ enum class Mode {
117+ // Enables the current "status quo" behavior of the dependency collector.
118+ //
119+ // By default, the dependency collector moves to register dependencies in
120+ // the referenced name trackers at the top of the active dependency stack.
121+ StatusQuo,
122+ // Enables an experimental mode to only register private dependencies.
123+ //
124+ // This mode restricts the dependency collector to ignore changes of
125+ // scope. This has practical effect of charging all unqualified lookups to
126+ // the primary file being acted upon instead of to the destination file.
127+ ExperimentalPrivateDependencies,
128+ };
129+ Mode mode;
130+
131+ explicit DependencyCollector (Mode mode) : mode{mode} {};
117132
118133public:
119134 // / Registers a named reference from the current dependency scope to a member
@@ -206,19 +221,43 @@ struct DependencyCollector {
206221 };
207222
208223private:
224+ // / Returns the first dependency source registered with the tracker, or
225+ // / \c nullptr if no dependency sources have been registered.
226+ SourceFile *getFirstDependencySourceOrNull () const {
227+ if (dependencySources.empty ())
228+ return nullptr ;
229+ return dependencySources.front ().getPointer ();
230+ }
231+
209232 // / If there is an active dependency source, returns its
210233 // / \c ReferencedNameTracker. Else, returns \c nullptr.
211234 ReferencedNameTracker *getActiveDependencyTracker () const {
212- if (auto *source = getActiveDependencySourceOrNull ())
213- return source->getRequestBasedReferencedNameTracker ();
214- return nullptr ;
235+ SourceFile *source = nullptr ;
236+ switch (mode) {
237+ case Mode::StatusQuo:
238+ source = getActiveDependencySourceOrNull ();
239+ break ;
240+ case Mode::ExperimentalPrivateDependencies:
241+ source = getFirstDependencySourceOrNull ();
242+ break ;
243+ }
244+
245+ if (!source)
246+ return nullptr ;
247+
248+ return source->getRequestBasedReferencedNameTracker ();
215249 }
216250
217251 // / Returns \c true if the scope of the current active source cascades.
218252 // /
219253 // / If there is no active scope, the result always cascades.
220254 bool isActiveSourceCascading () const {
221- return getActiveSourceScope () == evaluator::DependencyScope::Cascading;
255+ switch (mode) {
256+ case Mode::StatusQuo:
257+ return getActiveSourceScope () == evaluator::DependencyScope::Cascading;
258+ case Mode::ExperimentalPrivateDependencies:
259+ return false ;
260+ }
222261 }
223262};
224263} // end namespace evaluator
0 commit comments