]> granicus.if.org Git - llvm/commit
Merging r310475:
authorTom Stellard <tstellar@redhat.com>
Wed, 15 Nov 2017 20:48:55 +0000 (20:48 +0000)
committerTom Stellard <tstellar@redhat.com>
Wed, 15 Nov 2017 20:48:55 +0000 (20:48 +0000)
commitf8579b1caadfcbc50a97ab1e64789270d68fe922
treece7bb6bf6171c1ccdb33ae734b42ef56b51c3341
parent165d008209e92bb78a094110ba202e3f2da289b1
Merging r310475:

------------------------------------------------------------------------
r310475 | belleyb | 2017-08-09 06:47:01 -0700 (Wed, 09 Aug 2017) | 28 lines

[Support] PR33388 - Fix formatv_object move constructor

formatv_object currently uses the implicitly defined move constructor,
but it is buggy. In typical use-cases, the problem doesn't show-up
because all calls to the move constructor are elided. Thus, the buggy
constructors are never invoked.

The issue especially shows-up when code is compiled using the
-fno-elide-constructors compiler flag. For instance, this is useful when
attempting to collect accurate code coverage statistics.

The exact issue is the following:

The Parameters data member is correctly moved, thus making the
parameters occupy a new memory location in the target
object. Unfortunately, the default copying of the Adapters blindly
copies the vector of pointers, leaving each of these pointers
referencing the parameters in the original object instead of the copied
one. These pointers quickly become dangling when the original object is
deleted. This quickly leads to crashes.

The solution is to update the Adapters pointers when performing a move.
The copy constructor isn't useful for format objects and can thus be
deleted.

This resolves PR33388.

Differential Revision: https://reviews.llvm.org/D34463
------------------------------------------------------------------------

git-svn-id: https://llvm.org/svn/llvm-project/llvm/branches/release_50@318333 91177308-0d34-0410-b5e6-96231b3b80d8
include/llvm/Support/FormatVariadic.h
unittests/Support/FormatVariadicTest.cpp