Skip to content

Commit

Permalink
[ValueTracking] Avoid undefined behavior in unittest by not making a …
Browse files Browse the repository at this point in the history
…named ArrayRef from a std::initializer_list

One of the ValueTracking unittests creates a named ArrayRef initialized by a std::initializer_list. The underlying array for an std::initializer_list is only guaranteed to have a lifetime as long as the initializer_list object itself. So this can leave the ArrayRef pointing at an array that no long exists.

This fixes this to just create an explicit array instead of an ArrayRef.

Differential Revision: https://reviews.llvm.org/D32089

llvm-svn: 300354
  • Loading branch information
topperc committed Apr 14, 2017
1 parent c22c7b1 commit 8580cd4
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion llvm/unittests/Analysis/ValueTrackingTest.cpp
Expand Up @@ -219,7 +219,7 @@ TEST(ValueTracking, GuaranteedToTransferExecutionToSuccessor) {
assert(F && "Bad assembly?");

auto &BB = F->getEntryBlock();
ArrayRef<bool> ExpectedAnswers = {
bool ExpectedAnswers[] = {
true, // call void @nounwind_readonly(i32* %p)
true, // call void @nounwind_argmemonly(i32* %p)
false, // call void @throws_but_readonly(i32* %p)
Expand Down

0 comments on commit 8580cd4

Please sign in to comment.