-
Notifications
You must be signed in to change notification settings - Fork 156
Analysis Printer #677
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
fabianbs96
merged 7 commits into
secure-software-engineering:development
from
fabianbs96:development
Nov 25, 2023
Merged
Analysis Printer #677
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
9179cf0
Analysis Printer (#17)
fabianbs96 3062f3d
Merge branch 'development' into development
fabianbs96 70e3241
Merge branch 'development' into development
fabianbs96 771d7d1
Merge branch 'development' into development
fabianbs96 6063730
fix: review feedback
sritejakv 2e9efb0
Merge pull request #22 from fabianbs96/f-AnalysisPrinterReview
fabianbs96 a75309e
Merge branch 'development' into development
fabianbs96 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,44 @@ | ||
| #ifndef PHASAR_PHASARLLVM_UTILS_ANALYSISPRINTERBASE_H | ||
| #define PHASAR_PHASARLLVM_UTILS_ANALYSISPRINTERBASE_H | ||
|
|
||
| #include "llvm/Support/raw_ostream.h" | ||
|
|
||
| namespace psr { | ||
|
|
||
| template <typename AnalysisDomainTy> struct Warning { | ||
| using n_t = typename AnalysisDomainTy::n_t; | ||
| using d_t = typename AnalysisDomainTy::d_t; | ||
| using l_t = typename AnalysisDomainTy::l_t; | ||
|
|
||
| n_t Instr; | ||
| d_t Fact; | ||
| l_t LatticeElement; | ||
|
|
||
| // Constructor | ||
| Warning(n_t Inst, d_t DfFact, l_t Lattice) | ||
| : Instr(std::move(Inst)), Fact(std::move(DfFact)), | ||
| LatticeElement(std::move(Lattice)) {} | ||
| }; | ||
|
|
||
| template <typename AnalysisDomainTy> struct DataflowAnalysisResults { | ||
| std::vector<Warning<AnalysisDomainTy>> War; | ||
| }; | ||
|
|
||
| template <typename AnalysisDomainTy> class AnalysisPrinterBase { | ||
| public: | ||
| virtual void onResult(Warning<AnalysisDomainTy> /*War*/) = 0; | ||
| virtual void onInitialize() = 0; | ||
| virtual void onFinalize(llvm::raw_ostream & /*OS*/) const = 0; | ||
|
|
||
| AnalysisPrinterBase() = default; | ||
| virtual ~AnalysisPrinterBase() = default; | ||
| AnalysisPrinterBase(const AnalysisPrinterBase &) = delete; | ||
| AnalysisPrinterBase &operator=(const AnalysisPrinterBase &) = delete; | ||
|
|
||
| AnalysisPrinterBase(AnalysisPrinterBase &&) = delete; | ||
| AnalysisPrinterBase &operator=(AnalysisPrinterBase &&) = delete; | ||
| }; | ||
|
|
||
| } // namespace psr | ||
|
|
||
| #endif | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,47 @@ | ||
| #ifndef PHASAR_PHASARLLVM_UTILS_DEFAULTANALYSISPRINTER_H | ||
| #define PHASAR_PHASARLLVM_UTILS_DEFAULTANALYSISPRINTER_H | ||
|
|
||
| #include "phasar/Domain/BinaryDomain.h" | ||
| #include "phasar/PhasarLLVM/Utils/AnalysisPrinterBase.h" | ||
| #include "phasar/PhasarLLVM/Utils/LLVMShorthands.h" | ||
| #include "phasar/Utils/Printer.h" | ||
|
|
||
| #include <optional> | ||
| #include <type_traits> | ||
| #include <vector> | ||
|
|
||
| namespace psr { | ||
|
|
||
| template <typename AnalysisDomainTy> | ||
| class DefaultAnalysisPrinter : public AnalysisPrinterBase<AnalysisDomainTy> { | ||
| using l_t = typename AnalysisDomainTy::l_t; | ||
|
|
||
| public: | ||
| ~DefaultAnalysisPrinter() override = default; | ||
| DefaultAnalysisPrinter() = default; | ||
|
|
||
| void onResult(Warning<AnalysisDomainTy> War) override { | ||
| AnalysisResults.War.emplace_back(std::move(War)); | ||
| } | ||
|
|
||
| void onInitialize() override{}; | ||
| void onFinalize(llvm::raw_ostream &OS = llvm::outs()) const override { | ||
| for (const auto &Iter : AnalysisResults.War) { | ||
|
|
||
| OS << "\nAt IR statement: " << NToString(Iter.Instr) << "\n"; | ||
|
|
||
| OS << "\tFact: " << DToString(Iter.Fact) << "\n"; | ||
|
|
||
| if constexpr (std::is_same_v<l_t, BinaryDomain>) { | ||
| OS << "Value: " << LToString(Iter.LatticeElement) << "\n"; | ||
| } | ||
| } | ||
| } | ||
|
|
||
| private: | ||
| DataflowAnalysisResults<AnalysisDomainTy> AnalysisResults{}; | ||
| }; | ||
|
|
||
| } // namespace psr | ||
|
|
||
| #endif |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| #ifndef PHASAR_PHASARLLVM_UTILS_NULLANALYSISPRINTER_H | ||
| #define PHASAR_PHASARLLVM_UTILS_NULLANALYSISPRINTER_H | ||
|
|
||
| #include "phasar/PhasarLLVM/Utils/AnalysisPrinterBase.h" | ||
|
|
||
| namespace psr { | ||
|
|
||
| template <typename AnalysisDomainTy> | ||
| class NullAnalysisPrinter final : public AnalysisPrinterBase<AnalysisDomainTy> { | ||
| public: | ||
| static NullAnalysisPrinter *getInstance() { | ||
| static auto Instance = NullAnalysisPrinter(); | ||
| return &Instance; | ||
| } | ||
|
|
||
| void onInitialize() override{}; | ||
| void onResult(Warning<AnalysisDomainTy> /*War*/) override{}; | ||
| void onFinalize(llvm::raw_ostream & /*OS*/) const override{}; | ||
|
|
||
| private: | ||
| NullAnalysisPrinter() = default; | ||
| }; | ||
|
|
||
| } // namespace psr | ||
| #endif |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.