diff options
author | Serge Guelton <sguelton@quarkslab.com> | 2019-01-20 21:19:56 +0000 |
---|---|---|
committer | Serge Guelton <sguelton@quarkslab.com> | 2019-01-20 21:19:56 +0000 |
commit | 1b91f2b9fb87c5e0bb3ca70ae7fe3e572fb203d1 (patch) | |
tree | 11ef190b8bdee9830c33b337c10c64427b54c305 /include | |
parent | e73d9ee9b3603e7a3843d38e1b599eb45d8b69f3 (diff) | |
download | clang-1b91f2b9fb87c5e0bb3ca70ae7fe3e572fb203d1.tar.gz |
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
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@351701 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include')
-rw-r--r-- | include/clang/AST/BaseSubobject.h | 5 | ||||
-rw-r--r-- | include/clang/AST/CharUnits.h | 4 | ||||
-rw-r--r-- | include/clang/AST/DeclAccessPair.h | 8 | ||||
-rw-r--r-- | include/clang/AST/DeclarationName.h | 3 | ||||
-rw-r--r-- | include/clang/AST/ExprObjC.h | 6 | ||||
-rw-r--r-- | include/clang/AST/GlobalDecl.h | 7 | ||||
-rw-r--r-- | include/clang/AST/Type.h | 3 | ||||
-rw-r--r-- | include/clang/Analysis/ProgramPoint.h | 3 | ||||
-rw-r--r-- | include/clang/Basic/IdentifierTable.h | 3 | ||||
-rw-r--r-- | include/clang/Basic/SourceLocation.h | 6 | ||||
-rw-r--r-- | include/clang/Lex/Token.h | 5 | ||||
-rw-r--r-- | include/clang/Sema/CodeCompleteConsumer.h | 8 | ||||
-rw-r--r-- | include/clang/Sema/Ownership.h | 3 | ||||
-rw-r--r-- | include/clang/StaticAnalyzer/Core/PathSensitive/SVals.h | 9 |
14 files changed, 0 insertions, 73 deletions
diff --git a/include/clang/AST/BaseSubobject.h b/include/clang/AST/BaseSubobject.h index 151678fbd3..15600f02fc 100644 --- a/include/clang/AST/BaseSubobject.h +++ b/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/include/clang/AST/CharUnits.h b/include/clang/AST/CharUnits.h index b029a1a3ab..37f489c770 100644 --- a/include/clang/AST/CharUnits.h +++ b/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/include/clang/AST/DeclAccessPair.h b/include/clang/AST/DeclAccessPair.h index 9b33379341..805342c291 100644 --- a/include/clang/AST/DeclAccessPair.h +++ b/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/include/clang/AST/DeclarationName.h b/include/clang/AST/DeclarationName.h index 22f6bf7f44..e5d34399f8 100644 --- a/include/clang/AST/DeclarationName.h +++ b/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/include/clang/AST/ExprObjC.h b/include/clang/AST/ExprObjC.h index b51935d0d7..debe5acebf 100644 --- a/include/clang/AST/ExprObjC.h +++ b/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/include/clang/AST/GlobalDecl.h b/include/clang/AST/GlobalDecl.h index d6d8b11062..a5937c239e 100644 --- a/include/clang/AST/GlobalDecl.h +++ b/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/include/clang/AST/Type.h b/include/clang/AST/Type.h index 58e2f60fe7..fbf91d3088 100644 --- a/include/clang/AST/Type.h +++ b/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/include/clang/Analysis/ProgramPoint.h b/include/clang/Analysis/ProgramPoint.h index 0f869233af..623f5dc707 100644 --- a/include/clang/Analysis/ProgramPoint.h +++ b/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/include/clang/Basic/IdentifierTable.h b/include/clang/Basic/IdentifierTable.h index c5ad0e5830..465486ede7 100644 --- a/include/clang/Basic/IdentifierTable.h +++ b/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/include/clang/Basic/SourceLocation.h b/include/clang/Basic/SourceLocation.h index 2b7f967d05..ceebdf4822 100644 --- a/include/clang/Basic/SourceLocation.h +++ b/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/include/clang/Lex/Token.h b/include/clang/Lex/Token.h index 83f4433709..20483e393c 100644 --- a/include/clang/Lex/Token.h +++ b/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/include/clang/Sema/CodeCompleteConsumer.h b/include/clang/Sema/CodeCompleteConsumer.h index 005d62ad00..5c14fb8773 100644 --- a/include/clang/Sema/CodeCompleteConsumer.h +++ b/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/include/clang/Sema/Ownership.h b/include/clang/Sema/Ownership.h index 8a82c1382d..f395282c0c 100644 --- a/include/clang/Sema/Ownership.h +++ b/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/include/clang/StaticAnalyzer/Core/PathSensitive/SVals.h b/include/clang/StaticAnalyzer/Core/PathSensitive/SVals.h index d956133d03..e859936621 100644 --- a/include/clang/StaticAnalyzer/Core/PathSensitive/SVals.h +++ b/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 |