================
@@ -55,28 +59,64 @@ class SARIFDiagnostic : public DiagnosticRenderer {
                                   StringRef ModuleName) override;
 
 private:
-  // Shared between SARIFDiagnosticPrinter and this renderer.
-  SarifDocumentWriter *Writer;
-
-  SarifResult addLocationToResult(SarifResult Result, FullSourceLoc Loc,
-                                  PresumedLoc PLoc,
-                                  ArrayRef<CharSourceRange> Ranges,
-                                  const Diagnostic &Diag);
-
-  SarifResult addRelatedLocationToResult(SarifResult Result, FullSourceLoc Loc,
-                                         PresumedLoc PLoc);
-
-  llvm::SmallVector<CharSourceRange>
-  getSarifLocation(FullSourceLoc Loc, PresumedLoc PLoc,
-                   ArrayRef<CharSourceRange> Ranges);
-
-  SarifRule addDiagnosticLevelToRule(SarifRule Rule,
-                                     DiagnosticsEngine::Level Level);
-
-  llvm::StringRef emitFilename(StringRef Filename, const SourceManager &SM);
-
-  llvm::SmallVector<std::pair<FullSourceLoc, PresumedLoc>>
-      RelatedLocationsCache;
+  class Node {
+  public:
+    // Subclasses
+    struct Result {
+      DiagnosticsEngine::Level Level;
+      std::string Message;
+      DiagOrStoredDiag Diag;
+    };
+
+    struct Option {
+      const LangOptions *LangOptsPtr;
+      const DiagnosticOptions *DiagnosticOptsPtr;
+    };
----------------
anonymouspc wrote:

Not that the `Node::getLocation()` and `Node::getRelatedLocations()` needs 
`const LangOptions&`. So that

If we remove the `LangOptsPtr` from `Node`
   - The `Node::getLocation()` will become 
`Node::getLocation(SARIFDiagnostic&)`.
   - The caller should use 
     ```cpp
     // original
     SarifResult Result = SarifResult::create(...)
       .setDiagnosticMessage(...)
       .addLocations(Root.getLocations())
       .addRelatedLocations(Root.getRelatedLocations())

     // now, after we remove `Node::LangOptsPtr`.
     SarifResult Result = SarifResult::create(...)
       .setDiagnosticMessage(...)
       .addLocations(SomeNode.getLocations(*this))
       .addRelatedLocations(SomeNode.getRelatedLocations(*this));
     ```

Fixed (removed these data members) in commit 
c508c38dd74570edb08cdde34b93109da335c21f.

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

Reply via email to