diff --git a/include/phasar/PhasarLLVM/Passes/GeneralStatisticsAnalysis.h b/include/phasar/PhasarLLVM/Passes/GeneralStatisticsAnalysis.h index ee07db14eb..25b71b3de1 100644 --- a/include/phasar/PhasarLLVM/Passes/GeneralStatisticsAnalysis.h +++ b/include/phasar/PhasarLLVM/Passes/GeneralStatisticsAnalysis.h @@ -34,19 +34,19 @@ namespace psr { class GeneralStatistics { private: friend class GeneralStatisticsAnalysis; - size_t functions = 0; - size_t globals = 0; - size_t basicblocks = 0; - size_t allocationsites = 0; - size_t callsites = 0; - size_t instructions = 0; - size_t storeInstructions = 0; - size_t loadInstructions = 0; - size_t memIntrinsic = 0; - size_t globalPointers = 0; - std::set allocatedTypes; - std::set allocaInstructions; - std::set retResInstructions; + size_t Functions = 0; + size_t Globals = 0; + size_t BasicBlocks = 0; + size_t AllocationSites = 0; + size_t CallSites = 0; + size_t Instructions = 0; + size_t StoreInstructions = 0; + size_t LoadInstructions = 0; + size_t MemIntrinsics = 0; + size_t GlobalPointers = 0; + std::set AllocatedTypes; + std::set AllocaInstructions; + std::set RetResInstructions; public: /** @@ -145,7 +145,7 @@ class GeneralStatisticsAnalysis /// The pass itself stores the results. using Result = GeneralStatistics; - explicit GeneralStatisticsAnalysis(); + explicit GeneralStatisticsAnalysis() = default; GeneralStatistics run(llvm::Module &M, llvm::ModuleAnalysisManager &AM); }; diff --git a/include/phasar/PhasarPass/PhasarPass.h b/include/phasar/PhasarPass/PhasarPass.h index c3879ad031..d8272b98c3 100644 --- a/include/phasar/PhasarPass/PhasarPass.h +++ b/include/phasar/PhasarPass/PhasarPass.h @@ -22,7 +22,7 @@ namespace psr { class PhasarPass : public llvm::ModulePass { public: - static char ID; + static inline char ID = 12; explicit PhasarPass(); PhasarPass(const PhasarPass &) = delete; diff --git a/include/phasar/PhasarPass/PhasarPrinterPass.h b/include/phasar/PhasarPass/PhasarPrinterPass.h index 48182b340f..76baa2f9a6 100644 --- a/include/phasar/PhasarPass/PhasarPrinterPass.h +++ b/include/phasar/PhasarPass/PhasarPrinterPass.h @@ -21,7 +21,7 @@ namespace psr { class PhasarPrinterPass : public llvm::ModulePass { public: - static char ID; + static inline char ID = 12; // NOLINT FIXME: make const when LLVM supports it explicit PhasarPrinterPass(); PhasarPrinterPass(const PhasarPrinterPass &) = delete; diff --git a/lib/PhasarLLVM/Passes/ExampleModulePass.cpp b/lib/PhasarLLVM/Passes/ExampleModulePass.cpp index e17f419af9..69cfadb498 100644 --- a/lib/PhasarLLVM/Passes/ExampleModulePass.cpp +++ b/lib/PhasarLLVM/Passes/ExampleModulePass.cpp @@ -23,7 +23,8 @@ llvm::AnalysisKey ExampleModulePass::Key; ExampleModulePass::ExampleModulePass() = default; llvm::PreservedAnalyses -ExampleModulePass::run(llvm::Module &M, llvm::ModuleAnalysisManager &MAM) { +ExampleModulePass::run(llvm::Module & /*M*/, + llvm::ModuleAnalysisManager & /*MAM*/) { cout << "ExampleModulePass::run()\n"; return llvm::PreservedAnalyses::all(); } diff --git a/lib/PhasarLLVM/Passes/GeneralStatisticsAnalysis.cpp b/lib/PhasarLLVM/Passes/GeneralStatisticsAnalysis.cpp index 4e534bd88e..274fda8feb 100644 --- a/lib/PhasarLLVM/Passes/GeneralStatisticsAnalysis.cpp +++ b/lib/PhasarLLVM/Passes/GeneralStatisticsAnalysis.cpp @@ -35,32 +35,29 @@ using namespace psr; namespace psr { -llvm::AnalysisKey GeneralStatisticsAnalysis::Key; - -GeneralStatisticsAnalysis::GeneralStatisticsAnalysis() = default; - +llvm::AnalysisKey GeneralStatisticsAnalysis::Key; // NOLINT GeneralStatistics GeneralStatisticsAnalysis::run(llvm::Module &M, - llvm::ModuleAnalysisManager &AM) { + llvm::ModuleAnalysisManager & /*AM*/) { LOG_IF_ENABLE(BOOST_LOG_SEV(lg::get(), INFO) << "Running GeneralStatisticsAnalysis"); static const std::set MemAllocatingFunctions = { "operator new(unsigned long)", "operator new[](unsigned long)", "malloc", "calloc", "realloc"}; for (auto &F : M) { - ++Stats.functions; + ++Stats.Functions; for (auto &BB : F) { - ++Stats.basicblocks; + ++Stats.BasicBlocks; for (auto &I : BB) { // found one more instruction - ++Stats.instructions; + ++Stats.Instructions; // check for alloca instruction for possible types if (const llvm::AllocaInst *Alloc = llvm::dyn_cast(&I)) { - Stats.allocatedTypes.insert(Alloc->getAllocatedType()); + Stats.AllocatedTypes.insert(Alloc->getAllocatedType()); // do not add allocas from llvm internal functions - Stats.allocaInstructions.insert(&I); - ++Stats.allocationsites; + Stats.AllocaInstructions.insert(&I); + ++Stats.AllocationSites; } // check bitcast instructions for possible types else { for (auto *User : I.users()) { @@ -72,30 +69,30 @@ GeneralStatisticsAnalysis::run(llvm::Module &M, } // check for return or resume instructions if (llvm::isa(I) || llvm::isa(I)) { - Stats.retResInstructions.insert(&I); + Stats.RetResInstructions.insert(&I); } // check for store instructions if (llvm::isa(I)) { - ++Stats.storeInstructions; + ++Stats.StoreInstructions; } // check for load instructions if (llvm::isa(I)) { - ++Stats.loadInstructions; + ++Stats.LoadInstructions; } // check for llvm's memory intrinsics if (llvm::isa(I)) { - ++Stats.memIntrinsic; + ++Stats.MemIntrinsics; } // check for function calls if (llvm::isa(I) || llvm::isa(I)) { - ++Stats.callsites; + ++Stats.CallSites; const llvm::CallBase *CallSite = llvm::cast(&I); if (CallSite->getCalledFunction()) { if (MemAllocatingFunctions.count(llvm::demangle( CallSite->getCalledFunction()->getName().str()))) { // do not add allocas from llvm internal functions - Stats.allocaInstructions.insert(&I); - ++Stats.allocationsites; + Stats.AllocaInstructions.insert(&I); + ++Stats.AllocationSites; // check if an instance of a user-defined type is allocated on the // heap for (auto *User : I.users()) { @@ -113,7 +110,7 @@ GeneralStatisticsAnalysis::run(llvm::Module &M, if (CTor->getCalledFunction() && getNthFunctionArgument(CTor->getCalledFunction(), 0) ->getType() == Cast->getDestTy()) { - Stats.allocatedTypes.insert( + Stats.AllocatedTypes.insert( Cast->getDestTy()->getPointerElementType()); } } @@ -130,9 +127,9 @@ GeneralStatisticsAnalysis::run(llvm::Module &M, // check for global pointers for (auto &Global : M.globals()) { if (Global.getType()->isPointerTy()) { - ++Stats.globalPointers; + ++Stats.GlobalPointers; } - ++Stats.globals; + ++Stats.Globals; } // register stuff in PAMM // For performance reasons (and out of sheer convenience) we simply initialize @@ -163,29 +160,29 @@ GeneralStatisticsAnalysis::run(llvm::Module &M, << "GeneralStatisticsAnalysis summary for module: '" << M.getName().str() << "'"); LOG_IF_ENABLE(BOOST_LOG_SEV(lg::get(), INFO) - << "Instructions : " << Stats.instructions); + << "Instructions : " << Stats.Instructions); LOG_IF_ENABLE(BOOST_LOG_SEV(lg::get(), INFO) - << "Allocated Types : " << Stats.allocatedTypes.size()); + << "Allocated Types : " << Stats.AllocatedTypes.size()); LOG_IF_ENABLE(BOOST_LOG_SEV(lg::get(), INFO) - << "Allocation Sites : " << Stats.allocationsites); + << "Allocation Sites : " << Stats.AllocationSites); LOG_IF_ENABLE(BOOST_LOG_SEV(lg::get(), INFO) - << "Basic Blocks : " << Stats.basicblocks); + << "Basic Blocks : " << Stats.BasicBlocks); LOG_IF_ENABLE(BOOST_LOG_SEV(lg::get(), INFO) - << "Calls Sites : " << Stats.callsites); + << "Calls Sites : " << Stats.CallSites); LOG_IF_ENABLE(BOOST_LOG_SEV(lg::get(), INFO) - << "Functions : " << Stats.functions); + << "Functions : " << Stats.Functions); LOG_IF_ENABLE(BOOST_LOG_SEV(lg::get(), INFO) - << "Globals : " << Stats.globals); + << "Globals : " << Stats.Globals); LOG_IF_ENABLE(BOOST_LOG_SEV(lg::get(), INFO) - << "Global Pointer : " << Stats.globalPointers); + << "Global Pointer : " << Stats.GlobalPointers); LOG_IF_ENABLE(BOOST_LOG_SEV(lg::get(), INFO) - << "Memory Intrinsics : " << Stats.memIntrinsic); + << "Memory Intrinsics : " << Stats.MemIntrinsics); LOG_IF_ENABLE(BOOST_LOG_SEV(lg::get(), INFO) - << "Store Instructions : " << Stats.storeInstructions); + << "Store Instructions : " << Stats.StoreInstructions); LOG_IF_ENABLE(BOOST_LOG_SEV(lg::get(), INFO) << ' '); LOG_IF_ENABLE(BOOST_LOG_SEV(lg::get(), INFO) - << "Allocated Types << " << Stats.allocatedTypes.size()); - for (const auto *Type : Stats.allocatedTypes) { + << "Allocated Types << " << Stats.AllocatedTypes.size()); + for (const auto *Type : Stats.AllocatedTypes) { std::string TypeStr; llvm::raw_string_ostream Rso(TypeStr); Type->print(Rso); @@ -196,38 +193,38 @@ GeneralStatisticsAnalysis::run(llvm::Module &M, return Stats; } -size_t GeneralStatistics::getAllocationsites() const { return allocationsites; } +size_t GeneralStatistics::getAllocationsites() const { return AllocationSites; } -size_t GeneralStatistics::getFunctioncalls() const { return callsites; } +size_t GeneralStatistics::getFunctioncalls() const { return CallSites; } -size_t GeneralStatistics::getInstructions() const { return instructions; } +size_t GeneralStatistics::getInstructions() const { return Instructions; } -size_t GeneralStatistics::getGlobalPointers() const { return globalPointers; } +size_t GeneralStatistics::getGlobalPointers() const { return GlobalPointers; } -size_t GeneralStatistics::getBasicBlocks() const { return basicblocks; } +size_t GeneralStatistics::getBasicBlocks() const { return BasicBlocks; } -size_t GeneralStatistics::getFunctions() const { return functions; } +size_t GeneralStatistics::getFunctions() const { return Functions; } -size_t GeneralStatistics::getGlobals() const { return globals; } +size_t GeneralStatistics::getGlobals() const { return Globals; } -size_t GeneralStatistics::getMemoryIntrinsics() const { return memIntrinsic; } +size_t GeneralStatistics::getMemoryIntrinsics() const { return MemIntrinsics; } size_t GeneralStatistics::getStoreInstructions() const { - return storeInstructions; + return StoreInstructions; } set GeneralStatistics::getAllocatedTypes() const { - return allocatedTypes; + return AllocatedTypes; } set GeneralStatistics::getAllocaInstructions() const { - return allocaInstructions; + return AllocaInstructions; } set GeneralStatistics::getRetResInstructions() const { - return retResInstructions; + return RetResInstructions; } } // namespace psr diff --git a/lib/PhasarLLVM/Passes/ValueAnnotationPass.cpp b/lib/PhasarLLVM/Passes/ValueAnnotationPass.cpp index f21dd79de1..ec5221facf 100644 --- a/lib/PhasarLLVM/Passes/ValueAnnotationPass.cpp +++ b/lib/PhasarLLVM/Passes/ValueAnnotationPass.cpp @@ -42,7 +42,8 @@ size_t ValueAnnotationPass::UniqueValueId = 0; ValueAnnotationPass::ValueAnnotationPass() = default; llvm::PreservedAnalyses -ValueAnnotationPass::run(llvm::Module &M, llvm::ModuleAnalysisManager &AM) { +ValueAnnotationPass::run(llvm::Module &M, + llvm::ModuleAnalysisManager & /*AM*/) { LOG_IF_ENABLE(BOOST_LOG_SEV(lg::get(), INFO) << "Running ValueAnnotationPass"); auto &Context = M.getContext(); diff --git a/lib/PhasarPass/PhasarPass.cpp b/lib/PhasarPass/PhasarPass.cpp index 7961c40890..9c6ccd10ab 100644 --- a/lib/PhasarPass/PhasarPass.cpp +++ b/lib/PhasarPass/PhasarPass.cpp @@ -48,8 +48,6 @@ namespace psr { -char PhasarPass::ID = 12; - PhasarPass::PhasarPass() : llvm::ModulePass(ID) {} llvm::StringRef PhasarPass::getPassName() const { return "PhasarPass"; } @@ -181,7 +179,7 @@ bool PhasarPass::runOnModule(llvm::Module &M) { return false; } -bool PhasarPass::doInitialization(llvm::Module &M) { +bool PhasarPass::doInitialization(llvm::Module & /*M*/) { llvm::outs() << "PhasarPass::doInitialization()\n"; initializeLogger(InitLogger); // check the user's parameters @@ -198,7 +196,7 @@ bool PhasarPass::doInitialization(llvm::Module &M) { return false; } -bool PhasarPass::doFinalization(llvm::Module &M) { +bool PhasarPass::doFinalization(llvm::Module & /*M*/) { llvm::outs() << "PhasarPass::doFinalization()\n"; return false; } @@ -207,12 +205,12 @@ void PhasarPass::getAnalysisUsage(llvm::AnalysisUsage &AU) const {} void PhasarPass::releaseMemory() {} -void PhasarPass::print(llvm::raw_ostream &O, const llvm::Module *M) const { +void PhasarPass::print(llvm::raw_ostream &O, const llvm::Module * /*M*/) const { O << "I am a PhasarPass Analysis Result ;-)\n"; } -static llvm::RegisterPass Phasar("phasar", "PhASAR Pass", - false /* Only looks at CFG */, - false /* Analysis Pass */); +static const llvm::RegisterPass + Phasar("phasar", "PhASAR Pass", false /* Only looks at CFG */, + false /* Analysis Pass */); } // namespace psr diff --git a/lib/PhasarPass/PhasarPrinterPass.cpp b/lib/PhasarPass/PhasarPrinterPass.cpp index 4045090b3d..2ee495bb31 100644 --- a/lib/PhasarPass/PhasarPrinterPass.cpp +++ b/lib/PhasarPass/PhasarPrinterPass.cpp @@ -17,8 +17,6 @@ namespace psr { -char PhasarPrinterPass::ID = 12; - PhasarPrinterPass::PhasarPrinterPass() : llvm::ModulePass(ID) {} llvm::StringRef PhasarPrinterPass::getPassName() const { @@ -32,12 +30,12 @@ bool PhasarPrinterPass::runOnModule(llvm::Module &M) { return false; } -bool PhasarPrinterPass::doInitialization(llvm::Module &M) { +bool PhasarPrinterPass::doInitialization(llvm::Module & /*M*/) { llvm::outs() << "PhasarPrinterPass::doInitialization()\n"; return false; } -bool PhasarPrinterPass::doFinalization(llvm::Module &M) { +bool PhasarPrinterPass::doFinalization(llvm::Module & /*M*/) { llvm::outs() << "PhasarPrinterPass::doFinalization()\n"; return false; }