Skip to content

Commit be88539

Browse files
Replace llvm::isPodLike<...> by llvm::is_trivially_copyable<...>
As noted in https://bugs.llvm.org/show_bug.cgi?id=36651, the specialization for isPodLike<std::pair<...>> did not match the expectation of std::is_trivially_copyable which makes the memcpy optimization invalid. This patch renames the llvm::isPodLike trait into llvm::is_trivially_copyable. Unfortunately std::is_trivially_copyable is not portable across compiler / STL versions. So a portable version is provided too. Note that the following specialization were invalid: std::pair<T0, T1> llvm::Optional<T> Tests have been added to assert that former specialization are respected by the standard usage of llvm::is_trivially_copyable, and that when a decent version of std::is_trivially_copyable is available, llvm::is_trivially_copyable is compared to std::is_trivially_copyable. As of this patch, llvm::Optional is no longer considered trivially copyable, even if T is. This is to be fixed in a later patch, as it has impact on a long-running bug (see r347004) Note that GCC warns about this UB, but this got silented by https://reviews.llvm.org/D50296. Differential Revision: https://reviews.llvm.org/D54472 llvm-svn: 351701
1 parent 7ac79ed commit be88539

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

53 files changed

+119
-212
lines changed

clang/include/clang/AST/BaseSubobject.h

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -80,11 +80,6 @@ template<> struct DenseMapInfo<clang::BaseSubobject> {
8080
}
8181
};
8282

83-
// It's OK to treat BaseSubobject as a POD type.
84-
template <> struct isPodLike<clang::BaseSubobject> {
85-
static const bool value = true;
86-
};
87-
8883
} // namespace llvm
8984

9085
#endif // LLVM_CLANG_AST_BASESUBOBJECT_H

clang/include/clang/AST/CharUnits.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -237,10 +237,6 @@ template<> struct DenseMapInfo<clang::CharUnits> {
237237
}
238238
};
239239

240-
template <> struct isPodLike<clang::CharUnits> {
241-
static const bool value = true;
242-
};
243-
244240
} // end namespace llvm
245241

246242
#endif // LLVM_CLANG_AST_CHARUNITS_H

clang/include/clang/AST/DeclAccessPair.h

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -60,12 +60,4 @@ class DeclAccessPair {
6060
};
6161
}
6262

63-
// Take a moment to tell SmallVector that DeclAccessPair is POD.
64-
namespace llvm {
65-
template<typename> struct isPodLike;
66-
template<> struct isPodLike<clang::DeclAccessPair> {
67-
static const bool value = true;
68-
};
69-
}
70-
7163
#endif

clang/include/clang/AST/DeclarationName.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -861,9 +861,6 @@ struct DenseMapInfo<clang::DeclarationName> {
861861
}
862862
};
863863

864-
template <>
865-
struct isPodLike<clang::DeclarationName> { static const bool value = true; };
866-
867864
} // namespace llvm
868865

869866
#endif // LLVM_CLANG_AST_DECLARATIONNAME_H

clang/include/clang/AST/ExprObjC.h

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -255,12 +255,6 @@ struct ObjCDictionaryElement {
255255

256256
} // namespace clang
257257

258-
namespace llvm {
259-
260-
template <> struct isPodLike<clang::ObjCDictionaryElement> : std::true_type {};
261-
262-
} // namespace llvm
263-
264258
namespace clang {
265259

266260
/// Internal struct for storing Key/value pair.

clang/include/clang/AST/GlobalDecl.h

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -139,13 +139,6 @@ namespace llvm {
139139
}
140140
};
141141

142-
// GlobalDecl isn't *technically* a POD type. However, its copy constructor,
143-
// copy assignment operator, and destructor are all trivial.
144-
template <>
145-
struct isPodLike<clang::GlobalDecl> {
146-
static const bool value = true;
147-
};
148-
149142
} // namespace llvm
150143

151144
#endif // LLVM_CLANG_AST_GLOBALDECL_H

clang/include/clang/AST/Type.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -94,9 +94,6 @@ namespace llvm {
9494
enum { NumLowBitsAvailable = clang::TypeAlignmentInBits };
9595
};
9696

97-
template <>
98-
struct isPodLike<clang::QualType> { static const bool value = true; };
99-
10097
} // namespace llvm
10198

10299
namespace clang {

clang/include/clang/Analysis/ProgramPoint.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -777,9 +777,6 @@ static bool isEqual(const clang::ProgramPoint &L,
777777

778778
};
779779

780-
template <>
781-
struct isPodLike<clang::ProgramPoint> { static const bool value = true; };
782-
783780
} // end namespace llvm
784781

785782
#endif

clang/include/clang/Basic/IdentifierTable.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -938,9 +938,6 @@ struct DenseMapInfo<clang::Selector> {
938938
}
939939
};
940940

941-
template <>
942-
struct isPodLike<clang::Selector> { static const bool value = true; };
943-
944941
template<>
945942
struct PointerLikeTypeTraits<clang::Selector> {
946943
static const void *getAsVoidPointer(clang::Selector P) {

clang/include/clang/Basic/SourceLocation.h

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
namespace llvm {
2626

2727
template <typename T> struct DenseMapInfo;
28-
template <typename T> struct isPodLike;
2928

3029
} // namespace llvm
3130

@@ -457,11 +456,6 @@ namespace llvm {
457456
}
458457
};
459458

460-
template <>
461-
struct isPodLike<clang::SourceLocation> { static const bool value = true; };
462-
template <>
463-
struct isPodLike<clang::FileID> { static const bool value = true; };
464-
465459
// Teach SmallPtrSet how to handle SourceLocation.
466460
template<>
467461
struct PointerLikeTypeTraits<clang::SourceLocation> {

0 commit comments

Comments
 (0)