From 627701e7f4a28dcfa2ea0c11c62cb71477c60757 Mon Sep 17 00:00:00 2001 From: Francesco Bertolaccini Date: Thu, 21 Nov 2024 16:25:56 +0100 Subject: [PATCH] pr: Enable SARIF output depending on feature set. --- tools/detect-parsers/ParserSourceDetector.cpp | 8 +++++--- tools/detect-parsers/SarifPasses.hpp | 12 +++++++----- tools/detect-parsers/main.cpp | 10 +++++++--- 3 files changed, 19 insertions(+), 11 deletions(-) diff --git a/tools/detect-parsers/ParserSourceDetector.cpp b/tools/detect-parsers/ParserSourceDetector.cpp index de1d6479e8..5d59aed6e3 100644 --- a/tools/detect-parsers/ParserSourceDetector.cpp +++ b/tools/detect-parsers/ParserSourceDetector.cpp @@ -1,9 +1,10 @@ // Copyright (c) 2021-present, Trail of Bits, Inc. -#include "SarifPasses.hpp" +#ifdef VAST_ENABLE_SARIF + #include "SarifPasses.hpp" -#include "vast/Dialect/Parser/Ops.hpp" -#include "vast/Frontend/Sarif.hpp" + #include "vast/Dialect/Parser/Ops.hpp" + #include "vast/Frontend/Sarif.hpp" namespace vast { void ParserSourceDetector::runOnOperation() { @@ -27,3 +28,4 @@ namespace vast { }); } } // namespace vast +#endif diff --git a/tools/detect-parsers/SarifPasses.hpp b/tools/detect-parsers/SarifPasses.hpp index adaabd46e9..00efb04d1d 100644 --- a/tools/detect-parsers/SarifPasses.hpp +++ b/tools/detect-parsers/SarifPasses.hpp @@ -2,15 +2,16 @@ #pragma once -#include "vast/Util/Warnings.hpp" +#ifdef VAST_ENABLE_SARIF + #include "vast/Util/Warnings.hpp" VAST_RELAX_WARNINGS -#include -#include -#include + #include + #include + #include VAST_UNRELAX_WARNINGS -#include + #include namespace vast { struct ParserSourceDetector @@ -23,3 +24,4 @@ namespace vast { void runOnOperation() override; }; } // namespace vast +#endif diff --git a/tools/detect-parsers/main.cpp b/tools/detect-parsers/main.cpp index 1cca8a80ca..053a16f27e 100644 --- a/tools/detect-parsers/main.cpp +++ b/tools/detect-parsers/main.cpp @@ -23,9 +23,9 @@ VAST_UNRELAX_WARNINGS #include "SarifPasses.hpp" namespace vast { - struct SarifWriter - : mlir::PassWrapper< - SarifWriter, mlir::OperationPass< mlir::ModuleOp > > + +#ifdef VAST_ENABLE_SARIF + struct SarifWriter : mlir::PassWrapper< SarifWriter, mlir::OperationPass< mlir::ModuleOp > > { std::vector< gap::sarif::result > results; std::string path; @@ -76,6 +76,10 @@ namespace vast { } ); } +#else + + void registerSarifPasses() {} +#endif } // namespace vast int main(int argc, char **argv) {