[polly] r287963 - [ScopDectionDiagnostic] Use scoped enums instead three letter prefix [NFC]

Tobias Grosser via llvm-commits llvm-commits at lists.llvm.org
Fri Nov 25 19:44:32 PST 2016


Author: grosser
Date: Fri Nov 25 21:44:31 2016
New Revision: 287963

URL: http://llvm.org/viewvc/llvm-project?rev=287963&view=rev
Log:
[ScopDectionDiagnostic] Use scoped enums instead three letter prefix [NFC]

This improves readability of the code.

Modified:
    polly/trunk/include/polly/ScopDetectionDiagnostic.h
    polly/trunk/lib/Analysis/ScopDetectionDiagnostic.cpp

Modified: polly/trunk/include/polly/ScopDetectionDiagnostic.h
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/include/polly/ScopDetectionDiagnostic.h?rev=287963&r1=287962&r2=287963&view=diff
==============================================================================
--- polly/trunk/include/polly/ScopDetectionDiagnostic.h (original)
+++ polly/trunk/include/polly/ScopDetectionDiagnostic.h Fri Nov 25 21:44:31 2016
@@ -62,43 +62,43 @@ class RejectLog;
 void emitRejectionRemarks(const BBPair &P, const RejectLog &Log);
 
 // Discriminator for LLVM-style RTTI (dyn_cast<> et al.)
