mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-07-23 14:25:07 +00:00
Correcting the ArrayRef test to not cause use-after-free bugs with initializer lists. Should also silence a -Wsign-compare warning accidentally introduced.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@229515 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -11,6 +11,7 @@
|
|||||||
#include "llvm/Support/Allocator.h"
|
#include "llvm/Support/Allocator.h"
|
||||||
#include "llvm/Support/raw_ostream.h"
|
#include "llvm/Support/raw_ostream.h"
|
||||||
#include "gtest/gtest.h"
|
#include "gtest/gtest.h"
|
||||||
|
#include <vector>
|
||||||
using namespace llvm;
|
using namespace llvm;
|
||||||
|
|
||||||
// Check that the ArrayRef-of-pointer converting constructor only allows adding
|
// Check that the ArrayRef-of-pointer converting constructor only allows adding
|
||||||
@@ -90,9 +91,9 @@ TEST(ArrayRefTest, ConstConvert) {
|
|||||||
a = ArrayRef<int *>(A);
|
a = ArrayRef<int *>(A);
|
||||||
}
|
}
|
||||||
|
|
||||||
static ArrayRef<int> ReturnTest12() { return {1, 2}; }
|
static std::vector<int> ReturnTest12() { return {1, 2}; }
|
||||||
static void ArgTest12(ArrayRef<int> A) {
|
static void ArgTest12(ArrayRef<int> A) {
|
||||||
EXPECT_EQ(2, A.size());
|
EXPECT_EQ(2U, A.size());
|
||||||
EXPECT_EQ(1, A[0]);
|
EXPECT_EQ(1, A[0]);
|
||||||
EXPECT_EQ(2, A[1]);
|
EXPECT_EQ(2, A[1]);
|
||||||
}
|
}
|
||||||
@@ -102,7 +103,8 @@ TEST(ArrayRefTest, InitializerList) {
|
|||||||
for (int i = 0; i < 5; ++i)
|
for (int i = 0; i < 5; ++i)
|
||||||
EXPECT_EQ(i, A[i]);
|
EXPECT_EQ(i, A[i]);
|
||||||
|
|
||||||
A = ReturnTest12();
|
std::vector<int> B = ReturnTest12();
|
||||||
|
A = B;
|
||||||
EXPECT_EQ(1, A[0]);
|
EXPECT_EQ(1, A[0]);
|
||||||
EXPECT_EQ(2, A[1]);
|
EXPECT_EQ(2, A[1]);
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user