Index: include/llvm/ADT/DenseMap.h =================================================================== --- include/llvm/ADT/DenseMap.h +++ include/llvm/ADT/DenseMap.h @@ -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 #include -#include #include #include #include +#include #include #include 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 @@ -42,8 +42,9 @@ ValueT &getSecond() { return std::pair::second; } const ValueT &getSecond() const { return std::pair::second; } }; -} +} // end namespace detail + template < typename KeyT, typename ValueT, typename KeyInfoT = DenseMapInfo, typename Bucket = detail::DenseMapPair, bool IsConst = false> @@ -224,7 +225,6 @@ insert(*I); } - bool erase(const KeyT &Val) { BucketT *TheBucket; if (!LookupBucketFor(Val, TheBucket)) @@ -429,7 +429,6 @@ static_cast(this)->shrink_and_clear(); } - BucketT *InsertIntoBucket(const KeyT &Key, const ValueT &Value, BucketT *TheBucket) { TheBucket = InsertIntoBucketImpl(Key, Key, TheBucket); @@ -530,7 +529,7 @@ 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()))) { @@ -968,7 +967,8 @@ return NumEntries; } void setNumEntries(unsigned Num) { - assert(Num < INT_MAX && "Cannot support more than INT_MAX entries"); + assert(Num < std::numeric_limits::max() && + "Cannot support more than std::numeric_limits::max() entries"); NumEntries = Num; } @@ -1042,8 +1042,10 @@ 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) {} @@ -1117,4 +1119,4 @@ } // end namespace llvm -#endif +#endif // LLVM_ADT_DENSEMAP_H Index: include/llvm/ADT/Statistic.h =================================================================== --- include/llvm/ADT/Statistic.h +++ include/llvm/ADT/Statistic.h @@ -31,6 +31,7 @@ #include namespace llvm { + class raw_ostream; class raw_fd_ostream; @@ -158,13 +159,14 @@ 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, DESC, 0, 0 } + static llvm::Statistic VARNAME = { DEBUG_TYPE, DESC, 0, false } /// \brief Enable the collection and printing of statistics. void EnableStatistics(); @@ -181,6 +183,6 @@ /// \brief Print statistics to the given output stream. void PrintStatistics(raw_ostream &OS); -} // end llvm namespace +} // end namespace llvm #endif // LLVM_ADT_STATISTIC_H Index: include/llvm/Support/AtomicOrdering.h =================================================================== --- include/llvm/Support/AtomicOrdering.h +++ include/llvm/Support/AtomicOrdering.h @@ -73,8 +73,8 @@ // Validate an integral value which isn't known to fit within the enum's range // is a valid AtomicOrdering. template static inline bool isValidAtomicOrdering(Int I) { - return (Int)AtomicOrdering::NotAtomic <= I && - I <= (Int)AtomicOrdering::SequentiallyConsistent; + return static_cast(AtomicOrdering::NotAtomic) <= I && + I <= static_cast(AtomicOrdering::SequentiallyConsistent); } /// String used by LLVM IR to represent atomic ordering. @@ -82,40 +82,40 @@ 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(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(ao)][static_cast(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(ao)][static_cast(other)]; } static inline bool isStrongerThanUnordered(AtomicOrdering ao) { @@ -145,7 +145,7 @@ /* acq_rel */ AtomicOrderingCABI::acq_rel, /* seq_cst */ AtomicOrderingCABI::seq_cst, }; - return lookup[(size_t)ao]; + return lookup[static_cast(ao)]; } } // end namespace llvm Index: include/llvm/Support/Debug.h =================================================================== --- include/llvm/Support/Debug.h +++ include/llvm/Support/Debug.h @@ -29,6 +29,7 @@ #define LLVM_SUPPORT_DEBUG_H namespace llvm { + class raw_ostream; #ifndef NDEBUG @@ -61,12 +62,12 @@ /// 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 @@ // #define DEBUG(X) DEBUG_WITH_TYPE(DEBUG_TYPE, X) -} // End llvm namespace +} // end namespace llvm -#endif +#endif // LLVM_SUPPORT_DEBUG_H