================
@@ -67,10 +75,102 @@ class SerializationFormat {
 
   static EntityId makeEntityId(const size_t Index) { return EntityId(Index); }
 
+  /// Constructs an empty WPASuite. Bypasses the private default constructor
+  /// so that deserialization code can build a WPASuite incrementally.
+  static WPASuite makeWPASuite() { return WPASuite(); }
+
 #define FIELD(CLASS, FIELD_NAME)                                               
\
   static const auto &get##FIELD_NAME(const CLASS &X) { return X.FIELD_NAME; }  
\
   static auto &get##FIELD_NAME(CLASS &X) { return X.FIELD_NAME; }
 #include 
"clang/ScalableStaticAnalysisFramework/Core/Model/PrivateFieldNames.def"
+
+  /// Per-format plugin registry for analysis result (de)serializers.
+  ///
+  /// Each concrete format (e.g. JSONFormat) instantiates this template once
+  /// via a public \c using alias. Analysis authors register support with:
+  ///
+  ///   static MyFormat::AnalysisResultRegistry::Add<MyAnalysisResult>
+  ///       Reg(serializeFn, deserializeFn);
+  ///
+  /// The serializer receives \c const MyAnalysisResult & directly — the
+  /// \c Add wrapper handles the downcast from \c AnalysisResult internally.
+  ///
+  /// \p FormatT is otherwise unused — it exists because \c llvm::Registry
+  /// is keyed on the \c Entry type, so two formats that happen to share the
+  /// same serializer/deserializer signatures would collide without a
+  /// disambiguating template parameter.
+  ///
+  /// \c function_ref is non-owning, but \c llvm::Registry only stores
+  /// nullary factories (no captured state). Function-local statics inside
+  /// \c Add<T>::Add(...) give each analysis's \c function_ref values a
+  /// stable, program-lifetime home, and a local \c ConcreteEntry struct
+  /// reads them back when the registry instantiates the factory.
+  template <class FormatT, class SerializerFn, class DeserializerFn>
----------------
aviralg wrote:

All this magic makes user-side registration a single-line operation.

https://github.com/llvm/llvm-project/pull/187403
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to