-enum RejectReasonKind {
+enum class RejectReasonKind {
   // CFG Category
-  rrkCFG,
-  rrkInvalidTerminator,
-  rrkCondition,
-  rrkLastCFG,
-  rrkIrreducibleRegion,
+  CFG,
+  InvalidTerminator,
+  Condition,
+  LastCFG,
+  IrreducibleRegion,
 
   // Non-Affinity
-  rrkAffFunc,
-  rrkUndefCond,
-  rrkInvalidCond,
-  rrkUndefOperand,
-  rrkNonAffBranch,
-  rrkNoBasePtr,
-  rrkUndefBasePtr,
-  rrkVariantBasePtr,
-  rrkNonAffineAccess,
-  rrkDifferentElementSize,
-  rrkLastAffFunc,
+  AffFunc,
+  UndefCond,
+  InvalidCond,
+  UndefOperand,
+  NonAffBranch,
+  NoBasePtr,
+  UndefBasePtr,
+  VariantBasePtr,
+  NonAffineAccess,
+  DifferentElementSize,
+  LastAffFunc,
 
-  rrkLoopBound,
-  rrkLoopHasNoExit,
+  LoopBound,
+  LoopHasNoExit,
 
-  rrkFuncCall,
-  rrkNonSimpleMemoryAccess,
+  FuncCall,
+  NonSimpleMemoryAccess,
 
-  rrkAlias,
+  Alias,
 
   // Other
-  rrkOther,
-  rrkIntToPtr,
-  rrkAlloca,
-  rrkUnknownInst,
-  rrkEntry,
-  rrkUnprofitable,
-  rrkLastOther
+  Other,
+  IntToPtr,
+  Alloca,
+  UnknownInst,
+  Entry,
+  Unprofitable,
+  LastOther
 };
 
 //===----------------------------------------------------------------------===//
@@ -193,7 +193,7 @@ class ReportInvalidTerminator : public R
 
 public:
   ReportInvalidTerminator(BasicBlock *BB)
-      : ReportCFG(rrkInvalidTerminator), BB(BB) {}
+      : ReportCFG(RejectReasonKind::InvalidTerminator), BB(BB) {}
 
   /// @name LLVM-RTTI interface
   //@{
@@ -215,7 +215,7 @@ class ReportIrreducibleRegion : public R
 
 public:
   ReportIrreducibleRegion(Region *R, DebugLoc DbgLoc)
-      : ReportCFG(rrkIrreducibleRegion), R(R), DbgLoc(DbgLoc) {}
+      : ReportCFG(RejectReasonKind::IrreducibleRegion), R(R), DbgLoc(DbgLoc) {}
 
   /// @name LLVM-RTTI interface
   //@{
@@ -267,7 +267,7 @@ class ReportUndefCond : public ReportAff
 
 public:
   ReportUndefCond(const Instruction *Inst, BasicBlock *BB)
-      : ReportAffFunc(rrkUndefCond, Inst), BB(BB) {}
+      : ReportAffFunc(RejectReasonKind::UndefCond, Inst), BB(BB) {}
 
   /// @name LLVM-RTTI interface
   //@{
@@ -292,7 +292,7 @@ class ReportInvalidCond : public ReportA
 
 public:
   ReportInvalidCond(const Instruction *Inst, BasicBlock *BB)
-      : ReportAffFunc(rrkInvalidCond, Inst), BB(BB) {}
+      : ReportAffFunc(RejectReasonKind::InvalidCond, Inst), BB(BB) {}
 
   /// @name LLVM-RTTI interface
   //@{
@@ -315,7 +315,7 @@ class ReportUndefOperand : public Report
 
 public:
   ReportUndefOperand(BasicBlock *BB, const Instruction *Inst)
-      : ReportAffFunc(rrkUndefOperand, Inst), BB(BB) {}
+      : ReportAffFunc(RejectReasonKind::UndefOperand, Inst), BB(BB) {}
 
   /// @name LLVM-RTTI interface
   //@{
@@ -345,7 +345,8 @@ class ReportNonAffBranch : public Report
 public:
   ReportNonAffBranch(BasicBlock *BB, const SCEV *LHS, const SCEV *RHS,
                      const Instruction *Inst)
-      : ReportAffFunc(rrkNonAffBranch, Inst), BB(BB), LHS(LHS), RHS(RHS) {}
+      : ReportAffFunc(RejectReasonKind::NonAffBranch, Inst), BB(BB), LHS(LHS),
+        RHS(RHS) {}
 
   const SCEV *lhs() { return LHS; }
   const SCEV *rhs() { return RHS; }
@@ -367,7 +368,7 @@ class ReportNoBasePtr : public ReportAff
   //===--------------------------------------------------------------------===//
 public:
   ReportNoBasePtr(const Instruction *Inst)
-      : ReportAffFunc(rrkNoBasePtr, Inst) {}
+      : ReportAffFunc(RejectReasonKind::NoBasePtr, Inst) {}
 
   /// @name LLVM-RTTI interface
   //@{
@@ -386,7 +387,7 @@ class ReportUndefBasePtr : public Report
   //===--------------------------------------------------------------------===//
 public:
   ReportUndefBasePtr(const Instruction *Inst)
-      : ReportAffFunc(rrkUndefBasePtr, Inst) {}
+      : ReportAffFunc(RejectReasonKind::UndefBasePtr, Inst) {}
 
   /// @name LLVM-RTTI interface
   //@{
@@ -409,7 +410,8 @@ class ReportVariantBasePtr : public Repo
 
 public:
   ReportVariantBasePtr(Value *BaseValue, const Instruction *Inst)
-      : ReportAffFunc(rrkVariantBasePtr, Inst), BaseValue(BaseValue) {}
+      : ReportAffFunc(RejectReasonKind::VariantBasePtr, Inst),
+        BaseValue(BaseValue) {}
 
   /// @name LLVM-RTTI interface
   //@{
@@ -437,8 +439,8 @@ class ReportNonAffineAccess : public Rep
 public:
   ReportNonAffineAccess(const SCEV *AccessFunction, const Instruction *Inst,
                         const Value *V)
-      : ReportAffFunc(rrkNonAffineAccess, Inst), AccessFunction(AccessFunction),
-        BaseValue(V) {}
+      : ReportAffFunc(RejectReasonKind::NonAffineAccess, Inst),
+        AccessFunction(AccessFunction), BaseValue(V) {}
 
   const SCEV *get() { return AccessFunction; }
 
@@ -464,7 +466,8 @@ class ReportDifferentArrayElementSize :
 
 public:
   ReportDifferentArrayElementSize(const Instruction *Inst, const Value *V)
-      : ReportAffFunc(rrkDifferentElementSize, Inst), BaseValue(V) {}
+      : ReportAffFunc(RejectReasonKind::DifferentElementSize, Inst),
+        BaseValue(V) {}
 
   /// @name LLVM-RTTI interface
   //@{
@@ -522,7 +525,8 @@ class ReportLoopHasNoExit : public Rejec
 
 public:
   ReportLoopHasNoExit(Loop *L)
-      : RejectReason(rrkLoopHasNoExit), L(L), Loc(L->getStartLoc()) {}
+      : RejectReason(RejectReasonKind::LoopHasNoExit), L(L),
+        Loc(L->getStartLoc()) {}
 
   /// @name LLVM-RTTI interface
   //@{

Modified: polly/trunk/lib/Analysis/ScopDetectionDiagnostic.cpp
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/lib/Analysis/ScopDetectionDiagnostic.cpp?rev=287963&r1=287962&r2=287963&view=diff
==============================================================================
--- polly/trunk/lib/Analysis/ScopDetectionDiagnostic.cpp (original)
+++ polly/trunk/lib/Analysis/ScopDetectionDiagnostic.cpp Fri Nov 25 21:44:31 2016
@@ -140,7 +140,8 @@ ReportCFG::ReportCFG(const RejectReasonK
 }
 
 bool ReportCFG::classof(const RejectReason *RR) {
-  return RR->getKind() >= rrkCFG && RR->getKind() <= rrkLastCFG;
+  return RR->getKind() >= RejectReasonKind::CFG &&
+         RR->getKind() <= RejectReasonKind::LastCFG;
 }
 
 //===----------------------------------------------------------------------===//
@@ -155,7 +156,7 @@ const DebugLoc &ReportInvalidTerminator:
 }
 
 bool ReportInvalidTerminator::classof(const RejectReason *RR) {
-  return RR->getKind() == rrkInvalidTerminator;
+  return RR->getKind() == RejectReasonKind::InvalidTerminator;
 }
 
 //===----------------------------------------------------------------------===//
