@@ -58,6 +58,9 @@ struct AnyRequestVTable {
5858 static void noteCycleStep (const void *ptr, DiagnosticEngine &diags) {
5959 static_cast <const Request *>(ptr)->noteCycleStep (diags);
6060 }
61+ static SourceLoc getNearestLoc (const void *ptr) {
62+ return static_cast <const Request *>(ptr)->getNearestLoc ();
63+ }
6164 };
6265
6366 const uint64_t typeID;
@@ -66,6 +69,7 @@ struct AnyRequestVTable {
6669 const std::function<void (const void *, llvm::raw_ostream &)> simpleDisplay;
6770 const std::function<void (const void *, DiagnosticEngine &)> diagnoseCycle;
6871 const std::function<void (const void *, DiagnosticEngine &)> noteCycleStep;
72+ const std::function<SourceLoc(const void *)> getNearestLoc;
6973
7074 template <typename Request>
7175 static const AnyRequestVTable *get () {
@@ -75,7 +79,8 @@ struct AnyRequestVTable {
7579 &Impl<Request>::isEqual,
7680 &Impl<Request>::simpleDisplay,
7781 &Impl<Request>::diagnoseCycle,
78- &Impl<Request>::noteCycleStep
82+ &Impl<Request>::noteCycleStep,
83+ &Impl<Request>::getNearestLoc
7984 };
8085 return &vtable;
8186 }
@@ -173,6 +178,11 @@ class AnyRequestBase {
173178 getVTable ()->noteCycleStep (getRawStorage (), diags);
174179 }
175180
181+ // / Get the best source location describing the parameters to this request.
182+ SourceLoc getNearestLoc () const {
183+ return getVTable ()->getNearestLoc (getRawStorage ());
184+ }
185+
176186 // / Compare two instances for equality.
177187 friend bool operator ==(const AnyRequestBase<Derived> &lhs,
178188 const AnyRequestBase<Derived> &rhs) {
@@ -224,6 +234,8 @@ class AnyRequestBase {
224234// / - Cycle diagnostics operations:
225235// / void diagnoseCycle(DiagnosticEngine &diags) const;
226236// / void noteCycleStep(DiagnosticEngine &diags) const;
237+ // / - Source location information:
238+ // / SourceLoc getNearestLoc() const;
227239// /
228240class ActiveRequest final : public AnyRequestBase<ActiveRequest> {
229241 template <typename T>
0 commit comments