summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJustin Bogner <mail@justinbogner.com>2015-12-07 20:04:57 +0000
committerJustin Bogner <mail@justinbogner.com>2015-12-07 20:04:57 +0000
commitcbc12262e3219cdcfdedd11b2321280cb520a3bf (patch)
tree2fc469924710636dfb48085395420ae9f8082bb3
parent9ed1baed6fa40c2c25d2748e81359c54a0e00dcf (diff)
downloadbcm5719-llvm-cbc12262e3219cdcfdedd11b2321280cb520a3bf.tar.gz
bcm5719-llvm-cbc12262e3219cdcfdedd11b2321280cb520a3bf.zip
AST: defer to TypeLoc::copy in TypeLoc::initializeFullCopy
If we're initializing a TypeLoc from one that's been allocated with different alignment, memcpy will get the padding wrong. The `copy` method already checks and handles this case, so we should just defer to it. This also drops the `const` off of the `initializeFullCopy` declarations, since it isn't even remotely true (and the compiler notices when we try to call copy() instead of tricking it with memcpy). Fixes llvm.org/pr23516. llvm-svn: 254935
-rw-r--r--clang/include/clang/AST/TypeLoc.h9
1 files changed, 4 insertions, 5 deletions
diff --git a/clang/include/clang/AST/TypeLoc.h b/clang/include/clang/AST/TypeLoc.h
index 674fffb8fa2..26feda5d766 100644
--- a/clang/include/clang/AST/TypeLoc.h
+++ b/clang/include/clang/AST/TypeLoc.h
@@ -170,19 +170,18 @@ public:
/// \brief Initializes this by copying its information from another
/// TypeLoc of the same type.
- void initializeFullCopy(TypeLoc Other) const {
+ void initializeFullCopy(TypeLoc Other) {
assert(getType() == Other.getType());
- size_t Size = getFullDataSize();
- memcpy(getOpaqueData(), Other.getOpaqueData(), Size);
+ copy(Other);
}
/// \brief Initializes this by copying its information from another
/// TypeLoc of the same type. The given size must be the full data
/// size.
- void initializeFullCopy(TypeLoc Other, unsigned Size) const {
+ void initializeFullCopy(TypeLoc Other, unsigned Size) {
assert(getType() == Other.getType());
assert(getFullDataSize() == Size);
- memcpy(getOpaqueData(), Other.getOpaqueData(), Size);
+ copy(Other);
}
/// Copies the other type loc into this one.
OpenPOWER on IntegriCloud