Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .clang-tidy
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ Checks: '-*,
-readability-function-cognitive-complexity,
-readability-convert-member-functions-to-static,
-readability-isolate-declaration,
-readability-identifier-length,
cppcoreguidelines-*,
-cppcoreguidelines-avoid-non-const-global-variables,
-cppcoreguidelines-pro-bounds-array-to-pointer-decay,
Expand Down
5 changes: 5 additions & 0 deletions include/phasar/DB/ProjectIRDB.h
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,11 @@ class ProjectIRDB {
persistedStringToValue(const std::string &StringRep) const;
};

/**
* Revserses the getMetaDataID function
*/
const llvm::Value *fromMetaDataId(const ProjectIRDB &IRDB, llvm::StringRef Id);

} // namespace psr

#endif
2 changes: 1 addition & 1 deletion include/phasar/PhasarLLVM/ControlFlow/LLVMBasedCFG.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
#include "llvm/IR/Function.h"

#include "phasar/PhasarLLVM/ControlFlow/CFG.h"
#include "phasar/Utils/LLVMIRToSrc.h"
#include "phasar/PhasarLLVM/Utils/LLVMIRToSrc.h"

#include "nlohmann/json.hpp"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
#include <type_traits>

#include "phasar/PhasarLLVM/Utils/BinaryDomain.h"
#include "phasar/Utils/LLVMShorthands.h"
#include "phasar/PhasarLLVM/Utils/LLVMShorthands.h"

