[llvm] r278583 - Fix some Clang-tidy modernize-use-using and Include What You Use warnings.

Eugene Zelenko via llvm-commits llvm-commits at lists.llvm.org
Fri Aug 12 17:50:41 PDT 2016


Author: eugenezelenko
Date: Fri Aug 12 19:50:41 2016
New Revision: 278583

URL: http://llvm.org/viewvc/llvm-project?rev=278583&view=rev
Log:
Fix some Clang-tidy modernize-use-using and Include What You Use warnings.

Differential revision: https://reviews.llvm.org/D23478

Modified:
    llvm/trunk/include/llvm/ADT/DenseMap.h
    llvm/trunk/include/llvm/ADT/Statistic.h
    llvm/trunk/include/llvm/Support/AtomicOrdering.h
    llvm/trunk/include/llvm/Support/Debug.h
    llvm/trunk/lib/Analysis/Lint.cpp
    llvm/trunk/lib/IR/Verifier.cpp

Modified: llvm/trunk/include/llvm/ADT/DenseMap.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ADT/DenseMap.h?rev=278583&r1=278582&r2=278583&view=diff
==============================================================================
--- llvm/trunk/include/llvm/ADT/DenseMap.h (original)
+++ llvm/trunk/include/llvm/ADT/DenseMap.h Fri Aug 12 19:50:41 2016
@@ -19,20 +19,20 @@
 #include "llvm/Support/AlignOf.h"
 #include "llvm/Support/Compiler.h"
 #include "llvm/Support/MathExtras.h"
-#include "llvm/Support/PointerLikeTypeTraits.h"
 #include "llvm/Support/type_traits.h"
 #include <algorithm>
 #include <cassert>
-#include <climits>
 #include <cstddef>
 #include <cstring>
 #include <iterator>
+#include <limits>
 #include <new>
 #include <utility>
 
 namespace llvm {
 
 namespace detail {
+
 // We extend a pair to allow users to override the bucket type with their own
 // implementation without requiring two members.
 template <typename KeyT, typename ValueT>
@@ -42,7 +42,8 @@ struct DenseMapPair : public std::pair<K
   ValueT &getSecond() { return std::pair<KeyT, ValueT>::second; }
   const ValueT &getSecond() const { return std::pair<KeyT, ValueT>::second; }
 };
-}
+
+} // end namespace detail
 
 template <
     typename KeyT, typename ValueT, typename KeyInfoT = DenseMapInfo<KeyT>,
@@ -239,7 +240,6 @@ public:
       insert(*I);
   }
 
