@@ -757,20 +757,70 @@ class RequirementRequest :
757
757
bool isCached() const;
758
758
};
759
759
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
+
760
802
struct USRGenerationOptions {
761
803
/// @brief Whether to emit USRs using the Swift declaration when it is
762
804
/// synthesized from a Clang based declaration. Useful in cases where Swift
763
805
/// declarations are synthesized from Clang nodes but the caller actually
764
806
/// wants the USR of the Swift declaration.
765
807
bool distinguishSynthesizedDecls;
766
808
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
+
767
814
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));
769
818
}
770
819
771
820
friend bool operator==(const USRGenerationOptions &lhs,
772
821
const USRGenerationOptions &rhs) {
773
- return lhs.distinguishSynthesizedDecls == rhs.distinguishSynthesizedDecls ;
822
+ return lhs.distinguishSynthesizedDecls == rhs.distinguishSynthesizedDecls &&
823
+ lhs.useSwiftUSR == rhs.useSwiftUSR;
774
824
}
775
825
776
826
friend bool operator!=(const USRGenerationOptions &lhs,
@@ -783,10 +833,12 @@ void simple_display(llvm::raw_ostream &out,
783
833
const USRGenerationOptions &options);
784
834
785
835
/// Generate the USR for the given declaration.
836
+ /// This is an umbrella request that forwards to ClangUSRGenerationRequest or
837
+ /// SwiftUSRGenerationRequest.
786
838
class USRGenerationRequest
787
839
: public SimpleRequest<USRGenerationRequest,
788
840
std::string(const ValueDecl *, USRGenerationOptions),
789
- RequestFlags::Cached > {
841
+ RequestFlags::Uncached > {
790
842
public:
791
843
using SimpleRequest::SimpleRequest;
792
844
@@ -796,10 +848,6 @@ class USRGenerationRequest
796
848
// Evaluation.
797
849
std::string evaluate(Evaluator &eval, const ValueDecl *d,
798
850
USRGenerationOptions options) const;
799
-
800
- public:
801
- // Caching
802
- bool isCached () const { return true ; }
803
851
};
804
852
805
853
/// Generate the mangling for the given local type declaration.
0 commit comments