Skip to content

Commit

Permalink
pr: Enable SARIF output depending on feature set.
Browse files Browse the repository at this point in the history
  • Loading branch information
frabert committed Nov 21, 2024
1 parent 49b2e72 commit 627701e
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 11 deletions.
8 changes: 5 additions & 3 deletions tools/detect-parsers/ParserSourceDetector.cpp
Original file line number Diff line number Diff line change
@@ -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() {
Expand All @@ -27,3 +28,4 @@ namespace vast {
});
}
} // namespace vast
#endif
12 changes: 7 additions & 5 deletions tools/detect-parsers/SarifPasses.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,16 @@

#pragma once

#include "vast/Util/Warnings.hpp"
#ifdef VAST_ENABLE_SARIF
#include "vast/Util/Warnings.hpp"

VAST_RELAX_WARNINGS
#include <mlir/IR/BuiltinOps.h>
#include <mlir/Pass/Pass.h>
#include <mlir/Pass/PassManager.h>
#include <mlir/IR/BuiltinOps.h>
#include <mlir/Pass/Pass.h>
#include <mlir/Pass/PassManager.h>
VAST_UNRELAX_WARNINGS

#include <gap/sarif/sarif.hpp>
#include <gap/sarif/sarif.hpp>

namespace vast {
struct ParserSourceDetector
Expand All @@ -23,3 +24,4 @@ namespace vast {
void runOnOperation() override;
};
} // namespace vast
#endif
10 changes: 7 additions & 3 deletions tools/detect-parsers/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -76,6 +76,10 @@ namespace vast {
}
);
}
#else

void registerSarifPasses() {}
#endif
} // namespace vast

int main(int argc, char **argv) {
Expand Down

0 comments on commit 627701e

Please sign in to comment.