From b9f35dca184fd91ec3037bfde04f66a34f4fa47f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nils=20H=C3=B6lscher?= Date: Fri, 22 Apr 2022 10:35:30 +0200 Subject: [PATCH] Linting and Formatting. removed .misc-no-recursion from linting. --- .clang-tidy | 2 +- CacheAnalysisPass/CacheAnalysisPass.cpp | 24 ++++++++++++------------ include/AbstractCache.h | 17 +++++++++-------- include/AbstractState.h | 9 +++++---- include/CacheType.h | 2 +- 5 files changed, 28 insertions(+), 26 deletions(-) diff --git a/.clang-tidy b/.clang-tidy index e7e0830..31f91a8 100644 --- a/.clang-tidy +++ b/.clang-tidy @@ -1,4 +1,4 @@ -Checks: '-*,clang-diagnostic-*,llvm-*,misc-*,-misc-unused-parameters,-misc-non-private-member-variables-in-classes,readability-identifier-naming' +Checks: '-*,clang-diagnostic-*,llvm-*,misc-*,-misc-unused-parameters,-misc-no-recursion*,-misc-non-private-member-variables-in-classes,readability-identifier-naming' CheckOptions: - key: readability-identifier-naming.ClassCase value: CamelCase diff --git a/CacheAnalysisPass/CacheAnalysisPass.cpp b/CacheAnalysisPass/CacheAnalysisPass.cpp index b56b76c..47a6ed7 100644 --- a/CacheAnalysisPass/CacheAnalysisPass.cpp +++ b/CacheAnalysisPass/CacheAnalysisPass.cpp @@ -28,10 +28,10 @@ #include "llvm/Pass.h" #include "llvm/Passes/PassBuilder.h" #include "llvm/Passes/PassPlugin.h" +#include "llvm/Support/raw_ostream.h" #include #include -#include #include #include "../include/AbstractCache.h" @@ -118,7 +118,7 @@ struct CacheAnalysisPass : PassInfoMixin { unsigned int stringRefToInt(StringRef SR) { unsigned int Length = SR.size(); - unsigned int ret = 0; + unsigned int Ret = 0; unsigned int Count = 1; for (char C : SR) { unsigned int Factor = (unsigned int)pow(10, (Length - Count++)); @@ -126,37 +126,37 @@ struct CacheAnalysisPass : PassInfoMixin { case '0': break; case '1': - ret += Factor; + Ret += Factor; break; case '2': - ret += 2 * Factor; + Ret += 2 * Factor; break; case '3': - ret += 3 * Factor; + Ret += 3 * Factor; break; case '4': - ret += 4 * Factor; + Ret += 4 * Factor; break; case '5': - ret += 5 * Factor; + Ret += 5 * Factor; break; case '6': - ret += 6 * Factor; + Ret += 6 * Factor; break; case '7': - ret += 7 * Factor; + Ret += 7 * Factor; break; case '8': - ret += 8 * Factor; + Ret += 8 * Factor; break; case '9': - ret += 9 * Factor; + Ret += 9 * Factor; break; default: errs() << "StringRef is not a decimal number"; }; } - return ret; + return Ret; } void addressCollector(Module &M) { diff --git a/include/AbstractCache.h b/include/AbstractCache.h index 73cf13a..f4b47e5 100644 --- a/include/AbstractCache.h +++ b/include/AbstractCache.h @@ -6,12 +6,13 @@ #include #include #include -#include -#include #include #include #include +#include +#include + #include "AbstractState.h" #include "Address.h" #include "ConcreteState.h" @@ -48,10 +49,10 @@ public: // everything is public, because IDGAF } void fillAbstractCache(unsigned int NodeNr) { - Nodes[NodeNr].computed = true; + Nodes[NodeNr].Computed = true; for (unsigned int SuccNr : Nodes[NodeNr].Successors) { Nodes[SuccNr]; - if (Nodes[SuccNr].computed) { + if (Nodes[SuccNr].Computed) { // Join don't call Nodes[SuccNr].mustJoin(Nodes[NodeNr]); Nodes[SuccNr].mustJoin(AbstractState(NodeNr)); @@ -67,10 +68,10 @@ public: // everything is public, because IDGAF unsigned int collectHits() { unsigned int Hits = 0; for (auto const &E : Edges) { - auto predecessor = Nodes[E.first]; + auto Predecessor = Nodes[E.first]; for (unsigned int SuccessorAddr : E.second) { // When successors Address is in predecessor, we have a Hit. - Hits += predecessor.isHit(Address(SuccessorAddr)) ? 1 : 0; + Hits += Predecessor.isHit(Address(SuccessorAddr)) ? 1 : 0; } } return Hits; @@ -79,10 +80,10 @@ public: // everything is public, because IDGAF unsigned int collectMisses() { unsigned int Misses = 0; for (auto const &E : Edges) { - auto predecessor = Nodes[E.first]; + auto Predecessor = Nodes[E.first]; for (unsigned int SuccessorAddr : E.second) { // When successors Address is in predecessor, we have a Hit. - Misses += predecessor.isHit(Address(SuccessorAddr)) ? 0 : 1; + Misses += Predecessor.isHit(Address(SuccessorAddr)) ? 0 : 1; } } return Misses; diff --git a/include/AbstractState.h b/include/AbstractState.h index d818aa8..3251353 100644 --- a/include/AbstractState.h +++ b/include/AbstractState.h @@ -6,12 +6,13 @@ #include #include #include -#include #include #include #include #include +#include + #include "Address.h" // Forward declarations @@ -27,7 +28,7 @@ public: // everything is public, because IDGAF unsigned int Addr; - bool computed = false; + bool Computed = false; // Only entries below this comment are needed for the exercise. @@ -110,8 +111,8 @@ public: // everything is public, because IDGAF * @param Addr , Address */ void update(Address Addr) { - for (int i = 3; i > 0; i--) { - Sets[Addr.Index].Associativity[i] = Sets[Addr.Index].Associativity[i - 1]; + for (int I = 3; I > 0; I--) { + Sets[Addr.Index].Associativity[I] = Sets[Addr.Index].Associativity[I - 1]; } Sets[Addr.Index].Associativity[0].Blocks = {Addr.Tag}; } diff --git a/include/CacheType.h b/include/CacheType.h index ad36b8b..e0f626a 100644 --- a/include/CacheType.h +++ b/include/CacheType.h @@ -15,7 +15,7 @@ class CacheType; */ class CacheType { public: - bool isPower2(int n) { return n && !(n & (n - 1)); } + bool isPower2(int N) { return N && !(N & (N - 1)); } int Sets; // n Sets int Associativity; // m Associativity