namespace psr {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

#include "phasar/PhasarLLVM/DataFlowSolver/IfdsIde/FlowFunctions.h"
#include "phasar/PhasarLLVM/DataFlowSolver/IfdsIde/LLVMZeroValue.h"
#include "phasar/Utils/LLVMShorthands.h"
#include "phasar/PhasarLLVM/Utils/LLVMShorthands.h"

namespace llvm {
class Value;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@

#include "phasar/PhasarLLVM/DataFlowSolver/IfdsIde/LLVMZeroValue.h"
#include "phasar/PhasarLLVM/Pointer/LLVMPointsToInfo.h"
#include "phasar/Utils/LLVMShorthands.h"
#include "phasar/PhasarLLVM/Utils/LLVMShorthands.h"

namespace psr {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@
#include "phasar/PhasarLLVM/TaintConfig/TaintConfig.h"
#include "phasar/PhasarLLVM/TypeHierarchy/LLVMTypeHierarchy.h"
#include "phasar/PhasarLLVM/Utils/BasicBlockOrdering.h"
#include "phasar/PhasarLLVM/Utils/LLVMShorthands.h"
#include "phasar/PhasarLLVM/Utils/LatticeDomain.h"
#include "phasar/Utils/LLVMShorthands.h"
#include "phasar/Utils/Logger.h"

namespace psr {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

#include "phasar/PhasarLLVM/DataFlowSolver/IfdsIde/FlowFunctions.h"
#include "phasar/PhasarLLVM/DataFlowSolver/IfdsIde/LLVMZeroValue.h"
#include "phasar/Utils/LLVMShorthands.h"
#include "phasar/PhasarLLVM/Utils/LLVMShorthands.h"

namespace llvm {
class CallBase;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,10 @@
#include "phasar/PhasarLLVM/Pointer/LLVMPointsToInfo.h"
#include "phasar/PhasarLLVM/Pointer/LLVMPointsToUtils.h"
#include "phasar/PhasarLLVM/TypeHierarchy/LLVMTypeHierarchy.h"
#include "phasar/PhasarLLVM/Utils/LLVMIRToSrc.h"
#include "phasar/PhasarLLVM/Utils/LLVMShorthands.h"
#include "phasar/PhasarLLVM/Utils/LatticeDomain.h"
#include "phasar/Utils/BitVectorSet.h"
#include "phasar/Utils/LLVMIRToSrc.h"
#include "phasar/Utils/LLVMShorthands.h"
#include "phasar/Utils/Logger.h"

// have some handy helper functionalities
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
#include "phasar/PhasarLLVM/Domain/AnalysisDomain.h"
#include "phasar/PhasarLLVM/Domain/ExtendedValue.h"
#include "phasar/PhasarLLVM/TaintConfig/TaintConfig.h"
#include "phasar/Utils/LLVMShorthands.h"
#include "phasar/PhasarLLVM/Utils/LLVMShorthands.h"

namespace llvm {
class Value;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
#include "phasar/PhasarLLVM/DataFlowSolver/IfdsIde/Solver/PathEdge.h"
#include "phasar/PhasarLLVM/Domain/AnalysisDomain.h"
#include "phasar/PhasarLLVM/Utils/DOTGraph.h"
#include "phasar/Utils/LLVMShorthands.h"
#include "phasar/PhasarLLVM/Utils/LLVMShorthands.h"
#include "phasar/Utils/Logger.h"
#include "phasar/Utils/PAMMMacros.h"
#include "phasar/Utils/Table.h"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
#include "llvm/ADT/SmallVector.h"

#include "phasar/PhasarLLVM/DataFlowSolver/IfdsIde/EdgeFunctions.h"
#include "phasar/Utils/LLVMShorthands.h"
#include "phasar/PhasarLLVM/Utils/LLVMShorthands.h"
#include "phasar/Utils/Logger.h"
#include "phasar/Utils/Table.h"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
#include <initializer_list>

#include "boost/functional/hash.hpp"
#include "phasar/Utils/LLVMShorthands.h"
#include "phasar/PhasarLLVM/Utils/LLVMShorthands.h"

namespace psr {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@

#include "phasar/PhasarLLVM/DataFlowSolver/Mono/Contexts/CallStringCTX.h"
#include "phasar/PhasarLLVM/DataFlowSolver/Mono/InterMonoProblem.h"
#include "phasar/Utils/LLVMShorthands.h"
#include "phasar/PhasarLLVM/Utils/LLVMShorthands.h"

namespace psr {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
#include "phasar/PhasarLLVM/DataFlowSolver/IfdsIde/Solver/PathEdge.h"
#include "phasar/PhasarLLVM/DataFlowSolver/WPDS/JoinLatticeToSemiRingElem.h"
#include "phasar/PhasarLLVM/DataFlowSolver/WPDS/WPDSProblem.h"
#include "phasar/Utils/LLVMShorthands.h"
#include "phasar/PhasarLLVM/Utils/LLVMShorthands.h"
#include "phasar/Utils/Logger.h"
#include "phasar/Utils/Table.h"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
#include "llvm/IR/Instructions.h"

#include "phasar/PhasarLLVM/TaintConfig/TaintConfig.h"
#include "phasar/Utils/LLVMShorthands.h"
#include "phasar/PhasarLLVM/Utils/LLVMShorthands.h"

namespace psr {
template <typename ContainerTy,
Expand Down
2 changes: 0 additions & 2 deletions include/phasar/PhasarLLVM/Utils/BasicBlockOrdering.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@
#include "llvm/ADT/DenseMap.h"
#include "llvm/ADT/FunctionExtras.h"

#include "phasar/DB/ProjectIRDB.h"

namespace llvm {
class Function;
class BasicBlock;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
#include "llvm/IR/ModuleSlotTracker.h"
#include "llvm/IR/Value.h"

#include "phasar/DB/ProjectIRDB.h"
#include "phasar/Utils/Utilities.h"

namespace psr {
Expand Down Expand Up @@ -95,11 +94,6 @@ globalValuesUsedinFunction(const llvm::Function *F);
*/
std::string getMetaDataID(const llvm::Value *V);

/**
* Revserses the getMetaDataID function
*/
const llvm::Value *fromMetaDataId(const ProjectIRDB &IRDB, llvm::StringRef Id);

/**
* @brief Does less-than comparison based on the annotated ID.
*
Expand Down
2 changes: 1 addition & 1 deletion include/phasar/Utils/DebugOutput.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
#include "llvm/Support/raw_os_ostream.h"
#include "llvm/Support/raw_ostream.h"

#include "phasar/Utils/LLVMShorthands.h"
#include "phasar/PhasarLLVM/Utils/LLVMShorthands.h"
#include "phasar/Utils/TypeTraits.h"

namespace psr {
Expand Down
7 changes: 5 additions & 2 deletions include/phasar/Utils/PAMM.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
#ifndef PHASAR_UTILS_PAMM_H_
#define PHASAR_UTILS_PAMM_H_

#include "boost/program_options/variables_map.hpp"

#include <chrono> // high_resolution_clock::time_point, milliseconds
#include <set> // set
#include <string> // string
Expand All @@ -25,7 +27,7 @@

namespace llvm {
class raw_ostream;
}
} // namespace llvm

namespace psr {

Expand Down Expand Up @@ -188,7 +190,8 @@ class PAMM {
/// \brief Exports the measured data to JSON - associated macro:
/// EXPORT_MEASURED_DATA(PATH).
/// \param OutputPath to exported JSON file.
void exportMeasuredData(std::string OutputPath);
void exportMeasuredData(std::string OutputPath,
boost::program_options::variables_map &Config);
};

} // namespace psr
Expand Down
5 changes: 2 additions & 3 deletions include/phasar/Utils/Utilities.h
Original file line number Diff line number Diff line change
Expand Up @@ -162,9 +162,8 @@ struct StringIDLess {
template <typename Fn> class scope_exit { // NOLINT
public:
template <typename FFn, typename = decltype(std::declval<FFn>()())>
explicit scope_exit(FFn &&F) noexcept(
std::is_nothrow_constructible_v<Fn, FFn> ||
std::is_nothrow_constructible_v<Fn, FFn &>)
scope_exit(FFn &&F) noexcept(std::is_nothrow_constructible_v<Fn, FFn> ||
std::is_nothrow_constructible_v<Fn, FFn &>)
: F(std::forward<FFn>(F)) {}

~scope_exit() { F(); }
Expand Down
4 changes: 4 additions & 0 deletions lib/Config/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
file(GLOB_RECURSE CONFIG_SRC *.h *.cpp)

set(PHASAR_LINK_LIBS
phasar_utils
)

set(LLVM_LINK_COMPONENTS
Support
)
Expand Down
1 change: 1 addition & 0 deletions lib/DB/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ include_directories(
set(PHASAR_LINK_LIBS
phasar_passes
phasar_utils
phasar_phasarllvm_utils
)

set(LLVM_LINK_COMPONENTS
Expand Down
2 changes: 1 addition & 1 deletion lib/DB/DBConn.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@
#include "phasar/DB/Hexastore.h"
#include "phasar/PhasarLLVM/Pointer/VTable.h"

#include "phasar/PhasarLLVM/Utils/LLVMShorthands.h"
#include "phasar/Utils/IO.h"
#include "phasar/Utils/LLVMShorthands.h"
#include "phasar/Utils/Logger.h"
#include "phasar/Utils/Macros.h"

Expand Down
44 changes: 43 additions & 1 deletion lib/DB/ProjectIRDB.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

#include <algorithm>
#include <cassert>
#include <charconv>
#include <filesystem>
#include <ostream>
#include <string>
Expand All @@ -31,9 +32,9 @@
#include "phasar/PhasarLLVM/DataFlowSolver/IfdsIde/LLVMZeroValue.h"
#include "phasar/PhasarLLVM/Passes/GeneralStatisticsAnalysis.h"
#include "phasar/PhasarLLVM/Passes/ValueAnnotationPass.h"
#include "phasar/PhasarLLVM/Utils/LLVMShorthands.h"
#include "phasar/Utils/EnumFlags.h"
#include "phasar/Utils/IO.h"
#include "phasar/Utils/LLVMShorthands.h"
#include "phasar/Utils/Logger.h"
#include "phasar/Utils/PAMMMacros.h"
#include "phasar/Utils/Utilities.h"
Expand Down Expand Up @@ -551,3 +552,44 @@ bool ProjectIRDB::debugInfoAvailable() const {
}

} // namespace psr

const llvm::Value *psr::fromMetaDataId(const ProjectIRDB &IRDB,
llvm::StringRef Id) {
if (Id.empty() || Id[0] == '-') {
return nullptr;
}

auto ParseInt = [](llvm::StringRef Str) -> std::optional<unsigned> {
unsigned Num;
auto [Ptr, EC] = std::from_chars(Str.data(), Str.data() + Str.size(), Num);

if (EC == std::errc{}) {
return Num;
}

PHASAR_LOG_LEVEL(WARNING, "Invalid metadata id '"
<< Str.str() << "': "
<< std::make_error_code(EC).message());
return std::nullopt;
};

if (auto Dot = Id.find('.'); Dot != llvm::StringRef::npos) {
auto FName = Id.slice(0, Dot);

auto ArgNr = ParseInt(Id.drop_front(Dot + 1));

if (!ArgNr) {
return nullptr;
}

const auto *F = IRDB.getFunction(FName);
if (F) {
return getNthFunctionArgument(F, *ArgNr);
}

return nullptr;
}

auto IdNr = ParseInt(Id);
return IdNr ? IRDB.getInstruction(*IdNr) : nullptr;
}
2 changes: 1 addition & 1 deletion lib/PhasarLLVM/ControlFlow/LLVMBasedBackwardCFG.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

#include "phasar/Config/Configuration.h"
#include "phasar/PhasarLLVM/ControlFlow/LLVMBasedBackwardCFG.h"
#include "phasar/Utils/LLVMShorthands.h"
#include "phasar/PhasarLLVM/Utils/LLVMShorthands.h"

using namespace psr;
using namespace std;
Expand Down
2 changes: 1 addition & 1 deletion lib/PhasarLLVM/ControlFlow/LLVMBasedBackwardICFG.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
#include "phasar/PhasarLLVM/ControlFlow/LLVMBasedBackwardICFG.h"
#include "phasar/PhasarLLVM/ControlFlow/LLVMBasedICFG.h"
#include "phasar/PhasarLLVM/TypeHierarchy/LLVMTypeHierarchy.h"
#include "phasar/Utils/LLVMShorthands.h"
#include "phasar/PhasarLLVM/Utils/LLVMShorthands.h"
#include "phasar/Utils/Logger.h"
#include "phasar/Utils/PAMM.h"
#include "phasar/Utils/Utilities.h"
Expand Down
2 changes: 1 addition & 1 deletion lib/PhasarLLVM/ControlFlow/LLVMBasedCFG.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
#include "nlohmann/json.hpp"
#include "phasar/Config/Configuration.h"
#include "phasar/PhasarLLVM/ControlFlow/LLVMBasedCFG.h"
#include "phasar/Utils/LLVMShorthands.h"
#include "phasar/PhasarLLVM/Utils/LLVMShorthands.h"
#include "phasar/Utils/Logger.h"
#include "phasar/Utils/Utilities.h"

Expand Down
4 changes: 2 additions & 2 deletions lib/PhasarLLVM/ControlFlow/LLVMBasedICFG.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,9 @@
#include "phasar/PhasarLLVM/Pointer/LLVMPointsToSet.h"
#include "phasar/PhasarLLVM/TypeHierarchy/LLVMTypeHierarchy.h"
#include "phasar/PhasarLLVM/TypeHierarchy/LLVMVFTable.h"
#include "phasar/PhasarLLVM/Utils/LLVMIRToSrc.h"
#include "phasar/PhasarLLVM/Utils/LLVMShorthands.h"
#include "phasar/PhasarPass/Options.h"
#include "phasar/Utils/LLVMIRToSrc.h"
#include "phasar/Utils/LLVMShorthands.h"
#include "phasar/Utils/Logger.h"
#include "phasar/Utils/NlohmannLogging.h"
#include "phasar/Utils/PAMMMacros.h"
Expand Down
2 changes: 1 addition & 1 deletion lib/PhasarLLVM/ControlFlow/Resolver/CHAResolver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

#include "phasar/PhasarLLVM/ControlFlow/Resolver/CHAResolver.h"
#include "phasar/PhasarLLVM/TypeHierarchy/LLVMTypeHierarchy.h"
#include "phasar/Utils/LLVMShorthands.h"
#include "phasar/PhasarLLVM/Utils/LLVMShorthands.h"
#include "phasar/Utils/Logger.h"

using namespace std;
Expand Down
2 changes: 1 addition & 1 deletion lib/PhasarLLVM/ControlFlow/Resolver/DTAResolver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@

#include "phasar/PhasarLLVM/ControlFlow/Resolver/DTAResolver.h"
#include "phasar/PhasarLLVM/TypeHierarchy/LLVMTypeHierarchy.h"
#include "phasar/Utils/LLVMShorthands.h"
#include "phasar/PhasarLLVM/Utils/LLVMShorthands.h"
#include "phasar/Utils/Logger.h"
#include "phasar/Utils/Utilities.h"

Expand Down
2 changes: 1 addition & 1 deletion lib/PhasarLLVM/ControlFlow/Resolver/OTFResolver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
#include "phasar/PhasarLLVM/Pointer/LLVMPointsToGraph.h"
#include "phasar/PhasarLLVM/Pointer/LLVMPointsToInfo.h"
#include "phasar/PhasarLLVM/TypeHierarchy/LLVMTypeHierarchy.h"
#include "phasar/Utils/LLVMShorthands.h"
#include "phasar/PhasarLLVM/Utils/LLVMShorthands.h"
#include "phasar/Utils/Logger.h"
#include "phasar/Utils/Utilities.h"

Expand Down
2 changes: 1 addition & 1 deletion lib/PhasarLLVM/ControlFlow/Resolver/RTAResolver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
#include "phasar/DB/ProjectIRDB.h"
#include "phasar/PhasarLLVM/ControlFlow/Resolver/RTAResolver.h"
#include "phasar/PhasarLLVM/TypeHierarchy/LLVMTypeHierarchy.h"
#include "phasar/Utils/LLVMShorthands.h"
#include "phasar/PhasarLLVM/Utils/LLVMShorthands.h"
#include "phasar/Utils/Logger.h"
#include "phasar/Utils/Utilities.h"

Expand Down
Loading