r351701 - Replace llvm::isPodLike<...> by llvm::is_trivially_copyable<...>
Serge Guelton via cfe-commits
cfe-commits at lists.llvm.org
Sun Jan 20 13:19:56 PST 2019
Author: serge_sans_paille
Date: Sun Jan 20 13:19:56 2019
New Revision: 351701
URL: http://llvm.org/viewvc/llvm-project?rev=351701&view=rev
Log:
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
Modified:
cfe/trunk/include/clang/AST/BaseSubobject.h
cfe/trunk/include/clang/AST/CharUnits.h
cfe/trunk/include/clang/AST/DeclAccessPair.h
cfe/trunk/include/clang/AST/DeclarationName.h
cfe/trunk/include/clang/AST/ExprObjC.h
cfe/trunk/include/clang/AST/GlobalDecl.h
cfe/trunk/include/clang/AST/Type.h
cfe/trunk/include/clang/Analysis/ProgramPoint.h
cfe/trunk/include/clang/Basic/IdentifierTable.h
cfe/trunk/include/clang/Basic/SourceLocation.h
cfe/trunk/include/clang/Lex/Token.h
cfe/trunk/include/clang/Sema/CodeCompleteConsumer.h
cfe/trunk/include/clang/Sema/Ownership.h
cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/SVals.h
cfe/trunk/lib/AST/VTableBuilder.cpp
cfe/trunk/lib/Sema/SemaChecking.cpp
cfe/trunk/lib/StaticAnalyzer/Core/RegionStore.cpp
cfe/trunk/test/Analysis/llvm-conventions.cpp
cfe/trunk/tools/libclang/Indexing.cpp
Modified: cfe/trunk/include/clang/AST/BaseSubobject.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/BaseSubobject.h?rev=351701&r1=351700&r2=351701&view=diff
==============================================================================
--- cfe/trunk/include/clang/AST/BaseSubobject.h (original)
+++ cfe/trunk/include/clang/AST/BaseSubobject.h Sun Jan 20 13:19:56 2019
@@ -80,11 +80,6 @@ template<> struct DenseMapInfo<clang::Ba
}
};
-// 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
Modified: cfe/trunk/include/clang/AST/CharUnits.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/CharUnits.h?rev=351701&r1=351700&r2=351701&view=diff
==============================================================================
--- cfe/trunk/include/clang/AST/CharUnits.h (original)
+++ cfe/trunk/include/clang/AST/CharUnits.h Sun Jan 20 13:19:56 2019
@@ -237,10 +237,6 @@ template<> struct DenseMapInfo<clang::Ch
}
};
-template <> struct isPodLike<clang::CharUnits> {
- static const bool value = true;
-};
-
} // end namespace llvm
#endif // LLVM_CLANG_AST_CHARUNITS_H
Modified: cfe/trunk/include/clang/AST/DeclAccessPair.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/DeclAccessPair.h?rev=351701&r1=351700&r2=351701&view=diff
==============================================================================
--- cfe/trunk/include/clang/AST/DeclAccessPair.h (original)
+++ cfe/trunk/include/clang/AST/DeclAccessPair.h Sun Jan 20 13:19:56 2019
@@ -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
Modified: cfe/trunk/include/clang/AST/DeclarationName.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/DeclarationName.h?rev=351701&r1=351700&r2=351701&view=diff
==============================================================================
--- cfe/trunk/include/clang/AST/DeclarationName.h (original)
+++ cfe/trunk/include/clang/AST/DeclarationName.h Sun Jan 20 13:19:56 2019
@@ -861,9 +861,6 @@ struct DenseMapInfo<clang::DeclarationNa
}
};
-template <>
-struct isPodLike<clang::DeclarationName> { static const bool value = true; };
-
} // namespace llvm
#endif // LLVM_CLANG_AST_DECLARATIONNAME_H
Modified: cfe/trunk/include/clang/AST/ExprObjC.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/ExprObjC.h?rev=351701&r1=351700&r2=351701&view=diff
==============================================================================
--- cfe/trunk/include/clang/AST/ExprObjC.h (original)
+++ cfe/trunk/include/clang/AST/ExprObjC.h Sun Jan 20 13:19:56 2019
@@ -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.
Modified: cfe/trunk/include/clang/AST/GlobalDecl.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/GlobalDecl.h?rev=351701&r1=351700&r2=351701&view=diff
==============================================================================
--- cfe/trunk/include/clang/AST/GlobalDecl.h (original)
+++ cfe/trunk/include/clang/AST/GlobalDecl.h Sun Jan 20 13:19:56 2019
@@ -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
Modified: cfe/trunk/include/clang/AST/Type.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Type.h?rev=351701&r1=351700&r2=351701&view=diff
==============================================================================
--- cfe/trunk/include/clang/AST/Type.h (original)
+++ cfe/trunk/include/clang/AST/Type.h Sun Jan 20 13:19:56 2019
@@ -94,9 +94,6 @@ namespace llvm {
enum { NumLowBitsAvailable = clang::TypeAlignmentInBits };
};
- template <>
- struct isPodLike<clang::QualType> { static const bool value = true; };
-
} // namespace llvm
namespace clang {
Modified: cfe/trunk/include/clang/Analysis/ProgramPoint.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Analysis/ProgramPoint.h?rev=351701&r1=351700&r2=351701&view=diff
==============================================================================
--- cfe/trunk/include/clang/Analysis/ProgramPoint.h (original)
+++ cfe/trunk/include/clang/Analysis/ProgramPoint.h Sun Jan 20 13:19:56 2019
@@ -777,9 +777,6 @@ static bool isEqual(const clang::Program
};
-template <>
-struct isPodLike<clang::ProgramPoint> { static const bool value = true; };
-
} // end namespace llvm
#endif
Modified: cfe/trunk/include/clang/Basic/IdentifierTable.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/IdentifierTable.h?rev=351701&r1=351700&r2=351701&view=diff
==============================================================================
--- cfe/trunk/include/clang/Basic/IdentifierTable.h (original)
+++ cfe/trunk/include/clang/Basic/IdentifierTable.h Sun Jan 20 13:19:56 2019
@@ -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) {
Modified: cfe/trunk/include/clang/Basic/SourceLocation.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/SourceLocation.h?rev=351701&r1=351700&r2=351701&view=diff
==============================================================================
--- cfe/trunk/include/clang/Basic/SourceLocation.h (original)
+++ cfe/trunk/include/clang/Basic/SourceLocation.h Sun Jan 20 13:19:56 2019
@@ -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> {
Modified: cfe/trunk/include/clang/Lex/Token.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Lex/Token.h?rev=351701&r1=351700&r2=351701&view=diff
==============================================================================
--- cfe/trunk/include/clang/Lex/Token.h (original)
+++ cfe/trunk/include/clang/Lex/Token.h Sun Jan 20 13:19:56 2019
@@ -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
Modified: cfe/trunk/include/clang/Sema/CodeCompleteConsumer.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/CodeCompleteConsumer.h?rev=351701&r1=351700&r2=351701&view=diff
==============================================================================
--- cfe/trunk/include/clang/Sema/CodeCompleteConsumer.h (original)
+++ cfe/trunk/include/clang/Sema/CodeCompleteConsumer.h Sun Jan 20 13:19:56 2019
@@ -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.
Modified: cfe/trunk/include/clang/Sema/Ownership.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Ownership.h?rev=351701&r1=351700&r2=351701&view=diff
==============================================================================
--- cfe/trunk/include/clang/Sema/Ownership.h (original)
+++ cfe/trunk/include/clang/Sema/Ownership.h Sun Jan 20 13:19:56 2019
@@ -128,9 +128,6 @@ namespace llvm {
}
};
- template <class T>
- struct isPodLike<clang::OpaquePtr<T>> { static const bool value = true; };
-
} // namespace llvm
namespace clang {
Modified: cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/SVals.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/SVals.h?rev=351701&r1=351700&r2=351701&view=diff
==============================================================================
--- cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/SVals.h (original)
+++ cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/SVals.h Sun Jan 20 13:19:56 2019
@@ -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
Modified: cfe/trunk/lib/AST/VTableBuilder.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/VTableBuilder.cpp?rev=351701&r1=351700&r2=351701&view=diff
==============================================================================
--- cfe/trunk/lib/AST/VTableBuilder.cpp (original)
+++ cfe/trunk/lib/AST/VTableBuilder.cpp Sun Jan 20 13:19:56 2019
@@ -846,6 +846,8 @@ private:
: BaseOffset(CharUnits::Zero()),
BaseOffsetInLayoutClass(CharUnits::Zero()),
VTableIndex(0) { }
+
+ MethodInfo(MethodInfo const&) = default;
};
typedef llvm::DenseMap<const CXXMethodDecl *, MethodInfo> MethodInfoMapTy;
Modified: cfe/trunk/lib/Sema/SemaChecking.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaChecking.cpp?rev=351701&r1=351700&r2=351701&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaChecking.cpp (original)
+++ cfe/trunk/lib/Sema/SemaChecking.cpp Sun Jan 20 13:19:56 2019
@@ -11662,12 +11662,12 @@ class SequenceChecker : public Evaluated
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)); }
Modified: cfe/trunk/lib/StaticAnalyzer/Core/RegionStore.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Core/RegionStore.cpp?rev=351701&r1=351700&r2=351701&view=diff
==============================================================================
--- cfe/trunk/lib/StaticAnalyzer/Core/RegionStore.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Core/RegionStore.cpp Sun Jan 20 13:19:56 2019
@@ -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
Modified: cfe/trunk/test/Analysis/llvm-conventions.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/llvm-conventions.cpp?rev=351701&r1=351700&r2=351701&view=diff
==============================================================================
--- cfe/trunk/test/Analysis/llvm-conventions.cpp (original)
+++ cfe/trunk/test/Analysis/llvm-conventions.cpp Sun Jan 20 13:19:56 2019
@@ -152,8 +152,6 @@ inline bool operator>(StringRef LHS, Str
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
Modified: cfe/trunk/tools/libclang/Indexing.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/libclang/Indexing.cpp?rev=351701&r1=351700&r2=351701&view=diff
==============================================================================
--- cfe/trunk/tools/libclang/Indexing.cpp (original)
+++ cfe/trunk/tools/libclang/Indexing.cpp Sun Jan 20 13:19:56 2019
@@ -93,9 +93,6 @@ typedef llvm::DenseSet<PPRegion> PPRegio
} // end anonymous namespace
namespace llvm {
- template <> struct isPodLike<PPRegion> {
- static const bool value = true;
- };
template <>
struct DenseMapInfo<PPRegion> {
More information about the cfe-commits
mailing list