-
   bool erase(const KeyT &Val) {
     BucketT *TheBucket;
     if (!LookupBucketFor(Val, TheBucket))
@@ -528,7 +528,7 @@ private:
 
     unsigned BucketNo = getHashValue(Val) & (NumBuckets-1);
     unsigned ProbeAmt = 1;
-    while (1) {
+    while (true) {
       const BucketT *ThisBucket = BucketsPtr + BucketNo;
       // Found Val's bucket?  If so, return it.
       if (LLVM_LIKELY(KeyInfoT::isEqual(Val, ThisBucket->getFirst()))) {
@@ -966,7 +966,8 @@ private:
     return NumEntries;
   }
   void setNumEntries(unsigned Num) {
-    assert(Num < INT_MAX && "Cannot support more than INT_MAX entries");
+    assert(Num < std::numeric_limits<int>::max() &&
+           "Cannot support more than std::numeric_limits<int>::max() entries");
     NumEntries = Num;
   }
 
@@ -1040,8 +1041,10 @@ public:
   typedef value_type *pointer;
   typedef value_type &reference;
   typedef std::forward_iterator_tag iterator_category;
+
 private:
   pointer Ptr, End;
+
 public:
   DenseMapIterator() : Ptr(nullptr), End(nullptr) {}
 
@@ -1115,4 +1118,4 @@ capacity_in_bytes(const DenseMap<KeyT, V
 
 } // end namespace llvm
 
-#endif
+#endif // LLVM_ADT_DENSEMAP_H

Modified: llvm/trunk/include/llvm/ADT/Statistic.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ADT/Statistic.h?rev=278583&r1=278582&r2=278583&view=diff
==============================================================================
--- llvm/trunk/include/llvm/ADT/Statistic.h (original)
+++ llvm/trunk/include/llvm/ADT/Statistic.h Fri Aug 12 19:50:41 2016
@@ -32,6 +32,7 @@
 #include <memory>
 
 namespace llvm {
+
 class raw_ostream;
 class raw_fd_ostream;
 
@@ -140,13 +141,14 @@ protected:
     TsanHappensAfter(this);
     return *this;
   }
+
   void RegisterStatistic();
 };
 
 // STATISTIC - A macro to make definition of statistics really simple.  This
 // automatically passes the DEBUG_TYPE of the file into the statistic.
 #define STATISTIC(VARNAME, DESC)                                               \
-  static llvm::Statistic VARNAME = {DEBUG_TYPE, #VARNAME, DESC, {0}, 0}
+  static llvm::Statistic VARNAME = {DEBUG_TYPE, #VARNAME, DESC, {0}, false}
 
 /// \brief Enable the collection and printing of statistics.
 void EnableStatistics();
@@ -166,6 +168,6 @@ void PrintStatistics(raw_ostream &OS);
 /// Print statistics in JSON format.
 void PrintStatisticsJSON(raw_ostream &OS);
 
-} // end llvm namespace
+} // end namespace llvm
 
 #endif // LLVM_ADT_STATISTIC_H

Modified: llvm/trunk/include/llvm/Support/AtomicOrdering.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/AtomicOrdering.h?rev=278583&r1=278582&r2=278583&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Support/AtomicOrdering.h (original)
+++ llvm/trunk/include/llvm/Support/AtomicOrdering.h Fri Aug 12 19:50:41 2016
@@ -73,8 +73,8 @@ bool operator>=(AtomicOrdering, AtomicOr
 // Validate an integral value which isn't known to fit within the enum's range
 // is a valid AtomicOrdering.
 template <typename Int> static inline bool isValidAtomicOrdering(Int I) {
-  return (Int)AtomicOrdering::NotAtomic <= I &&
-         I <= (Int)AtomicOrdering::SequentiallyConsistent;
+  return static_cast<Int>(AtomicOrdering::NotAtomic) <= I &&
+         I <= static_cast<Int>(AtomicOrdering::SequentiallyConsistent);
 }
 
 /// String used by LLVM IR to represent atomic ordering.
@@ -82,40 +82,40 @@ static inline const char *toIRString(Ato
   static const char *names[8] = {"not_atomic", "unordered", "monotonic",
                                  "consume",    "acquire",   "release",
                                  "acq_rel",    "seq_cst"};
-  return names[(size_t)ao];
+  return names[static_cast<size_t>(ao)];
 }
 
 /// Returns true if ao is stronger than other as defined by the AtomicOrdering
 /// lattice, which is based on C++'s definition.
 static inline bool isStrongerThan(AtomicOrdering ao, AtomicOrdering other) {
   static const bool lookup[8][8] = {
-      //               NA UN RX CO AC RE AR SC
-      /* NotAtomic */ {0, 0, 0, 0, 0, 0, 0, 0},
-      /* Unordered */ {1, 0, 0, 0, 0, 0, 0, 0},
-      /* relaxed   */ {1, 1, 0, 0, 0, 0, 0, 0},
-      /* consume   */ {1, 1, 1, 0, 0, 0, 0, 0},
-      /* acquire   */ {1, 1, 1, 1, 0, 0, 0, 0},
-      /* release   */ {1, 1, 1, 0, 0, 0, 0, 0},
-      /* acq_rel   */ {1, 1, 1, 1, 1, 1, 0, 0},
-      /* seq_cst   */ {1, 1, 1, 1, 1, 1, 1, 0},
+      //               NA     UN     RX     CO     AC     RE     AR     SC
+      /* NotAtomic */ {false, false, false, false, false, false, false, false},
+      /* Unordered */ { true, false, false, false, false, false, false, false},
+      /* relaxed   */ { true,  true, false, false, false, false, false, false},
+      /* consume   */ { true,  true,  true, false, false, false, false, false},
+      /* acquire   */ { true,  true,  true,  true, false, false, false, false},
+      /* release   */ { true,  true,  true, false, false, false, false, false},
+      /* acq_rel   */ { true,  true,  true,  true,  true,  true, false, false},
+      /* seq_cst   */ { true,  true,  true,  true,  true,  true,  true, false},
   };
-  return lookup[(size_t)ao][(size_t)other];
+  return lookup[static_cast<size_t>(ao)][static_cast<size_t>(other)];
 }
 
 static inline bool isAtLeastOrStrongerThan(AtomicOrdering ao,
                                            AtomicOrdering other) {
   static const bool lookup[8][8] = {
-      //               NA UN RX CO AC RE AR SC
-      /* NotAtomic */ {1, 0, 0, 0, 0, 0, 0, 0},
-      /* Unordered */ {1, 1, 0, 0, 0, 0, 0, 0},
-      /* relaxed   */ {1, 1, 1, 0, 0, 0, 0, 0},
-      /* consume   */ {1, 1, 1, 1, 0, 0, 0, 0},
-      /* acquire   */ {1, 1, 1, 1, 1, 0, 0, 0},
-      /* release   */ {1, 1, 1, 0, 0, 1, 0, 0},
-      /* acq_rel   */ {1, 1, 1, 1, 1, 1, 1, 0},
-      /* seq_cst   */ {1, 1, 1, 1, 1, 1, 1, 1},
+      //               NA     UN     RX     CO     AC     RE     AR     SC
+      /* NotAtomic */ { true, false, false, false, false, false, false, false},
+      /* Unordered */ { true,  true, false, false, false, false, false, false},
+      /* relaxed   */ { true,  true,  true, false, false, false, false, false},
+      /* consume   */ { true,  true,  true,  true, false, false, false, false},
+      /* acquire   */ { true,  true,  true,  true,  true, false, false, false},
+      /* release   */ { true,  true,  true, false, false,  true, false, false},
+      /* acq_rel   */ { true,  true,  true,  true,  true,  true,  true, false},
+      /* seq_cst   */ { true,  true,  true,  true,  true,  true,  true,  true},
   };
-  return lookup[(size_t)ao][(size_t)other];
+  return lookup[static_cast<size_t>(ao)][static_cast<size_t>(other)];
 }
 
 static inline bool isStrongerThanUnordered(AtomicOrdering ao) {
@@ -145,7 +145,7 @@ static inline AtomicOrderingCABI toCABI(
       /* acq_rel   */ AtomicOrderingCABI::acq_rel,
       /* seq_cst   */ AtomicOrderingCABI::seq_cst,
   };
-  return lookup[(size_t)ao];
+  return lookup[static_cast<size_t>(ao)];
 }
 
 } // end namespace llvm

Modified: llvm/trunk/include/llvm/Support/Debug.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/Debug.h?rev=278583&r1=278582&r2=278583&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Support/Debug.h (original)
+++ llvm/trunk/include/llvm/Support/Debug.h Fri Aug 12 19:50:41 2016
@@ -29,6 +29,7 @@
 #define LLVM_SUPPORT_DEBUG_H
 
 namespace llvm {
+
 class raw_ostream;
 
 #ifndef NDEBUG
@@ -61,12 +62,12 @@ void setCurrentDebugType(const char *Typ
 /// is not specified, or is specified as "bitset".
 #define DEBUG_WITH_TYPE(TYPE, X)                                        \
   do { if (::llvm::DebugFlag && ::llvm::isCurrentDebugType(TYPE)) { X; } \
-  } while (0)
+  } while (false)
 
 #else
 #define isCurrentDebugType(X) (false)
 #define setCurrentDebugType(X)
-#define DEBUG_WITH_TYPE(TYPE, X) do { } while (0)
+#define DEBUG_WITH_TYPE(TYPE, X) do { } while (false)
 #endif
 
 /// EnableDebugBuffering - This defaults to false.  If true, the debug
@@ -91,6 +92,6 @@ raw_ostream &dbgs();
 //
 #define DEBUG(X) DEBUG_WITH_TYPE(DEBUG_TYPE, X)
 
-} // End llvm namespace
+} // end namespace llvm
 
-#endif
+#endif // LLVM_SUPPORT_DEBUG_H

Modified: llvm/trunk/lib/Analysis/Lint.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/Lint.cpp?rev=278583&r1=278582&r2=278583&view=diff
==============================================================================
--- llvm/trunk/lib/Analysis/Lint.cpp (original)
+++ llvm/trunk/lib/Analysis/Lint.cpp Fri Aug 12 19:50:41 2016
@@ -35,27 +35,48 @@
 //===----------------------------------------------------------------------===//
 
 #include "llvm/Analysis/Lint.h"
-#include "llvm/ADT/STLExtras.h"
-#include "llvm/ADT/SmallSet.h"
+#include "llvm/ADT/APInt.h"
+#include "llvm/ADT/ArrayRef.h"
+#include "llvm/ADT/SmallPtrSet.h"
+#include "llvm/ADT/Twine.h"
 #include "llvm/Analysis/AliasAnalysis.h"
 #include "llvm/Analysis/AssumptionCache.h"
 #include "llvm/Analysis/ConstantFolding.h"
 #include "llvm/Analysis/InstructionSimplify.h"
 #include "llvm/Analysis/Loads.h"
+#include "llvm/Analysis/MemoryLocation.h"
 #include "llvm/Analysis/Passes.h"
 #include "llvm/Analysis/TargetLibraryInfo.h"
 #include "llvm/Analysis/ValueTracking.h"
+#include "llvm/IR/Argument.h"
+#include "llvm/IR/BasicBlock.h"
 #include "llvm/IR/CallSite.h"
+#include "llvm/IR/Constant.h"
+#include "llvm/IR/Constants.h"
 #include "llvm/IR/DataLayout.h"
+#include "llvm/IR/DerivedTypes.h"
 #include "llvm/IR/Dominators.h"
 #include "llvm/IR/Function.h"
+#include "llvm/IR/GlobalVariable.h"
 #include "llvm/IR/Module.h"
 #include "llvm/IR/InstVisitor.h"
+#include "llvm/IR/InstrTypes.h"
+#include "llvm/IR/Instruction.h"
+#include "llvm/IR/Instructions.h"
 #include "llvm/IR/IntrinsicInst.h"
 #include "llvm/IR/LegacyPassManager.h"
+#include "llvm/IR/Type.h"
+#include "llvm/IR/Value.h"
 #include "llvm/Pass.h"
+#include "llvm/Support/Casting.h"
 #include "llvm/Support/Debug.h"
+#include "llvm/Support/MathExtras.h"
 #include "llvm/Support/raw_ostream.h"
+#include <cassert>
+#include <cstdint>
+#include <iterator>
+#include <string>
+
 using namespace llvm;
 
 namespace {
@@ -64,7 +85,7 @@ namespace {
     static const unsigned Write    = 2;
     static const unsigned Callee   = 4;
     static const unsigned Branchee = 8;
-  }
+  } // end namespace MemRef
 
   class Lint : public FunctionPass, public InstVisitor<Lint> {
     friend class InstVisitor<Lint>;
@@ -159,7 +180,7 @@ namespace {
       WriteValues({V1, Vs...});
     }
   };
-}
+} // end anonymous namespace
 
 char Lint::ID = 0;
 INITIALIZE_PASS_BEGIN(Lint, "lint", "Statically lint-checks LLVM IR",
@@ -173,7 +194,7 @@ INITIALIZE_PASS_END(Lint, "lint", "Stati
 
 // Assert - We know that cond should be true, if not print an error message.
 #define Assert(C, ...) \
-    do { if (!(C)) { CheckFailed(__VA_ARGS__); return; } } while (0)
+    do { if (!(C)) { CheckFailed(__VA_ARGS__); return; } } while (false)
 
 // Lint::run - This is the main Analysis entry point for a
 // function.

Modified: llvm/trunk/lib/IR/Verifier.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/IR/Verifier.cpp?rev=278583&r1=278582&r2=278583&view=diff
==============================================================================
--- llvm/trunk/lib/IR/Verifier.cpp (original)
+++ llvm/trunk/lib/IR/Verifier.cpp Fri Aug 12 19:50:41 2016
@@ -45,44 +45,80 @@
 //===----------------------------------------------------------------------===//
 
 #include "llvm/IR/Verifier.h"
+#include "llvm/ADT/APFloat.h"
+#include "llvm/ADT/APInt.h"
+#include "llvm/ADT/ArrayRef.h"
+#include "llvm/ADT/DenseMap.h"
+#include "llvm/ADT/ilist.h"
 #include "llvm/ADT/MapVector.h"
+#include "llvm/ADT/Optional.h"
 #include "llvm/ADT/STLExtras.h"
-#include "llvm/ADT/SetVector.h"
 #include "llvm/ADT/SmallPtrSet.h"
+#include "llvm/ADT/SmallSet.h"
 #include "llvm/ADT/SmallVector.h"
-#include "llvm/ADT/StringExtras.h"
+#include "llvm/ADT/StringMap.h"
+#include "llvm/ADT/StringRef.h"
+#include "llvm/ADT/Twine.h"
+#include "llvm/IR/Argument.h"
+#include "llvm/IR/Attributes.h"
+#include "llvm/IR/BasicBlock.h"
 #include "llvm/IR/CFG.h"
 #include "llvm/IR/CallSite.h"
 #include "llvm/IR/CallingConv.h"
+#include "llvm/IR/Comdat.h"
+#include "llvm/IR/Constant.h"
 #include "llvm/IR/ConstantRange.h"
 #include "llvm/IR/Constants.h"
 #include "llvm/IR/DataLayout.h"
 #include "llvm/IR/DebugInfo.h"
+#include "llvm/IR/DebugInfoMetadata.h"
+#include "llvm/IR/DebugLoc.h"
 #include "llvm/IR/DerivedTypes.h"
 #include "llvm/IR/DiagnosticInfo.h"
 #include "llvm/IR/Dominators.h"
+#include "llvm/IR/Function.h"
+#include "llvm/IR/GlobalAlias.h"
+#include "llvm/IR/GlobalValue.h"
+#include "llvm/IR/GlobalVariable.h"
 #include "llvm/IR/InlineAsm.h"
-#include "llvm/IR/InstIterator.h"
+#include "llvm/IR/InstrTypes.h"
+#include "llvm/IR/Instruction.h"
+#include "llvm/IR/Instructions.h"
 #include "llvm/IR/InstVisitor.h"
 #include "llvm/IR/IntrinsicInst.h"
+#include "llvm/IR/Intrinsics.h"
 #include "llvm/IR/LLVMContext.h"
 #include "llvm/IR/Metadata.h"
 #include "llvm/IR/Module.h"
 #include "llvm/IR/ModuleSlotTracker.h"
 #include "llvm/IR/PassManager.h"
 #include "llvm/IR/Statepoint.h"
+#include "llvm/IR/Type.h"
+#include "llvm/IR/Use.h"
+#include "llvm/IR/User.h"
+#include "llvm/IR/Value.h"
 #include "llvm/Pass.h"
+#include "llvm/Support/AtomicOrdering.h"
+#include "llvm/Support/Casting.h"
 #include "llvm/Support/CommandLine.h"
 #include "llvm/Support/Debug.h"
+#include "llvm/Support/Dwarf.h"
 #include "llvm/Support/ErrorHandling.h"
+#include "llvm/Support/MathExtras.h"
 #include "llvm/Support/raw_ostream.h"
 #include <algorithm>
-#include <cstdarg>
+#include <cassert>
+#include <cstdint>
+#include <memory>
+#include <string>
+#include <utility>
+
 using namespace llvm;
 
 static cl::opt<bool> VerifyDebugInfo("verify-debug-info", cl::init(true));
 
 namespace {
+
 struct VerifierSupport {
   raw_ostream *OS;
   const Module &M;
@@ -120,6 +156,7 @@ private:
       *OS << '\n';
     }
   }
+
   void Write(ImmutableCallSite CS) {
     Write(CS.getInstruction());
   }
@@ -458,17 +495,17 @@ private:
   /// declarations share the same calling convention.
   void verifyDeoptimizeCallingConvs();
 };
-} // End anonymous namespace
+
+} // end anonymous namespace
 
 /// We know that cond should be true, if not print an error message.
 #define Assert(C, ...) \