@@ -172,7 +173,7 @@ std::string ReportIrreducibleRegion::get
 }
 
 bool ReportIrreducibleRegion::classof(const RejectReason *RR) {
-  return RR->getKind() == rrkIrreducibleRegion;
+  return RR->getKind() == RejectReasonKind::IrreducibleRegion;
 }
 
 //===----------------------------------------------------------------------===//
@@ -184,7 +185,8 @@ ReportAffFunc::ReportAffFunc(const Rejec
 }
 
 bool ReportAffFunc::classof(const RejectReason *RR) {
-  return RR->getKind() >= rrkAffFunc && RR->getKind() <= rrkLastAffFunc;
+  return RR->getKind() >= RejectReasonKind::AffFunc &&
+         RR->getKind() <= RejectReasonKind::LastAffFunc;
 }
 
 //===----------------------------------------------------------------------===//
@@ -195,7 +197,7 @@ std::string ReportUndefCond::getMessage(
 }
 
 bool ReportUndefCond::classof(const RejectReason *RR) {
-  return RR->getKind() == rrkUndefCond;
+  return RR->getKind() == RejectReasonKind::UndefCond;
 }
 
 //===----------------------------------------------------------------------===//
@@ -207,7 +209,7 @@ std::string ReportInvalidCond::getMessag
 }
 
 bool ReportInvalidCond::classof(const RejectReason *RR) {
-  return RR->getKind() == rrkInvalidCond;
+  return RR->getKind() == RejectReasonKind::InvalidCond;
 }
 
 //===----------------------------------------------------------------------===//
@@ -218,7 +220,7 @@ std::string ReportUndefOperand::getMessa
 }
 
 bool ReportUndefOperand::classof(const RejectReason *RR) {
-  return RR->getKind() == rrkUndefOperand;
+  return RR->getKind() == RejectReasonKind::UndefOperand;
 }
 
 //===----------------------------------------------------------------------===//
@@ -230,7 +232,7 @@ std::string ReportNonAffBranch::getMessa
 }
 
 bool ReportNonAffBranch::classof(const RejectReason *RR) {
-  return RR->getKind() == rrkNonAffBranch;
+  return RR->getKind() == RejectReasonKind::NonAffBranch;
 }
 
 //===----------------------------------------------------------------------===//
@@ -239,7 +241,7 @@ bool ReportNonAffBranch::classof(const R
 std::string ReportNoBasePtr::getMessage() const { return "No base pointer"; }
 
 bool ReportNoBasePtr::classof(const RejectReason *RR) {
-  return RR->getKind() == rrkNoBasePtr;
+  return RR->getKind() == RejectReasonKind::NoBasePtr;
 }
 
 //===----------------------------------------------------------------------===//
@@ -250,7 +252,7 @@ std::string ReportUndefBasePtr::getMessa
 }
 
 bool ReportUndefBasePtr::classof(const RejectReason *RR) {
-  return RR->getKind() == rrkUndefBasePtr;
+  return RR->getKind() == RejectReasonKind::UndefBasePtr;
 }
 
 //===----------------------------------------------------------------------===//
@@ -265,7 +267,7 @@ std::string ReportVariantBasePtr::getEnd
 }
 
 bool ReportVariantBasePtr::classof(const RejectReason *RR) {
-  return RR->getKind() == rrkVariantBasePtr;
+  return RR->getKind() == RejectReasonKind::VariantBasePtr;
 }
 
 //===----------------------------------------------------------------------===//
