-
Notifications
You must be signed in to change notification settings - Fork 142
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Analysis Printer (#17) * Initial Commit * AnalysisPrinter Second commit * Initial Commit * Integrate Printer with client Analysis and test * Addressing Review comments * Integrate AnalysisPrinter with all analyses and template class modified * vector emplace_back instead of push_back * Testcase for AnalysisPrinter * GroundTruth derived class initial commit * AnalysisPrinter Test complete and Test * fixing myphasartool file * Test pre-commit fix * Adding Test cases and fixing PR failure * 1.template params to N,D,L 2.remove AnalysisType param from AnalysisResults 3.rearranging class variables * 1.template params to N,D,L 2.remove AnalysisType param from AnalysisResults 3.rearranging class variables * Null AnalysisPrinter singleton * Adding AnalysisPrinter to IDETabulation Problem * making free (N,D,L)ToString functions * disable copy and move for analysis-printer * Default NullAnalysisPrinter and explicit print methods * removing SetAnalysisPrinter from client analyses and modified Testcase for AnalysisPrinter * Adding superclass for AnalysisPrinter * Addressing review comments and fixing PR build failure * fix: minors * fix: minor (clang-tidy) * fix: review feedback * misc: minor refactoring --------- Co-authored-by: SanthoshMohan <[email protected]> Co-authored-by: Sriteja Kummita <[email protected]> * fix: review feedback --------- Co-authored-by: SanthoshMohan <[email protected]> Co-authored-by: Sriteja Kummita <[email protected]>
- Loading branch information
1 parent
fc14480
commit 1e9f3b7
Showing
13 changed files
with
295 additions
and
70 deletions.
There are no files selected for viewing
This file contains 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 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 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 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 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 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 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 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 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 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 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.