summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--clang/include/clang/AST/BaseSubobject.h5
-rw-r--r--clang/include/clang/AST/CharUnits.h4
-rw-r--r--clang/include/clang/AST/DeclAccessPair.h8
-rw-r--r--clang/include/clang/AST/DeclarationName.h3
-rw-r--r--clang/include/clang/AST/ExprObjC.h6
-rw-r--r--clang/include/clang/AST/GlobalDecl.h7
-rw-r--r--clang/include/clang/AST/Type.h3
-rw-r--r--clang/include/clang/Analysis/ProgramPoint.h3
-rw-r--r--clang/include/clang/Basic/IdentifierTable.h3
-rw-r--r--clang/include/clang/Basic/SourceLocation.h6
-rw-r--r--clang/include/clang/Lex/Token.h5
-rw-r--r--clang/include/clang/Sema/CodeCompleteConsumer.h8
-rw-r--r--clang/include/clang/Sema/Ownership.h3
-rw-r--r--clang/include/clang/StaticAnalyzer/Core/PathSensitive/SVals.h9
-rw-r--r--clang/lib/AST/VTableBuilder.cpp2
-rw-r--r--clang/lib/Sema/SemaChecking.cpp4
-rw-r--r--clang/lib/StaticAnalyzer/Core/RegionStore.cpp4
-rw-r--r--clang/test/Analysis/llvm-conventions.cpp2
-rw-r--r--clang/tools/libclang/Indexing.cpp3
-rw-r--r--llvm/docs/ProgrammersManual.rst2
-rw-r--r--llvm/include/llvm/ADT/ArrayRef.h6
-rw-r--r--llvm/include/llvm/ADT/DenseMap.h6
-rw-r--r--llvm/include/llvm/ADT/ImmutableList.h4
-rw-r--r--llvm/include/llvm/ADT/Optional.h7
-rw-r--r--llvm/include/llvm/ADT/PointerIntPair.h6
-rw-r--r--llvm/include/llvm/ADT/SmallVector.h15
-rw-r--r--llvm/include/llvm/ADT/StringRef.h4
-rw-r--r--llvm/include/llvm/ADT/bit.h10
-rw-r--r--llvm/include/llvm/Analysis/BlockFrequencyInfoImpl.h8
-rw-r--r--llvm/include/llvm/Bitcode/BitCodes.h2
-rw-r--r--llvm/include/llvm/CodeGen/DIE.h2
-rw-r--r--llvm/include/llvm/CodeGen/RegisterPressure.h4
-rw-r--r--llvm/include/llvm/CodeGen/ScheduleDAG.h3
-rw-r--r--llvm/include/llvm/CodeGen/SelectionDAGNodes.h1
-rw-r--r--llvm/include/llvm/CodeGen/SlotIndexes.h2
-rw-r--r--llvm/include/llvm/CodeGen/TargetPassConfig.h3
-rw-r--r--llvm/include/llvm/IR/CFG.h4
-rw-r--r--llvm/include/llvm/IR/ValueHandle.h17
-rw-r--r--llvm/include/llvm/MC/MCInst.h2
-rw-r--r--llvm/include/llvm/Support/ScaledNumber.h4
-rw-r--r--llvm/include/llvm/Support/type_traits.h84
-rw-r--r--llvm/lib/Transforms/Scalar/SROA.cpp7
-rw-r--r--llvm/tools/llvm-diff/DifferenceEngine.cpp2
-rw-r--r--llvm/unittests/ADT/ArrayRefTest.cpp3
-rw-r--r--llvm/unittests/ADT/ImmutableListTest.cpp3
-rw-r--r--llvm/unittests/ADT/PointerIntPairTest.cpp8
-rw-r--r--llvm/unittests/ADT/StringRefTest.cpp2
-rw-r--r--llvm/unittests/Analysis/BlockFrequencyInfoTest.cpp4
-rw-r--r--llvm/unittests/Bitcode/BitstreamReaderTest.cpp3
-rw-r--r--llvm/unittests/CodeGen/CMakeLists.txt1
-rw-r--r--llvm/unittests/CodeGen/MachineInstrTest.cpp2
-rw-r--r--llvm/unittests/IR/CFGBuilder.cpp9
-rw-r--r--llvm/unittests/Support/ScaledNumberTest.cpp3
53 files changed, 119 insertions, 212 deletions
diff --git a/clang/include/clang/AST/BaseSubobject.h b/clang/include/clang/AST/BaseSubobject.h
index 151678fbd33..15600f02fce 100644
--- a/clang/include/clang/AST/BaseSubobject.h
+++ b/clang/include/clang/AST/BaseSubobject.h
@@ -80,11 +80,6 @@ template<> struct DenseMapInfo<clang::BaseSubobject> {
}
};
-// It's OK to treat BaseSubobject as a POD type.
-template <> struct isPodLike<clang::BaseSubobject> {
- static const bool value = true;
-};
-
} // namespace llvm
#endif // LLVM_CLANG_AST_BASESUBOBJECT_H
diff --git a/clang/include/clang/AST/CharUnits.h b/clang/include/clang/AST/CharUnits.h
index b029a1a3abb..37f489c7708 100644
--- a/clang/include/clang/AST/CharUnits.h
+++ b/clang/include/clang/AST/CharUnits.h
@@ -237,10 +237,6 @@ template<> struct DenseMapInfo<clang::CharUnits> {
}
};
-template <> struct isPodLike<clang::CharUnits> {
- static const bool value = true;
-};
-
} // end namespace llvm
#endif // LLVM_CLANG_AST_CHARUNITS_H
diff --git a/clang/include/clang/AST/DeclAccessPair.h b/clang/include/clang/AST/DeclAccessPair.h
index 9b333793415..805342c2910 100644
--- a/clang/include/clang/AST/DeclAccessPair.h
+++ b/clang/include/clang/AST/DeclAccessPair.h
@@ -60,12 +60,4 @@ public:
};
}
-// Take a moment to tell SmallVector that DeclAccessPair is POD.
-namespace llvm {
-template<typename> struct isPodLike;
-template<> struct isPodLike<clang::DeclAccessPair> {
- static const bool value = true;
-};
-}
-
#endif
diff --git a/clang/include/clang/AST/DeclarationName.h b/clang/include/clang/AST/DeclarationName.h
index 22f6bf7f44e..e5d34399f8d 100644
--- a/clang/include/clang/AST/DeclarationName.h
+++ b/clang/include/clang/AST/DeclarationName.h
@@ -861,9 +861,6 @@ struct DenseMapInfo<clang::DeclarationName> {
}
};
-template <>
-struct isPodLike<clang::DeclarationName> { static const bool value = true; };
-
} // namespace llvm
#endif // LLVM_CLANG_AST_DECLARATIONNAME_H
diff --git a/clang/include/clang/AST/ExprObjC.h b/clang/include/clang/AST/ExprObjC.h
index b51935d0d7f..debe5acebfd 100644
--- a/clang/include/clang/AST/ExprObjC.h
+++ b/clang/include/clang/AST/ExprObjC.h
@@ -255,12 +255,6 @@ struct ObjCDictionaryElement {
} // namespace clang
-namespace llvm {
-
-template <> struct isPodLike<clang::ObjCDictionaryElement> : std::true_type {};
-
-} // namespace llvm
-
namespace clang {
/// Internal struct for storing Key/value pair.
diff --git a/clang/include/clang/AST/GlobalDecl.h b/clang/include/clang/AST/GlobalDecl.h
index d6d8b110621..a5937c239ea 100644
--- a/clang/include/clang/AST/GlobalDecl.h
+++ b/clang/include/clang/AST/GlobalDecl.h
@@ -139,13 +139,6 @@ namespace llvm {
}
};
- // GlobalDecl isn't *technically* a POD type. However, its copy constructor,
- // copy assignment operator, and destructor are all trivial.
- template <>
- struct isPodLike<clang::GlobalDecl> {
- static const bool value = true;
- };
-
} // namespace llvm
#endif // LLVM_CLANG_AST_GLOBALDECL_H
diff --git a/clang/include/clang/AST/Type.h b/clang/include/clang/AST/Type.h
index 58e2f60fe76..fbf91d3088c 100644
--- a/clang/include/clang/AST/Type.h
+++ b/clang/include/clang/AST/Type.h
@@ -94,9 +94,6 @@ namespace llvm {
enum { NumLowBitsAvailable = clang::TypeAlignmentInBits };
};
- template <>
- struct isPodLike<clang::QualType> { static const bool value = true; };
-
} // namespace llvm
namespace clang {
diff --git a/clang/include/clang/Analysis/ProgramPoint.h b/clang/include/clang/Analysis/ProgramPoint.h
index 0f869233af6..623f5dc7072 100644
--- a/clang/include/clang/Analysis/ProgramPoint.h
+++ b/clang/include/clang/Analysis/ProgramPoint.h
@@ -777,9 +777,6 @@ static bool isEqual(const clang::ProgramPoint &L,
};
-template <>
-struct isPodLike<clang::ProgramPoint> { static const bool value = true; };
-
} // end namespace llvm
#endif
diff --git a/clang/include/clang/Basic/IdentifierTable.h b/clang/include/clang/Basic/IdentifierTable.h
index c5ad0e58304..465486ede71 100644
--- a/clang/include/clang/Basic/IdentifierTable.h
+++ b/clang/include/clang/Basic/IdentifierTable.h
@@ -938,9 +938,6 @@ struct DenseMapInfo<clang::Selector> {
}
};
-template <>
-struct isPodLike<clang::Selector> { static const bool value = true; };
-
template<>
struct PointerLikeTypeTraits<clang::Selector> {
static const void *getAsVoidPointer(clang::Selector P) {
diff --git a/clang/include/clang/Basic/SourceLocation.h b/clang/include/clang/Basic/SourceLocation.h
index 2b7f967d052..ceebdf48225 100644
--- a/clang/include/clang/Basic/SourceLocation.h
+++ b/clang/include/clang/Basic/SourceLocation.h
@@ -25,7 +25,6 @@
namespace llvm {
template <typename T> struct DenseMapInfo;
-template <typename T> struct isPodLike;
} // namespace llvm
@@ -457,11 +456,6 @@ namespace llvm {
}
};
- template <>
- struct isPodLike<clang::SourceLocation> { static const bool value = true; };
- template <>
- struct isPodLike<clang::FileID> { static const bool value = true; };
-
// Teach SmallPtrSet how to handle SourceLocation.
template<>
struct PointerLikeTypeTraits<clang::SourceLocation> {
diff --git a/clang/include/clang/Lex/Token.h b/clang/include/clang/Lex/Token.h
index 83f44337093..20483e393c1 100644
--- a/clang/include/clang/Lex/Token.h
+++ b/clang/include/clang/Lex/Token.h
@@ -328,9 +328,4 @@ struct PPConditionalInfo {
} // end namespace clang
-namespace llvm {
- template <>
- struct isPodLike<clang::Token> { static const bool value = true; };
-} // end namespace llvm
-
#endif // LLVM_CLANG_LEX_TOKEN_H
diff --git a/clang/include/clang/Sema/CodeCompleteConsumer.h b/clang/include/clang/Sema/CodeCompleteConsumer.h
index 005d62ad00c..5c14fb87737 100644
--- a/clang/include/clang/Sema/CodeCompleteConsumer.h
+++ b/clang/include/clang/Sema/CodeCompleteConsumer.h
@@ -655,14 +655,6 @@ public:
} // namespace clang
-namespace llvm {
-
-template <> struct isPodLike<clang::CodeCompletionString::Chunk> {
- static const bool value = true;
-};
-
-} // namespace llvm
-
namespace clang {
/// A builder class used to construct new code-completion strings.
diff --git a/clang/include/clang/Sema/Ownership.h b/clang/include/clang/Sema/Ownership.h
index 8a82c1382d5..f395282c0c5 100644
--- a/clang/include/clang/Sema/Ownership.h
+++ b/clang/include/clang/Sema/Ownership.h
@@ -128,9 +128,6 @@ namespace llvm {
}
};
- template <class T>
- struct isPodLike<clang::OpaquePtr<T>> { static const bool value = true; };
-
} // namespace llvm
namespace clang {
diff --git a/clang/include/clang/StaticAnalyzer/Core/PathSensitive/SVals.h b/clang/include/clang/StaticAnalyzer/Core/PathSensitive/SVals.h
index d956133d030..e859936621d 100644
--- a/clang/include/clang/StaticAnalyzer/Core/PathSensitive/SVals.h
+++ b/clang/include/clang/StaticAnalyzer/Core/PathSensitive/SVals.h
@@ -667,13 +667,4 @@ private:
} // namespace clang
-namespace llvm {
-
-template <typename T> struct isPodLike;
-template <> struct isPodLike<clang::ento::SVal> {
- static const bool value = true;
-};
-
-} // namespace llvm
-
#endif // LLVM_CLANG_STATICANALYZER_CORE_PATHSENSITIVE_SVALS_H
diff --git a/clang/lib/AST/VTableBuilder.cpp b/clang/lib/AST/VTableBuilder.cpp
index d2701720e91..85c4fca378e 100644
--- a/clang/lib/AST/VTableBuilder.cpp
+++ b/clang/lib/AST/VTableBuilder.cpp
@@ -846,6 +846,8 @@ private:
: BaseOffset(CharUnits::Zero()),
BaseOffsetInLayoutClass(CharUnits::Zero()),
VTableIndex(0) { }
+
+ MethodInfo(MethodInfo const&) = default;
};
typedef llvm::DenseMap<const CXXMethodDecl *, MethodInfo> MethodInfoMapTy;
diff --git a/clang/lib/Sema/SemaChecking.cpp b/clang/lib/Sema/SemaChecking.cpp
index b3c3d7bbe9f..90c931f8844 100644
--- a/clang/lib/Sema/SemaChecking.cpp
+++ b/clang/lib/Sema/SemaChecking.cpp
@@ -11662,12 +11662,12 @@ class SequenceChecker : public EvaluatedExprVisitor<SequenceChecker> {
class Seq {
friend class SequenceTree;
- unsigned Index = 0;
+ unsigned Index;
explicit Seq(unsigned N) : Index(N) {}
public:
- Seq() = default;
+ Seq() : Index(0) {}
};
SequenceTree() { Values.push_back(Value(0)); }
diff --git a/clang/lib/StaticAnalyzer/Core/RegionStore.cpp b/clang/lib/StaticAnalyzer/Core/RegionStore.cpp
index c15c48cc46e..679d95b7c58 100644
--- a/clang/lib/StaticAnalyzer/Core/RegionStore.cpp
+++ b/clang/lib/StaticAnalyzer/Core/RegionStore.cpp
@@ -130,10 +130,6 @@ namespace llvm {
return os;
}
- template <typename T> struct isPodLike;
- template <> struct isPodLike<BindingKey> {
- static const bool value = true;
- };
} // end llvm namespace
#ifndef NDEBUG
diff --git a/clang/test/Analysis/llvm-conventions.cpp b/clang/test/Analysis/llvm-conventions.cpp
index 49bdc6380bc..e8588db60f4 100644
--- a/clang/test/Analysis/llvm-conventions.cpp
+++ b/clang/test/Analysis/llvm-conventions.cpp
@@ -152,8 +152,6 @@ inline bool operator>(StringRef LHS, StringRef RHS);
inline bool operator>=(StringRef LHS, StringRef RHS);
inline std::string &operator+=(std::string &buffer, StringRef string);
hash_code hash_value(StringRef S);
-template <typename T> struct isPodLike;
-template <> struct isPodLike<StringRef> { static const bool value = true; };
} // end of namespace llvm
diff --git a/clang/tools/libclang/Indexing.cpp b/clang/tools/libclang/Indexing.cpp
index 1833a801824..d666d4bff47 100644
--- a/clang/tools/libclang/Indexing.cpp
+++ b/clang/tools/libclang/Indexing.cpp
@@ -93,9 +93,6 @@ typedef llvm::DenseSet<PPRegion> PPRegionSetTy;
} // end anonymous namespace
namespace llvm {
- template <> struct isPodLike<PPRegion> {
- static const bool value = true;
- };
template <>
struct DenseMapInfo<PPRegion> {
diff --git a/llvm/docs/ProgrammersManual.rst b/llvm/docs/ProgrammersManual.rst
index 0903a22fc3e..7faba112ffe 100644
--- a/llvm/docs/ProgrammersManual.rst
+++ b/llvm/docs/ProgrammersManual.rst
@@ -1456,7 +1456,7 @@ SmallVector has grown a few other minor advantages over std::vector, causing
#. std::vector is exception-safe, and some implementations have pessimizations
that copy elements when SmallVector would move them.
-#. SmallVector understands ``isPodLike<Type>`` and uses realloc aggressively.
+#. SmallVector understands ``llvm::is_trivially_copyable<Type>`` and uses realloc aggressively.
#. Many LLVM APIs take a SmallVectorImpl as an out parameter (see the note
below).
diff --git a/llvm/include/llvm/ADT/ArrayRef.h b/llvm/include/llvm/ADT/ArrayRef.h
index e6834269c0c..75bb7d690cc 100644
--- a/llvm/include/llvm/ADT/ArrayRef.h
+++ b/llvm/include/llvm/ADT/ArrayRef.h
@@ -525,12 +525,6 @@ namespace llvm {
/// @}
- // ArrayRefs can be treated like a POD type.
- template <typename T> struct isPodLike;
- template <typename T> struct isPodLike<ArrayRef<T>> {
- static const bool value = true;
- };
-
template <typename T> hash_code hash_value(ArrayRef<T> S) {
return hash_combine_range(S.begin(), S.end());
}
diff --git a/llvm/include/llvm/ADT/DenseMap.h b/llvm/include/llvm/ADT/DenseMap.h
index 289cc4a0347..e7cd370df6f 100644
--- a/llvm/include/llvm/ADT/DenseMap.h
+++ b/llvm/include/llvm/ADT/DenseMap.h
@@ -145,7 +145,8 @@ public:
}
const KeyT EmptyKey = getEmptyKey(), TombstoneKey = getTombstoneKey();
- if (isPodLike<KeyT>::value && isPodLike<ValueT>::value) {
+ if (is_trivially_copyable<KeyT>::value &&
+ is_trivially_copyable<ValueT>::value) {
// Use a simpler loop when these are trivial types.
for (BucketT *P = getBuckets(), *E = getBucketsEnd(); P != E; ++P)
P->getFirst() = EmptyKey;
@@ -421,7 +422,8 @@ protected:
setNumEntries(other.getNumEntries());
setNumTombstones(other.getNumTombstones());
- if (isPodLike<KeyT>::value && isPodLike<ValueT>::value)
+ if (is_trivially_copyable<KeyT>::value &&
+ is_trivially_copyable<ValueT>::value)
memcpy(reinterpret_cast<void *>(getBuckets()), other.getBuckets(),
getNumBuckets() * sizeof(BucketT));
else
diff --git a/llvm/include/llvm/ADT/ImmutableList.h b/llvm/include/llvm/ADT/ImmutableList.h
index 37c91cdd369..c9ee494734e 100644
--- a/llvm/include/llvm/ADT/ImmutableList.h
+++ b/llvm/include/llvm/ADT/ImmutableList.h
@@ -241,10 +241,6 @@ template<typename T> struct DenseMapInfo<ImmutableList<T>> {
}
};
-template <typename T> struct isPodLike;
-template <typename T>
-struct isPodLike<ImmutableList<T>> { static const bool value = true; };
-
} // end namespace llvm
#endif // LLVM_ADT_IMMUTABLELIST_H
diff --git a/llvm/include/llvm/ADT/Optional.h b/llvm/include/llvm/ADT/Optional.h
index 32401da517e..25a3185064f 100644
--- a/llvm/include/llvm/ADT/Optional.h
+++ b/llvm/include/llvm/ADT/Optional.h
@@ -30,7 +30,7 @@ class raw_ostream;
namespace optional_detail {
/// Storage for any type.
-template <typename T, bool = isPodLike<T>::value> struct OptionalStorage {
+template <typename T, bool = is_trivially_copyable<T>::value> struct OptionalStorage {
AlignedCharArrayUnion<T> storage;
bool hasVal = false;
@@ -185,11 +185,6 @@ public:
#endif
};
-template <typename T> struct isPodLike<Optional<T>> {
- // An Optional<T> is pod-like if T is.
- static const bool value = isPodLike<T>::value;
-};
-
template <typename T, typename U>
bool operator==(const Optional<T> &X, const Optional<U> &Y) {
if (X && Y)
diff --git a/llvm/include/llvm/ADT/PointerIntPair.h b/llvm/include/llvm/ADT/PointerIntPair.h
index b73e3c9ba82..b132de81987 100644
--- a/llvm/include/llvm/ADT/PointerIntPair.h
+++ b/llvm/include/llvm/ADT/PointerIntPair.h
@@ -175,12 +175,6 @@ struct PointerIntPairInfo {
}
};
-template <typename T> struct isPodLike;
-template <typename PointerTy, unsigned IntBits, typename IntType>
-struct isPodLike<PointerIntPair<PointerTy, IntBits, IntType>> {
- static const bool value = true;
-};
-
// Provide specialization of DenseMapInfo for PointerIntPair.
template <typename PointerTy, unsigned IntBits, typename IntType>
struct DenseMapInfo<PointerIntPair<PointerTy, IntBits, IntType>> {
diff --git a/llvm/include/llvm/ADT/SmallVector.h b/llvm/include/llvm/ADT/SmallVector.h
index 7650001d617..34efb05d43d 100644
--- a/llvm/include/llvm/ADT/SmallVector.h
+++ b/llvm/include/llvm/ADT/SmallVector.h
@@ -179,9 +179,9 @@ public:
}
};
-/// SmallVectorTemplateBase<isPodLike = false> - This is where we put method
+/// SmallVectorTemplateBase<TriviallyCopyable = false> - This is where we put method
/// implementations that are designed to work with non-POD-like T's.
-template <typename T, bool = isPodLike<T>::value>
+template <typename T, bool = is_trivially_copyable<T>::value>
class SmallVectorTemplateBase : public SmallVectorTemplateCommon<T> {
protected:
SmallVectorTemplateBase(size_t Size) : SmallVectorTemplateCommon<T>(Size) {}
@@ -235,8 +235,8 @@ public:
};
// Define this out-of-line to dissuade the C++ compiler from inlining it.
-template <typename T, bool isPodLike>
-void SmallVectorTemplateBase<T, isPodLike>::grow(size_t MinSize) {
+template <typename T, bool TriviallyCopyable>
+void SmallVectorTemplateBase<T, TriviallyCopyable>::grow(size_t MinSize) {
if (MinSize > UINT32_MAX)
report_bad_alloc_error("SmallVector capacity overflow during allocation");
@@ -259,9 +259,8 @@ void SmallVectorTemplateBase<T, isPodLike>::grow(size_t MinSize) {
this->Capacity = NewCapacity;
}
-
-/// SmallVectorTemplateBase<isPodLike = true> - This is where we put method
-/// implementations that are designed to work with POD-like T's.
+/// SmallVectorTemplateBase<TriviallyCopyable = true> - This is where we put
+/// method implementations that are designed to work with POD-like T's.
template <typename T>
class SmallVectorTemplateBase<T, true> : public SmallVectorTemplateCommon<T> {
protected:
@@ -330,7 +329,7 @@ public:
protected:
// Default ctor - Initialize to empty.
explicit SmallVectorImpl(unsigned N)
- : SmallVectorTemplateBase<T, isPodLike<T>::value>(N) {}
+ : SmallVectorTemplateBase<T>(N) {}
public:
SmallVectorImpl(const SmallVectorImpl &) = delete;
diff --git a/llvm/include/llvm/ADT/StringRef.h b/llvm/include/llvm/ADT/StringRef.h
index a98ed94ff28..76687a94bca 100644
--- a/llvm/include/llvm/ADT/StringRef.h
+++ b/llvm/include/llvm/ADT/StringRef.h
@@ -927,10 +927,6 @@ namespace llvm {
LLVM_NODISCARD
hash_code hash_value(StringRef S);
- // StringRefs can be treated like a POD type.
- template <typename T> struct isPodLike;
- template <> struct isPodLike<StringRef> { static const bool value = true; };
-
} // end namespace llvm
#endif // LLVM_ADT_STRINGREF_H
diff --git a/llvm/include/llvm/ADT/bit.h b/llvm/include/llvm/ADT/bit.h
index 9b084c840ad..a790d5ed2d2 100644
--- a/llvm/include/llvm/ADT/bit.h
+++ b/llvm/include/llvm/ADT/bit.h
@@ -40,11 +40,11 @@ template <typename To, typename From
, typename = typename std::enable_if<__is_trivially_copyable(To)>::type
, typename = typename std::enable_if<__is_trivially_copyable(From)>::type
#else
- // This case is GCC 4.x. clang with libc++ or libstdc++ never get here. Unlike
- // llvm/Support/type_traits.h's isPodLike we don't want to provide a
- // good-enough answer here: developers in that configuration will hit
- // compilation failures on the bots instead of locally. That's acceptable
- // because it's very few developers, and only until we move past C++11.
+// This case is GCC 4.x. clang with libc++ or libstdc++ never get here. Unlike
+// llvm/Support/type_traits.h's is_trivially_copyable we don't want to
+// provide a good-enough answer here: developers in that configuration will hit
+// compilation failures on the bots instead of locally. That's acceptable
+// because it's very few developers, and only until we move past C++11.
#endif
>
inline To bit_cast(const From &from) noexcept {
diff --git a/llvm/include/llvm/Analysis/BlockFrequencyInfoImpl.h b/llvm/include/llvm/Analysis/BlockFrequencyInfoImpl.h
index 31e361cc30b..813bad49888 100644
--- a/llvm/include/llvm/Analysis/BlockFrequencyInfoImpl.h
+++ b/llvm/include/llvm/Analysis/BlockFrequencyInfoImpl.h
@@ -159,10 +159,6 @@ inline raw_ostream &operator<<(raw_ostream &OS, BlockMass X) {
} // end namespace bfi_detail
-template <> struct isPodLike<bfi_detail::BlockMass> {
- static const bool value = true;
-};
-
/// Base class for BlockFrequencyInfoImpl
///
/// BlockFrequencyInfoImplBase has supporting data structures and some
@@ -186,9 +182,9 @@ public:
struct BlockNode {
using IndexType = uint32_t;
- IndexType Index = std::numeric_limits<uint32_t>::max();
+ IndexType Index;
- BlockNode() = default;
+ BlockNode() : Index(std::numeric_limits<uint32_t>::max()) {}
BlockNode(IndexType Index) : Index(Index) {}
bool operator==(const BlockNode &X) const { return Index == X.Index; }
diff --git a/llvm/include/llvm/Bitcode/BitCodes.h b/llvm/include/llvm/Bitcode/BitCodes.h
index 4cc38bf28ba..a0d8dfd68bf 100644
--- a/llvm/include/llvm/Bitcode/BitCodes.h
+++ b/llvm/include/llvm/Bitcode/BitCodes.h
@@ -159,8 +159,6 @@ public:
};
-template <> struct isPodLike<BitCodeAbbrevOp> { static const bool value=true; };
-
/// BitCodeAbbrev - This class represents an abbreviation record. An
/// abbreviation allows a complex record that has redundancy to be stored in a
/// specialized format instead of the fully-general, fully-vbr, format.
diff --git a/llvm/include/llvm/CodeGen/DIE.h b/llvm/include/llvm/CodeGen/DIE.h
index aae6c6ecd28..9e7167fd88c 100644
--- a/llvm/include/llvm/CodeGen/DIE.h
+++ b/llvm/include/llvm/CodeGen/DIE.h
@@ -799,7 +799,7 @@ class DIEUnit {
const uint16_t Version; /// The Dwarf version number for this unit.
const uint8_t AddrSize; /// The size in bytes of an address for this unit.
protected:
- ~DIEUnit() = default;
+ virtual ~DIEUnit() = default;
public:
DIEUnit(uint16_t Version, uint8_t AddrSize, dwarf::Tag UnitTag);
diff --git a/llvm/include/llvm/CodeGen/RegisterPressure.h b/llvm/include/llvm/CodeGen/RegisterPressure.h
index 2797d8fa908..5bbaa03fd75 100644
--- a/llvm/include/llvm/CodeGen/RegisterPressure.h
+++ b/llvm/include/llvm/CodeGen/RegisterPressure.h
@@ -131,10 +131,6 @@ public:
}
};
-template <> struct isPodLike<PressureChange> {
- static const bool value = true;
-};
-
/// List of PressureChanges in order of increasing, unique PSetID.
///
/// Use a small fixed number, because we can fit more PressureChanges in an
diff --git a/llvm/include/llvm/CodeGen/ScheduleDAG.h b/llvm/include/llvm/CodeGen/ScheduleDAG.h
index 6d33dda1566..68614dded81 100644
--- a/llvm/include/llvm/CodeGen/ScheduleDAG.h
+++ b/llvm/include/llvm/CodeGen/ScheduleDAG.h
@@ -238,9 +238,6 @@ class TargetRegisterInfo;
void dump(const TargetRegisterInfo *TRI = nullptr) const;
};
- template <>
- struct isPodLike<SDep> { static const bool value = true; };
-
/// Scheduling unit. This is a node in the scheduling DAG.
class SUnit {
private:
diff --git a/llvm/include/llvm/CodeGen/SelectionDAGNodes.h b/llvm/include/llvm/CodeGen/SelectionDAGNodes.h
index 09d058da0b6..ec0fce6202b 100644
--- a/llvm/include/llvm/CodeGen/SelectionDAGNodes.h
+++ b/llvm/include/llvm/CodeGen/SelectionDAGNodes.h
@@ -231,7 +231,6 @@ template<> struct DenseMapInfo<SDValue> {
return LHS == RHS;
}
};
-template <> struct isPodLike<SDValue> { static const bool value = true; };
/// Allow casting operators to work directly on
/// SDValues as if they were SDNode*'s.
diff --git a/llvm/include/llvm/CodeGen/SlotIndexes.h b/llvm/include/llvm/CodeGen/SlotIndexes.h
index 90904d6702f..63461d61bf3 100644
--- a/llvm/include/llvm/CodeGen/SlotIndexes.h
+++ b/llvm/include/llvm/CodeGen/SlotIndexes.h
@@ -301,8 +301,6 @@ class raw_ostream;
}
};
- template <> struct isPodLike<SlotIndex> { static const bool value = true; };
-
inline raw_ostream& operator<<(raw_ostream &os, SlotIndex li) {
li.print(os);
return os;
diff --git a/llvm/include/llvm/CodeGen/TargetPassConfig.h b/llvm/include/llvm/CodeGen/TargetPassConfig.h
index c021958d93a..5567ff6f27a 100644
--- a/llvm/include/llvm/CodeGen/TargetPassConfig.h
+++ b/llvm/include/llvm/CodeGen/TargetPassConfig.h
@@ -74,9 +74,6 @@ public:
}
};
-template <> struct isPodLike<IdentifyingPassPtr> {
- static const bool value = true;
-};
/// Target-Independent Code Generator Pass Configuration Options.
///
diff --git a/llvm/include/llvm/IR/CFG.h b/llvm/include/llvm/IR/CFG.h
index 98e61ee47a5..55aff7137e8 100644
--- a/llvm/include/llvm/IR/CFG.h
+++ b/llvm/include/llvm/IR/CFG.h
@@ -237,10 +237,6 @@ public:
}
};
-template <typename T, typename U> struct isPodLike<SuccIterator<T, U>> {
- static const bool value = isPodLike<T>::value;
-};
-
using succ_iterator = SuccIterator<Instruction, BasicBlock>;
using succ_const_iterator = SuccIterator<const Instruction, const BasicBlock>;
using succ_range = iterator_range<succ_iterator>;
diff --git a/llvm/include/llvm/IR/ValueHandle.h b/llvm/include/llvm/IR/ValueHandle.h
index 4e17ae34d28..1135d796f7e 100644
--- a/llvm/include/llvm/IR/ValueHandle.h
+++ b/llvm/include/llvm/IR/ValueHandle.h
@@ -308,15 +308,6 @@ struct DenseMapInfo<AssertingVH<T>> {
}
};
-template <typename T>
-struct isPodLike<AssertingVH<T>> {
-#ifdef NDEBUG
- static const bool value = true;
-#else
- static const bool value = false;
-#endif
-};
-
/// Value handle that tracks a Value across RAUW.
///
/// TrackingVH is designed for situations where a client needs to hold a handle
@@ -548,14 +539,6 @@ template <typename T> struct DenseMapInfo<PoisoningVH<T>> {
}
};
-template <typename T> struct isPodLike<PoisoningVH<T>> {
-#ifdef NDEBUG
- static const bool value = true;
-#else
- static const bool value = false;
-#endif
-};
-
} // end namespace llvm
#endif // LLVM_IR_VALUEHANDLE_H
diff --git a/llvm/include/llvm/MC/MCInst.h b/llvm/include/llvm/MC/MCInst.h
index 4cb88b3c97e..9675b786745 100644
--- a/llvm/include/llvm/MC/MCInst.h
+++ b/llvm/include/llvm/MC/MCInst.h
@@ -153,8 +153,6 @@ public:
bool evaluateAsConstantImm(int64_t &Imm) const;
};
-template <> struct isPodLike<MCOperand> { static const bool value = true; };
-
/// Instances of this class represent a single low-level machine
/// instruction.
class MCInst {
diff --git a/llvm/include/llvm/Support/ScaledNumber.h b/llvm/include/llvm/Support/ScaledNumber.h
index e84c044df04..552da34f357 100644
--- a/llvm/include/llvm/Support/ScaledNumber.h
+++ b/llvm/include/llvm/Support/ScaledNumber.h
@@ -886,10 +886,6 @@ template <class DigitsT> void ScaledNumber<DigitsT>::shiftRight(int32_t Shift) {
Digits >>= Shift;
}
-template <typename T> struct isPodLike;
-template <typename T> struct isPodLike<ScaledNumber<T>> {
- static const bool value = true;
-};
} // end namespace llvm
diff --git a/llvm/include/llvm/Support/type_traits.h b/llvm/include/llvm/Support/type_traits.h
index 7d68a12e66f..b8cf12d03d2 100644
--- a/llvm/include/llvm/Support/type_traits.h
+++ b/llvm/include/llvm/Support/type_traits.h
@@ -24,35 +24,6 @@
namespace llvm {
-/// isPodLike - This is a type trait that is used to determine whether a given
-/// type can be copied around with memcpy instead of running ctors etc.
-template <typename T>
-struct isPodLike {
- // std::is_trivially_copyable is available in libc++ with clang, libstdc++
- // that comes with GCC 5. MSVC 2015 and newer also have
- // std::is_trivially_copyable.
-#if (__has_feature(is_trivially_copyable) && defined(_LIBCPP_VERSION)) || \
- (defined(__GNUC__) && __GNUC__ >= 5) || defined(_MSC_VER)
- // If the compiler supports the is_trivially_copyable trait use it, as it
- // matches the definition of isPodLike closely.
- static const bool value = std::is_trivially_copyable<T>::value;
-#elif __has_feature(is_trivially_copyable)
- // Use the internal name if the compiler supports is_trivially_copyable but we
- // don't know if the standard library does. This is the case for clang in
- // conjunction with libstdc++ from GCC 4.x.
- static const bool value = __is_trivially_copyable(T);
-#else
- // If we don't know anything else, we can (at least) assume that all non-class
- // types are PODs.
- static const bool value = !std::is_class<T>::value;
-#endif
-};
-
-// std::pair's are pod-like if their elements are.
-template<typename T, typename U>
-struct isPodLike<std::pair<T, U>> {
- static const bool value = isPodLike<T>::value && isPodLike<U>::value;
-};
/// Metafunction that determines whether the given type is either an
/// integral type or an enumeration type, including enum classes.
@@ -119,6 +90,11 @@ template<typename T> union move_construction_triviality_helper {
move_construction_triviality_helper(move_construction_triviality_helper&&) = default;
~move_construction_triviality_helper() = default;
};
+
+template<class T>
+union trivial_helper {
+ T t;
+};
} // end namespace detail
/// An implementation of `std::is_trivially_copy_constructible` since we have
@@ -143,6 +119,56 @@ struct is_trivially_move_constructible<T &> : std::true_type {};
template <typename T>
struct is_trivially_move_constructible<T &&> : std::true_type {};
+// An implementation of `std::is_trivially_copyable` since STL version
+// is not equally supported by all compilers, especially GCC 4.9.
+// Uniform implementation of this trait is important for ABI compatibility
+// as it has an impact on SmallVector's ABI (among others).
+template <typename T>
+class is_trivially_copyable {
+
+ // copy constructors
+ static constexpr bool has_trivial_copy_constructor =
+ std::is_copy_constructible<detail::trivial_helper<T>>::value;
+ static constexpr bool has_deleted_copy_constructor =
+ !std::is_copy_constructible<T>::value;
+
+ // move constructors
+ static constexpr bool has_trivial_move_constructor =
+ std::is_move_constructible<detail::trivial_helper<T>>::value;
+ static constexpr bool has_deleted_move_constructor =
+ !std::is_move_constructible<T>::value;
+
+ // copy assign
+ static constexpr bool has_trivial_copy_assign =
+ std::is_copy_assignable<detail::trivial_helper<T>>::value;
+ static constexpr bool has_deleted_copy_assign =
+ !std::is_copy_assignable<T>::value;
+
+ // move assign
+ static constexpr bool has_trivial_move_assign =
+ std::is_move_assignable<detail::trivial_helper<T>>::value;
+ static constexpr bool has_deleted_move_assign =
+ !std::is_move_assignable<T>::value;
+
+ // destructor
+ static constexpr bool has_trivial_destructor =
+ std::is_destructible<detail::trivial_helper<T>>::value;
+
+ public:
+
+ static constexpr bool value =
+ has_trivial_destructor &&
+ (has_deleted_move_assign || has_trivial_move_assign) &&
+ (has_deleted_move_constructor || has_trivial_move_constructor) &&
+ (has_deleted_copy_assign || has_trivial_copy_assign) &&
+ (has_deleted_copy_constructor || has_trivial_copy_constructor);
+
+#if (__has_feature(is_trivially_copyable) || (defined(__GNUC__) && __GNUC__ >= 5))
+ static_assert(value == std::is_trivially_copyable<T>::value, "inconsistent behavior between llvm:: and std:: implementation of is_trivially_copyable");
+#endif
+};
+
+
} // end namespace llvm
// If the compiler supports detecting whether a class is final, define
diff --git a/llvm/lib/Transforms/Scalar/SROA.cpp b/llvm/lib/Transforms/Scalar/SROA.cpp
index be65d16120c..991e9c7c52f 100644
--- a/llvm/lib/Transforms/Scalar/SROA.cpp
+++ b/llvm/lib/Transforms/Scalar/SROA.cpp
@@ -221,13 +221,6 @@ public:
} // end anonymous namespace
-namespace llvm {
-
-template <typename T> struct isPodLike;
-template <> struct isPodLike<Slice> { static const bool value = true; };
-
-} // end namespace llvm
-
/// Representation of the alloca slices.
///
/// This class represents the slices of an alloca which are formed by its
diff --git a/llvm/tools/llvm-diff/DifferenceEngine.cpp b/llvm/tools/llvm-diff/DifferenceEngine.cpp
index a1c6005ae9c..bc93ece8649 100644
--- a/llvm/tools/llvm-diff/DifferenceEngine.cpp
+++ b/llvm/tools/llvm-diff/DifferenceEngine.cpp
@@ -67,7 +67,7 @@ public:
unsigned NewSize = Storage.size() - 1;
if (NewSize) {
// Move the slot at the end to the beginning.
- if (isPodLike<T>::value)
+ if (is_trivially_copyable<T>::value)
Storage[0] = Storage[NewSize];
else
std::swap(Storage[0], Storage[NewSize]);
diff --git a/llvm/unittests/ADT/ArrayRefTest.cpp b/llvm/unittests/ADT/ArrayRefTest.cpp
index ba540688cb5..a5609f89ff9 100644
--- a/llvm/unittests/ADT/ArrayRefTest.cpp
+++ b/llvm/unittests/ADT/ArrayRefTest.cpp
@@ -248,4 +248,7 @@ TEST(ArrayRefTest, makeArrayRef) {
EXPECT_TRUE(AR2.equals(AR2Ref));
}
+static_assert(is_trivially_copyable<ArrayRef<int>>::value,
+ "trivially copyable");
+
} // end anonymous namespace
diff --git a/llvm/unittests/ADT/ImmutableListTest.cpp b/llvm/unittests/ADT/ImmutableListTest.cpp
index bd5289d6b29..b0b1e0e6c29 100644
--- a/llvm/unittests/ADT/ImmutableListTest.cpp
+++ b/llvm/unittests/ADT/ImmutableListTest.cpp
@@ -267,4 +267,7 @@ TEST_F(ImmutableListTest, LongListOrderingTest) {
ASSERT_EQ(6, i);
}
+static_assert(is_trivially_copyable<ImmutableList<Wrapper<long>>>::value,
+ "trivially copyable");
+
} // namespace
diff --git a/llvm/unittests/ADT/PointerIntPairTest.cpp b/llvm/unittests/ADT/PointerIntPairTest.cpp
index 95e280330a7..6b3a4c055c9 100644
--- a/llvm/unittests/ADT/PointerIntPairTest.cpp
+++ b/llvm/unittests/ADT/PointerIntPairTest.cpp
@@ -61,6 +61,9 @@ TEST(PointerIntPairTest, GetSet) {
Pair2.setPointerAndInt(&s, E::Case3);
EXPECT_EQ(&s, Pair2.getPointer());
EXPECT_EQ(E::Case3, Pair2.getInt());
+
+ static_assert(is_trivially_copyable<PointerIntPair<S *, 2, E>>::value,
+ "trivially copyable");
}
TEST(PointerIntPairTest, DefaultInitialize) {
@@ -96,6 +99,11 @@ TEST(PointerIntPairTest, ManyUnusedBits) {
EXPECT_EQ(FixnumPointerTraits::NumLowBitsAvailable - 1,
PointerLikeTypeTraits<decltype(pair)>::NumLowBitsAvailable);
+
+ static_assert(
+ is_trivially_copyable<
+ PointerIntPair<Fixnum31, 1, bool, FixnumPointerTraits>>::value,
+ "trivially copyable");
}
} // end anonymous namespace
diff --git a/llvm/unittests/ADT/StringRefTest.cpp b/llvm/unittests/ADT/StringRefTest.cpp
index fbb60e6ce26..6f83dc3224a 100644
--- a/llvm/unittests/ADT/StringRefTest.cpp
+++ b/llvm/unittests/ADT/StringRefTest.cpp
@@ -1061,4 +1061,6 @@ TEST(StringRefTest, StringLiteral) {
EXPECT_EQ(StringRef("Bar"), Strings[1]);
}
+static_assert(is_trivially_copyable<StringRef>::value, "trivially copyable");
+
} // end anonymous namespace
diff --git a/llvm/unittests/Analysis/BlockFrequencyInfoTest.cpp b/llvm/unittests/Analysis/BlockFrequencyInfoTest.cpp
index 5572f5ba597..2aeba947a74 100644
--- a/llvm/unittests/Analysis/BlockFrequencyInfoTest.cpp
+++ b/llvm/unittests/Analysis/BlockFrequencyInfoTest.cpp
@@ -7,6 +7,7 @@
//===----------------------------------------------------------------------===//
#include "llvm/Analysis/BlockFrequencyInfo.h"
+#include "llvm/Analysis/BlockFrequencyInfoImpl.h"
#include "llvm/Analysis/BranchProbabilityInfo.h"
#include "llvm/Analysis/LoopInfo.h"
#include "llvm/AsmParser/Parser.h"
@@ -90,5 +91,8 @@ TEST_F(BlockFrequencyInfoTest, Basic) {
EXPECT_EQ(BFI.getBlockFreq(BB3).getFrequency(), BB3Freq);
}
+static_assert(is_trivially_copyable<bfi_detail::BlockMass>::value,
+ "trivially copyable");
+
} // end anonymous namespace
} // end namespace llvm
diff --git a/llvm/unittests/Bitcode/BitstreamReaderTest.cpp b/llvm/unittests/Bitcode/BitstreamReaderTest.cpp
index e9e6d9a1d07..85954858609 100644
--- a/llvm/unittests/Bitcode/BitstreamReaderTest.cpp
+++ b/llvm/unittests/Bitcode/BitstreamReaderTest.cpp
@@ -147,4 +147,7 @@ TEST(BitstreamReaderTest, shortRead) {
}
}
+static_assert(is_trivially_copyable<BitCodeAbbrevOp>::value,
+ "trivially copyable");
+
} // end anonymous namespace
diff --git a/llvm/unittests/CodeGen/CMakeLists.txt b/llvm/unittests/CodeGen/CMakeLists.txt
index 5ef8c2afb8c..772c075de12 100644
--- a/llvm/unittests/CodeGen/CMakeLists.txt
+++ b/llvm/unittests/CodeGen/CMakeLists.txt
@@ -19,6 +19,7 @@ add_llvm_unittest(CodeGenTests
MachineInstrTest.cpp
MachineOperandTest.cpp
ScalableVectorMVTsTest.cpp
+ TypeTraitsTest.cpp
)
add_subdirectory(GlobalISel)
diff --git a/llvm/unittests/CodeGen/MachineInstrTest.cpp b/llvm/unittests/CodeGen/MachineInstrTest.cpp
index 880e013b99f..2678a4589f9 100644
--- a/llvm/unittests/CodeGen/MachineInstrTest.cpp
+++ b/llvm/unittests/CodeGen/MachineInstrTest.cpp
@@ -272,4 +272,6 @@ TEST(MachineInstrPrintingTest, DebugLocPrinting) {
StringRef(OS.str()).endswith("filename:1:5"));
}
+static_assert(is_trivially_copyable<MCOperand>::value, "trivially copyable");
+
} // end namespace
diff --git a/llvm/unittests/IR/CFGBuilder.cpp b/llvm/unittests/IR/CFGBuilder.cpp
index ca7a0555dd0..a2016f7e6cb 100644
--- a/llvm/unittests/IR/CFGBuilder.cpp
+++ b/llvm/unittests/IR/CFGBuilder.cpp
@@ -8,6 +8,7 @@
#include "CFGBuilder.h"
+#include "llvm/IR/CFG.h"
#include "llvm/IR/IRBuilder.h"
#include "llvm/IR/LLVMContext.h"
#include "llvm/Support/Debug.h"
@@ -265,3 +266,11 @@ TEST(CFGBuilder, Rebuild) {
EXPECT_TRUE(isa<SwitchInst>(B.getOrAddBlock("c")->getTerminator()));
EXPECT_TRUE(isa<SwitchInst>(B.getOrAddBlock("d")->getTerminator()));
}
+
+static_assert(is_trivially_copyable<succ_iterator>::value,
+ "trivially copyable");
+static_assert(is_trivially_copyable<succ_const_iterator>::value,
+ "trivially copyable");
+static_assert(is_trivially_copyable<succ_range>::value, "trivially copyable");
+static_assert(is_trivially_copyable<succ_const_range>::value,
+ "trivially copyable");
diff --git a/llvm/unittests/Support/ScaledNumberTest.cpp b/llvm/unittests/Support/ScaledNumberTest.cpp
index 449c0477b0a..3fa63b7bf3c 100644
--- a/llvm/unittests/Support/ScaledNumberTest.cpp
+++ b/llvm/unittests/Support/ScaledNumberTest.cpp
@@ -562,4 +562,7 @@ TEST(ScaledNumberHelpersTest, toIntBug) {
EXPECT_EQ(1u, (n * n).toInt<uint32_t>());
}
+static_assert(is_trivially_copyable<ScaledNumber<uint32_t>>::value,
+ "trivially copyable");
+
} // end namespace
OpenPOWER on IntegriCloud