================
@@ -439,10 +439,26 @@ json::Object SarifDocumentWriter::createDocument() {
   endRun();
 
   json::Object Doc{
-      {"$schema", SchemaURI},
-      {"version", SchemaVersion},
+      {"$schema", Version.SchemaURI},
+      {"version", Version.SchemaVersion},
   };
   if (!Runs.empty())
     Doc["runs"] = json::Array(Runs);
   return Doc;
 }
+
+ArrayRef<SarifVersion> SarifDocumentWriter::getSupportedVersions() {
+  static const SarifVersion Versions[] = {
+      {"2.1.0", "2.1",
+       "https://docs.oasis-open.org/sarif/sarif/v2.1.0/cos02/schemas/";
+       "sarif-schema-2.1.0.json",
+       true}};
+
+  return Versions;
+}
+
+const SarifVersion &SarifDocumentWriter::getDefaultVersion() {
+  const auto Versions = getSupportedVersions();
+  return *std::find_if(Versions.begin(), Versions.end(),
+                       [](const SarifVersion &V) { return V.IsDefault; });
+}
----------------
dbartol wrote:

`find_singleton`'s interface is a bit strange (the "predicate" takes an extra 
`bool` argument, and returns a pointer). I just kept `llvm::find_if`, but then 
added a uniqueness assert where we construct the versions array.


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

Reply via email to