]> granicus.if.org Git - clang/commit
Replace llvm::isPodLike<...> by llvm::is_trivially_copyable<...>
authorSerge Guelton <sguelton@quarkslab.com>
Sun, 20 Jan 2019 21:19:56 +0000 (21:19 +0000)
committerSerge Guelton <sguelton@quarkslab.com>
Sun, 20 Jan 2019 21:19:56 +0000 (21:19 +0000)
commit1b91f2b9fb87c5e0bb3ca70ae7fe3e572fb203d1
tree11ef190b8bdee9830c33b337c10c64427b54c305
parente73d9ee9b3603e7a3843d38e1b599eb45d8b69f3
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
19 files changed:
include/clang/AST/BaseSubobject.h
include/clang/AST/CharUnits.h
include/clang/AST/DeclAccessPair.h
include/clang/AST/DeclarationName.h
include/clang/AST/ExprObjC.h
include/clang/AST/GlobalDecl.h
include/clang/AST/Type.h
include/clang/Analysis/ProgramPoint.h
include/clang/Basic/IdentifierTable.h
include/clang/Basic/SourceLocation.h
include/clang/Lex/Token.h
include/clang/Sema/CodeCompleteConsumer.h
include/clang/Sema/Ownership.h
include/clang/StaticAnalyzer/Core/PathSensitive/SVals.h
lib/AST/VTableBuilder.cpp
lib/Sema/SemaChecking.cpp
lib/StaticAnalyzer/Core/RegionStore.cpp
test/Analysis/llvm-conventions.cpp
tools/libclang/Indexing.cpp