-
Notifications
You must be signed in to change notification settings - Fork 140
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implementing On-The-Fly Reporting (#701)
* 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 <santhoshmohan0897@gmail.com> Co-authored-by: Sriteja Kummita <sriteja.ku@gmail.com> * OnTheFlyReporting Initial Commit * fix: review feedback * onTheFlyAnalysis makeUniquePtr * OnTheFlyReporting Initial Commit * onTheFlyAnalysis makeUniquePtr * addressing minor error in prev commit * Refactoring Warn Variable and Refactoring lambda flow for AnalysisPrinter * Integrating sourceMgr to AnalysisPrinter * Testcase for OnTheFlyAnalysisPrinting * Testcase for SourceMgrPrinter * MaybeUniquePtr for SourceMgrPrinter * Minor review comments * refactoring the printers * adding TODOs * more TODOs * Refactor AnalysisPrinter part1 * Refactor AnalysisPrinter part2 * dev: update AnalysisPrinterBase, integrate and fix tests * adding warning kind * fix ci * update codeowners for analysis-printer * Refactor SourceManagerPrinter * Minor in OTF Printer Test * fixing review feedback * fix l_t printing * Mandating analysisType to tyestate descriptions --------- Co-authored-by: SanthoshMohan <santhoshmohan0897@gmail.com> Co-authored-by: Fabian Schiebel <fabian.schiebel@iem.fraunhofer.de>
- Loading branch information
1 parent
cd302d8
commit 8a786ac
Showing
35 changed files
with
757 additions
and
213 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
Validating CODEOWNERS rules …
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
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 was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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,36 @@ | ||
#ifndef PHASAR_PHASARLLVM_UTILS_LLVMSOURCEMANAGER_H | ||
#define PHASAR_PHASARLLVM_UTILS_LLVMSOURCEMANAGER_H | ||
|
||
#include "llvm/ADT/DenseMap.h" | ||
#include "llvm/ADT/Twine.h" | ||
#include "llvm/Support/SourceMgr.h" | ||
|
||
#include <optional> | ||
|
||
namespace llvm { | ||
class Value; | ||
class DIFile; | ||
} // namespace llvm | ||
|
||
namespace psr { | ||
struct ManagedDebugLocation { | ||
unsigned Line{}; | ||
unsigned Column{}; | ||
unsigned File{}; | ||
}; | ||
|
||
class LLVMSourceManager { | ||
public: | ||
[[nodiscard]] std::optional<ManagedDebugLocation> | ||
getDebugLocation(const llvm::Value *V); | ||
|
||
void print(llvm::raw_ostream &OS, ManagedDebugLocation Loc, | ||
llvm::SourceMgr::DiagKind DiagKind, const llvm::Twine &Message); | ||
|
||
private: | ||
llvm::DenseMap<const llvm::DIFile *, unsigned> FileIdMap{}; | ||
llvm::SourceMgr SrcMgr{}; | ||
}; | ||
} // namespace psr | ||
|
||
#endif // PHASAR_PHASARLLVM_UTILS_LLVMSOURCEMANAGER_H |
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,71 @@ | ||
#ifndef PHASAR_PHASARLLVM_UTILS_SOURCEMGRPRINTER_H | ||
#define PHASAR_PHASARLLVM_UTILS_SOURCEMGRPRINTER_H | ||
|
||
#include "phasar/PhasarLLVM/Utils/DataFlowAnalysisType.h" | ||
#include "phasar/PhasarLLVM/Utils/LLVMIRToSrc.h" | ||
#include "phasar/PhasarLLVM/Utils/LLVMSourceManager.h" | ||
#include "phasar/Utils/AnalysisPrinterBase.h" | ||
#include "phasar/Utils/MaybeUniquePtr.h" | ||
|
||
#include "llvm/ADT/FunctionExtras.h" | ||
#include "llvm/Support/raw_ostream.h" | ||
|
||
#include <type_traits> | ||
|
||
namespace psr { | ||
|
||
namespace detail { | ||
class SourceMgrPrinterBase { | ||
public: | ||
explicit SourceMgrPrinterBase( | ||
llvm::unique_function<std::string(DataFlowAnalysisType)> &&PrintMessage, | ||
llvm::raw_ostream &OS = llvm::errs(), | ||
llvm::SourceMgr::DiagKind WKind = llvm::SourceMgr::DK_Warning); | ||
|
||
explicit SourceMgrPrinterBase( | ||
llvm::unique_function<std::string(DataFlowAnalysisType)> &&PrintMessage, | ||
const llvm::Twine &OutFileName, | ||
llvm::SourceMgr::DiagKind WKind = llvm::SourceMgr::DK_Warning); | ||
|
||
protected: | ||
LLVMSourceManager SrcMgr; | ||
|
||
llvm::unique_function<std::string(DataFlowAnalysisType)> GetPrintMessage; | ||
MaybeUniquePtr<llvm::raw_ostream> OS = &llvm::errs(); | ||
llvm::SourceMgr::DiagKind WarningKind; | ||
}; | ||
} // namespace detail | ||
|
||
template <typename AnalysisDomainTy> | ||
class SourceMgrPrinter : public AnalysisPrinterBase<AnalysisDomainTy>, | ||
private detail::SourceMgrPrinterBase { | ||
using n_t = typename AnalysisDomainTy::n_t; | ||
using d_t = typename AnalysisDomainTy::d_t; | ||
using l_t = typename AnalysisDomainTy::l_t; | ||
|
||
public: | ||
explicit SourceMgrPrinter( | ||
llvm::unique_function<std::string(DataFlowAnalysisType)> &&PrintMessage, | ||
llvm::raw_ostream &OS = llvm::errs(), | ||
llvm::SourceMgr::DiagKind WKind = llvm::SourceMgr::DK_Warning) | ||
: detail::SourceMgrPrinterBase(std::move(PrintMessage), OS, WKind) {} | ||
|
||
private: | ||
void doOnResult(n_t Inst, d_t Fact, l_t /*Value*/, | ||
DataFlowAnalysisType AnalysisType) override { | ||
auto SrcLoc = SrcMgr.getDebugLocation(Inst); | ||
if constexpr (std::is_convertible_v<d_t, const llvm::Value *>) { | ||
if (!SrcLoc) { | ||
SrcLoc = | ||
SrcMgr.getDebugLocation(static_cast<const llvm::Value *>(Fact)); | ||
} | ||
} | ||
|
||
if (SrcLoc) { | ||
SrcMgr.print(*OS, *SrcLoc, WarningKind, GetPrintMessage(AnalysisType)); | ||
} | ||
} | ||
}; | ||
|
||
} // namespace psr | ||
#endif |
Oops, something went wrong.