diff options
Diffstat (limited to 'unittests/Support')
-rw-r--r-- | unittests/Support/AllocatorTest.cpp | 2 | ||||
-rw-r--r-- | unittests/Support/CommandLineTest.cpp | 13 | ||||
-rw-r--r-- | unittests/Support/ErrorOrTest.cpp | 4 | ||||
-rw-r--r-- | unittests/Support/Path.cpp | 2 | ||||
-rw-r--r-- | unittests/Support/StreamingMemoryObject.cpp | 9 |
5 files changed, 13 insertions, 17 deletions
diff --git a/unittests/Support/AllocatorTest.cpp b/unittests/Support/AllocatorTest.cpp index 38c7fcba8afd..4b544641e9bf 100644 --- a/unittests/Support/AllocatorTest.cpp +++ b/unittests/Support/AllocatorTest.cpp @@ -129,7 +129,7 @@ TEST(AllocatorTest, TestAlignmentPastSlab) { // Aligning the current slab pointer is likely to move it past the end of the // slab, which would confuse any unsigned comparisons with the difference of - // the the end pointer and the aligned pointer. + // the end pointer and the aligned pointer. Alloc.Allocate(1024, 8192); EXPECT_EQ(2U, Alloc.GetNumSlabs()); diff --git a/unittests/Support/CommandLineTest.cpp b/unittests/Support/CommandLineTest.cpp index 328c4b7fcf30..e0fbf5b09e57 100644 --- a/unittests/Support/CommandLineTest.cpp +++ b/unittests/Support/CommandLineTest.cpp @@ -10,6 +10,7 @@ #include "llvm/ADT/STLExtras.h" #include "llvm/Config/config.h" #include "llvm/Support/CommandLine.h" +#include "llvm/Support/StringSaver.h" #include "gtest/gtest.h" #include <stdlib.h> #include <string> @@ -146,26 +147,20 @@ TEST(CommandLineTest, UseOptionCategory) { "Category."; } -class StrDupSaver : public cl::StringSaver { - const char *SaveString(const char *Str) override { - return strdup(Str); - } -}; - -typedef void ParserFunction(StringRef Source, llvm::cl::StringSaver &Saver, +typedef void ParserFunction(StringRef Source, StringSaver &Saver, SmallVectorImpl<const char *> &NewArgv, bool MarkEOLs); void testCommandLineTokenizer(ParserFunction *parse, const char *Input, const char *const Output[], size_t OutputSize) { SmallVector<const char *, 0> Actual; - StrDupSaver Saver; + BumpPtrAllocator A; + BumpPtrStringSaver Saver(A); parse(Input, Saver, Actual, /*MarkEOLs=*/false); EXPECT_EQ(OutputSize, Actual.size()); for (unsigned I = 0, E = Actual.size(); I != E; ++I) { if (I < OutputSize) EXPECT_STREQ(Output[I], Actual[I]); - free(const_cast<char *>(Actual[I])); } } diff --git a/unittests/Support/ErrorOrTest.cpp b/unittests/Support/ErrorOrTest.cpp index 5e8d442a7039..73d0e3f2bb71 100644 --- a/unittests/Support/ErrorOrTest.cpp +++ b/unittests/Support/ErrorOrTest.cpp @@ -67,8 +67,8 @@ TEST(ErrorOr, Covariant) { } TEST(ErrorOr, Comparison) { - ErrorOr<int> x(std::errc::no_such_file_or_directory); - EXPECT_EQ(x, std::errc::no_such_file_or_directory); + ErrorOr<int> x(errc::no_such_file_or_directory); + EXPECT_EQ(x, errc::no_such_file_or_directory); } // ErrorOr<int*> x(nullptr); diff --git a/unittests/Support/Path.cpp b/unittests/Support/Path.cpp index 262d27260ce4..210b3a04cb21 100644 --- a/unittests/Support/Path.cpp +++ b/unittests/Support/Path.cpp @@ -16,7 +16,7 @@ #include "gtest/gtest.h" #ifdef LLVM_ON_WIN32 -#include <Windows.h> +#include <windows.h> #include <winerror.h> #endif diff --git a/unittests/Support/StreamingMemoryObject.cpp b/unittests/Support/StreamingMemoryObject.cpp index c043efbb5e47..e86aa9cae51e 100644 --- a/unittests/Support/StreamingMemoryObject.cpp +++ b/unittests/Support/StreamingMemoryObject.cpp @@ -7,6 +7,7 @@ // //===----------------------------------------------------------------------===// +#include "llvm/ADT/STLExtras.h" #include "llvm/Support/StreamingMemoryObject.h" #include "gtest/gtest.h" #include <string.h> @@ -23,14 +24,14 @@ class NullDataStreamer : public DataStreamer { } TEST(StreamingMemoryObject, Test) { - auto *DS = new NullDataStreamer(); - StreamingMemoryObject O(DS); + auto DS = make_unique<NullDataStreamer>(); + StreamingMemoryObject O(std::move(DS)); EXPECT_TRUE(O.isValidAddress(32 * 1024)); } TEST(StreamingMemoryObject, TestSetKnownObjectSize) { - auto *DS = new NullDataStreamer(); - StreamingMemoryObject O(DS); + auto DS = make_unique<NullDataStreamer>(); + StreamingMemoryObject O(std::move(DS)); uint8_t Buf[32]; EXPECT_EQ((uint64_t) 16, O.readBytes(Buf, 16, 0)); O.setKnownObjectSize(24); |