-  do { if (!(C)) { CheckFailed(__VA_ARGS__); return; } } while (0)
+  do { if (!(C)) { CheckFailed(__VA_ARGS__); return; } } while (false)
 
 /// We know that a debug info condition should be true, if not print
 /// an error message.
 #define AssertDI(C, ...) \
-  do { if (!(C)) { DebugInfoCheckFailed(__VA_ARGS__); return; } } while (0)
-
+  do { if (!(C)) { DebugInfoCheckFailed(__VA_ARGS__); return; } } while (false)
 
 void Verifier::visit(Instruction &I) {
   for (unsigned i = 0, e = I.getNumOperands(); i != e; ++i)
@@ -928,7 +965,7 @@ void Verifier::visitDICompileUnit(const
     for (Metadata *Op : N.getRetainedTypes()->operands()) {
       AssertDI(Op && (isa<DIType>(Op) ||
                       (isa<DISubprogram>(Op) &&
-                       cast<DISubprogram>(Op)->isDefinition() == false)),
+                       !cast<DISubprogram>(Op)->isDefinition())),
                "invalid retained type", &N, Op);
     }
   }
@@ -2037,7 +2074,7 @@ void Verifier::visitFunction(const Funct
   if (F.getIntrinsicID() && F.getParent()->isMaterialized()) {
     const User *U;
     if (F.hasAddressTaken(&U))
-      Assert(0, "Invalid user of intrinsic instruction!", U);
+      Assert(false, "Invalid user of intrinsic instruction!", U);
   }
 
   Assert(!F.hasDLLImportStorageClass() ||
@@ -2220,7 +2257,7 @@ void Verifier::visitSelectInst(SelectIns
 /// a pass, if any exist, it's an error.
 ///
 void Verifier::visitUserOp1(Instruction &I) {
-  Assert(0, "User-defined operators should not live outside of a pass!", &I);
+  Assert(false, "User-defined operators should not live outside of a pass!", &I);
 }
 
 void Verifier::visitTruncInst(TruncInst &I) {
@@ -3666,7 +3703,7 @@ void Verifier::visitInstruction(Instruct
     // Check to make sure that only first-class-values are operands to
     // instructions.
     if (!I.getOperand(i)->getType()->isFirstClassType()) {
-      Assert(0, "Instruction operands must be first-class values!", &I);
+      Assert(false, "Instruction operands must be first-class values!", &I);
     }
 
     if (Function *F = dyn_cast<Function>(I.getOperand(i))) {
@@ -4356,6 +4393,7 @@ bool llvm::verifyModule(const Module &M,
 }
 
 namespace {
+
 struct VerifierLegacyPass : public FunctionPass {
   static char ID;
 
@@ -4411,7 +4449,8 @@ struct VerifierLegacyPass : public Funct
     AU.setPreservesAll();
   }
 };
-}
+
+} // end anonymous namespace
 
 char VerifierLegacyPass::ID = 0;
 INITIALIZE_PASS(VerifierLegacyPass, "verify", "Module Verifier", false, false)




More information about the llvm-commits mailing list