@@ -757,20 +757,70 @@ class RequirementRequest :
757757 bool isCached() const;
758758};
759759
760+ /// Generate the Clang USR for the given declaration.
761+ class ClangUSRGenerationRequest
762+ : public SimpleRequest<ClangUSRGenerationRequest,
763+ std::optional<std::string>(const ValueDecl *),
764+ RequestFlags::SeparatelyCached |
765+ RequestFlags::SplitCached> {
766+ public:
767+ using SimpleRequest::SimpleRequest;
768+
769+ private:
770+ friend SimpleRequest;
771+
772+ // Evaluation.
773+ std::optional<std::string> evaluate(Evaluator &eval,
774+ const ValueDecl *d) const;
775+
776+ public:
777+ // Split caching.
778+ bool isCached() const { return true; }
779+ std::optional<std::optional<std::string>> getCachedResult() const;
780+ void cacheResult(std::optional<std::string> result) const;
781+ };
782+
783+ /// Generate the Swift USR for the given declaration.
784+ class SwiftUSRGenerationRequest
785+ : public SimpleRequest<SwiftUSRGenerationRequest,
786+ std::string(const ValueDecl *),
787+ RequestFlags::Cached> {
788+ public:
789+ using SimpleRequest::SimpleRequest;
790+
791+ private:
792+ friend SimpleRequest;
793+
794+ // Evaluation.
795+ std::string evaluate(Evaluator &eval, const ValueDecl *d) const;
796+
797+ public:
798+ // Caching
799+ bool isCached() const { return true; }
800+ };
801+
760802struct USRGenerationOptions {
761803 /// @brief Whether to emit USRs using the Swift declaration when it is
762804 /// synthesized from a Clang based declaration. Useful in cases where Swift
763805 /// declarations are synthesized from Clang nodes but the caller actually
764806 /// wants the USR of the Swift declaration.
765807 bool distinguishSynthesizedDecls;
766808
809+ /// @brief Whether to emit USRs using the Swift declaration for all
810+ /// declarations specifically, emits a Swift USR for all Clang-based
811+ /// declarations.
812+ bool useSwiftUSR;
813+
767814 friend llvm::hash_code hash_value(const USRGenerationOptions &options) {
768- return llvm::hash_value (options.distinguishSynthesizedDecls );
815+ return llvm::hash_combine(
816+ llvm::hash_value(options.distinguishSynthesizedDecls),
817+ llvm::hash_value(options.useSwiftUSR));
769818 }
770819
771820 friend bool operator==(const USRGenerationOptions &lhs,
772821 const USRGenerationOptions &rhs) {
773- return lhs.distinguishSynthesizedDecls == rhs.distinguishSynthesizedDecls ;
822+ return lhs.distinguishSynthesizedDecls == rhs.distinguishSynthesizedDecls &&
823+ lhs.useSwiftUSR == rhs.useSwiftUSR;
774824 }
775825
776826 friend bool operator!=(const USRGenerationOptions &lhs,
@@ -783,10 +833,12 @@ void simple_display(llvm::raw_ostream &out,
783833 const USRGenerationOptions &options);
784834
785835/// Generate the USR for the given declaration.
836+ /// This is an umbrella request that forwards to ClangUSRGenerationRequest or
837+ /// SwiftUSRGenerationRequest.
786838class USRGenerationRequest
787839 : public SimpleRequest<USRGenerationRequest,
788840 std::string(const ValueDecl *, USRGenerationOptions),
789- RequestFlags::Cached > {
841+ RequestFlags::Uncached > {
790842public:
791843 using SimpleRequest::SimpleRequest;
792844
@@ -796,10 +848,6 @@ class USRGenerationRequest
796848 // Evaluation.
797849 std::string evaluate(Evaluator &eval, const ValueDecl *d,
798850 USRGenerationOptions options) const;
799-
800- public:
801- // Caching
802- bool isCached () const { return true ; }
803851};
804852
805853/// Generate the mangling for the given local type declaration.
0 commit comments