@@ -276,7 +278,7 @@ std::string ReportDifferentArrayElementS
 }
 
 bool ReportDifferentArrayElementSize::classof(const RejectReason *RR) {
-  return RR->getKind() == rrkDifferentElementSize;
+  return RR->getKind() == RejectReasonKind::DifferentElementSize;
 }
 
 std::string ReportDifferentArrayElementSize::getEndUserMessage() const {
@@ -294,7 +296,7 @@ std::string ReportNonAffineAccess::getMe
 }
 
 bool ReportNonAffineAccess::classof(const RejectReason *RR) {
-  return RR->getKind() == rrkNonAffineAccess;
+  return RR->getKind() == RejectReasonKind::NonAffineAccess;
 }
 
 std::string ReportNonAffineAccess::getEndUserMessage() const {
@@ -307,7 +309,7 @@ std::string ReportNonAffineAccess::getEn
 // ReportLoopBound.
 
 ReportLoopBound::ReportLoopBound(Loop *L, const SCEV *LoopCount)
-    : RejectReason(rrkLoopBound), L(L), LoopCount(LoopCount),
+    : RejectReason(RejectReasonKind::LoopBound), L(L), LoopCount(LoopCount),
       Loc(L->getStartLoc()) {
   ++BadLoopBoundForScop;
 }
@@ -320,7 +322,7 @@ std::string ReportLoopBound::getMessage(
 const DebugLoc &ReportLoopBound::getDebugLoc() const { return Loc; }
 
 bool ReportLoopBound::classof(const RejectReason *RR) {
-  return RR->getKind() == rrkLoopBound;
+  return RR->getKind() == RejectReasonKind::LoopBound;
 }
 
 std::string ReportLoopBound::getEndUserMessage() const {
@@ -335,7 +337,7 @@ std::string ReportLoopHasNoExit::getMess
 }
 
 bool ReportLoopHasNoExit::classof(const RejectReason *RR) {
-  return RR->getKind() == rrkLoopHasNoExit;
+  return RR->getKind() == RejectReasonKind::LoopHasNoExit;
 }
 
 const DebugLoc &ReportLoopHasNoExit::getDebugLoc() const { return Loc; }
@@ -348,7 +350,7 @@ std::string ReportLoopHasNoExit::getEndU
 // ReportFuncCall.
 
 ReportFuncCall::ReportFuncCall(Instruction *Inst)
-    : RejectReason(rrkFuncCall), Inst(Inst) {
+    : RejectReason(RejectReasonKind::FuncCall), Inst(Inst) {
   ++BadFuncCallForScop;
 }
 
@@ -366,14 +368,14 @@ std::string ReportFuncCall::getEndUserMe
 }
 
 bool ReportFuncCall::classof(const RejectReason *RR) {
-  return RR->getKind() == rrkFuncCall;
+  return RR->getKind() == RejectReasonKind::FuncCall;
 }
 
 //===----------------------------------------------------------------------===//
 // ReportNonSimpleMemoryAccess
 
 ReportNonSimpleMemoryAccess::ReportNonSimpleMemoryAccess(Instruction *Inst)
-    : ReportOther(rrkNonSimpleMemoryAccess), Inst(Inst) {}
+    : ReportOther(RejectReasonKind::NonSimpleMemoryAccess), Inst(Inst) {}
 
 std::string ReportNonSimpleMemoryAccess::getMessage() const {
   return "Non-simple memory access: " + *Inst;
@@ -389,14 +391,14 @@ std::string ReportNonSimpleMemoryAccess:
 }
 
 bool ReportNonSimpleMemoryAccess::classof(const RejectReason *RR) {
-  return RR->getKind() == rrkNonSimpleMemoryAccess;
+  return RR->getKind() == RejectReasonKind::NonSimpleMemoryAccess;
 }
 
 //===----------------------------------------------------------------------===//
 // ReportAlias.
 
 ReportAlias::ReportAlias(Instruction *Inst, AliasSet &AS)
-    : RejectReason(rrkAlias), Inst(Inst) {
+    : RejectReason(RejectReasonKind::Alias), Inst(Inst) {
 
   for (const auto &I : AS)
     Pointers.push_back(I.getValue());
@@ -447,7 +449,7 @@ std::string ReportAlias::getEndUserMessa
 const DebugLoc &ReportAlias::getDebugLoc() const { return Inst->getDebugLoc(); }
 
 bool ReportAlias::classof(const RejectReason *RR) {
-  return RR->getKind() == rrkAlias;
+  return RR->getKind() == RejectReasonKind::Alias;
 }
 
 //===----------------------------------------------------------------------===//
@@ -460,13 +462,14 @@ ReportOther::ReportOther(const RejectRea
 }
 
 bool ReportOther::classof(const RejectReason *RR) {
-  return RR->getKind() >= rrkOther && RR->getKind() <= rrkLastOther;
+  return RR->getKind() >= RejectReasonKind::Other &&
+         RR->getKind() <= RejectReasonKind::LastOther;
 }
 
 //===----------------------------------------------------------------------===//
 // ReportIntToPtr.
 ReportIntToPtr::ReportIntToPtr(Instruction *BaseValue)
-    : ReportOther(rrkIntToPtr), BaseValue(BaseValue) {}
+    : ReportOther(RejectReasonKind::IntToPtr), BaseValue(BaseValue) {}
 
 std::string ReportIntToPtr::getMessage() const {
   return "Find bad intToptr prt: " + *BaseValue;
@@ -477,14 +480,14 @@ const DebugLoc &ReportIntToPtr::getDebug
 }
 
 bool ReportIntToPtr::classof(const RejectReason *RR) {
-  return RR->getKind() == rrkIntToPtr;
+  return RR->getKind() == RejectReasonKind::IntToPtr;
 }
 
 //===----------------------------------------------------------------------===//
 // ReportAlloca.
 
 ReportAlloca::ReportAlloca(Instruction *Inst)
-    : ReportOther(rrkAlloca), Inst(Inst) {}
+    : ReportOther(RejectReasonKind::Alloca), Inst(Inst) {}
 
 std::string ReportAlloca::getMessage() const {
   return "Alloca instruction: " + *Inst;
@@ -495,14 +498,14 @@ const DebugLoc &ReportAlloca::getDebugLo
 }
 
 bool ReportAlloca::classof(const RejectReason *RR) {
-  return RR->getKind() == rrkAlloca;
+  return RR->getKind() == RejectReasonKind::Alloca;
 }
 
 //===----------------------------------------------------------------------===//
 // ReportUnknownInst.
 
 ReportUnknownInst::ReportUnknownInst(Instruction *Inst)
-    : ReportOther(rrkUnknownInst), Inst(Inst) {}
+    : ReportOther(RejectReasonKind::UnknownInst), Inst(Inst) {}
 
 std::string ReportUnknownInst::getMessage() const {
   return "Unknown instruction: " + *Inst;
@@ -513,12 +516,13 @@ const DebugLoc &ReportUnknownInst::getDe
 }
 
 bool ReportUnknownInst::classof(const RejectReason *RR) {
-  return RR->getKind() == rrkUnknownInst;
+  return RR->getKind() == RejectReasonKind::UnknownInst;
 }
 
 //===----------------------------------------------------------------------===//
 // ReportEntry.
-ReportEntry::ReportEntry(BasicBlock *BB) : ReportOther(rrkEntry), BB(BB) {}
+ReportEntry::ReportEntry(BasicBlock *BB)
+    : ReportOther(RejectReasonKind::Entry), BB(BB) {}
 
 std::string ReportEntry::getMessage() const {
   return "Region containing entry block of function is invalid!";
@@ -529,13 +533,13 @@ const DebugLoc &ReportEntry::getDebugLoc
 }
 
 bool ReportEntry::classof(const RejectReason *RR) {
-  return RR->getKind() == rrkEntry;
+  return RR->getKind() == RejectReasonKind::Entry;
 }
 
 //===----------------------------------------------------------------------===//
 // ReportUnprofitable.
 ReportUnprofitable::ReportUnprofitable(Region *R)
-    : ReportOther(rrkUnprofitable), R(R) {}
+    : ReportOther(RejectReasonKind::Unprofitable), R(R) {}
 
 std::string ReportUnprofitable::getMessage() const {
   return "Region can not profitably be optimized!";
@@ -555,6 +559,6 @@ const DebugLoc &ReportUnprofitable::getD
 }
 
 bool ReportUnprofitable::classof(const RejectReason *RR) {
-  return RR->getKind() == rrkUnprofitable;
+  return RR->getKind() == RejectReasonKind::Unprofitable;
 }
 } // namespace polly




More information about the llvm-commits mailing list