summaryrefslogtreecommitdiff
path: root/unittests/Support
diff options
context:
space:
mode:
authorDimitry Andric <dim@FreeBSD.org>2017-06-10 13:44:06 +0000
committerDimitry Andric <dim@FreeBSD.org>2017-06-10 13:44:06 +0000
commit7ab83427af0f77b59941ceba41d509d7d097b065 (patch)
treecc41c05b1db454e3d802f34df75e636ee922ad87 /unittests/Support
parentd288ef4c1788d3a951a7558c68312c2d320612b1 (diff)
downloadsrc-test2-fca26745f126c5961a3e44fc7e447936f5e935f8.tar.gz
src-test2-fca26745f126c5961a3e44fc7e447936f5e935f8.zip
Diffstat (limited to 'unittests/Support')
-rw-r--r--unittests/Support/ARMAttributeParser.cpp2
-rw-r--r--unittests/Support/BinaryStreamTest.cpp9
-rw-r--r--unittests/Support/CMakeLists.txt6
-rw-r--r--unittests/Support/CommandLineTest.cpp4
-rw-r--r--unittests/Support/CompressionTest.cpp2
-rw-r--r--unittests/Support/CrashRecoveryTest.cpp2
-rw-r--r--unittests/Support/DataExtractorTest.cpp2
-rw-r--r--unittests/Support/DwarfTest.cpp141
-rw-r--r--unittests/Support/DynamicLibrary/CMakeLists.txt25
-rw-r--r--unittests/Support/DynamicLibrary/DynamicLibraryTest.cpp53
-rw-r--r--unittests/Support/DynamicLibrary/PipSqueak.cxx34
-rw-r--r--unittests/Support/DynamicLibrary/PipSqueak.h13
-rw-r--r--unittests/Support/EndianStreamTest.cpp2
-rw-r--r--unittests/Support/FileOutputBufferTest.cpp2
-rw-r--r--unittests/Support/FormatVariadicTest.cpp2
-rw-r--r--unittests/Support/LEB128Test.cpp4
-rw-r--r--unittests/Support/MD5Test.cpp2
-rw-r--r--unittests/Support/MathExtrasTest.cpp2
-rw-r--r--unittests/Support/MemoryBufferTest.cpp2
-rw-r--r--unittests/Support/MemoryTest.cpp2
-rw-r--r--unittests/Support/Path.cpp83
-rw-r--r--unittests/Support/ProgramTest.cpp4
-rw-r--r--unittests/Support/SpecialCaseListTest.cpp2
-rw-r--r--unittests/Support/SwapByteOrderTest.cpp2
-rw-r--r--unittests/Support/TarWriterTest.cpp2
-rw-r--r--unittests/Support/TargetParserTest.cpp2
-rw-r--r--unittests/Support/TrigramIndexTest.cpp2
-rw-r--r--unittests/Support/YAMLIOTest.cpp1
-rw-r--r--unittests/Support/YAMLParserTest.cpp2
-rw-r--r--unittests/Support/formatted_raw_ostream_test.cpp2
-rw-r--r--unittests/Support/raw_ostream_test.cpp2
-rw-r--r--unittests/Support/raw_pwrite_stream_test.cpp2
-rw-r--r--unittests/Support/raw_sha1_ostream_test.cpp2
33 files changed, 127 insertions, 292 deletions
diff --git a/unittests/Support/ARMAttributeParser.cpp b/unittests/Support/ARMAttributeParser.cpp
index c2df6537ff63..1df03db6d07f 100644
--- a/unittests/Support/ARMAttributeParser.cpp
+++ b/unittests/Support/ARMAttributeParser.cpp
@@ -1,5 +1,5 @@
-#include "llvm/Support/ARMBuildAttributes.h"
#include "llvm/Support/ARMAttributeParser.h"
+#include "llvm/Support/ARMBuildAttributes.h"
#include "llvm/Support/LEB128.h"
#include "gtest/gtest.h"
#include <string>
diff --git a/unittests/Support/BinaryStreamTest.cpp b/unittests/Support/BinaryStreamTest.cpp
index 1ce74cbb722b..795c18902a9b 100644
--- a/unittests/Support/BinaryStreamTest.cpp
+++ b/unittests/Support/BinaryStreamTest.cpp
@@ -416,9 +416,7 @@ TEST_F(BinaryStreamTest, VarStreamArray) {
struct StringExtractor {
public:
- typedef uint32_t &ContextType;
- static Error extract(BinaryStreamRef Stream, uint32_t &Len, StringRef &Item,
- uint32_t &Index) {
+ Error operator()(BinaryStreamRef Stream, uint32_t &Len, StringRef &Item) {
if (Index == 0)
Len = strlen("1. Test");
else if (Index == 1)
@@ -435,11 +433,12 @@ TEST_F(BinaryStreamTest, VarStreamArray) {
++Index;
return Error::success();
}
+
+ uint32_t Index = 0;
};
for (auto &Stream : Streams) {
- uint32_t Context = 0;
- VarStreamArray<StringRef, StringExtractor> Array(*Stream.Input, Context);
+ VarStreamArray<StringRef, StringExtractor> Array(*Stream.Input);
auto Iter = Array.begin();
ASSERT_EQ("1. Test", *Iter++);
ASSERT_EQ("2. Longer Test", *Iter++);
diff --git a/unittests/Support/CMakeLists.txt b/unittests/Support/CMakeLists.txt
index e7f2f515d76a..098dba83197b 100644
--- a/unittests/Support/CMakeLists.txt
+++ b/unittests/Support/CMakeLists.txt
@@ -19,7 +19,6 @@ add_llvm_unittest(SupportTests
ConvertUTFTest.cpp
DataExtractorTest.cpp
DebugTest.cpp
- DwarfTest.cpp
EndianStreamTest.cpp
EndianTest.cpp
ErrorOrTest.cpp
@@ -67,6 +66,11 @@ add_llvm_unittest(SupportTests
xxhashTest.cpp
)
+# Disable all warning for AlignOfTest.cpp,
+# as it does things intentionally, and there is no reliable way of
+# disabling all warnings for all the compilers by using pragmas.
+set_source_files_properties(AlignOfTest.cpp PROPERTIES COMPILE_FLAGS -w)
+
# ManagedStatic.cpp uses <pthread>.
target_link_libraries(SupportTests ${LLVM_PTHREAD_LIB})
diff --git a/unittests/Support/CommandLineTest.cpp b/unittests/Support/CommandLineTest.cpp
index 33573c4e6960..7fdd42b4feca 100644
--- a/unittests/Support/CommandLineTest.cpp
+++ b/unittests/Support/CommandLineTest.cpp
@@ -7,10 +7,10 @@
//
//===----------------------------------------------------------------------===//
-#include "llvm/ADT/SmallString.h"
+#include "llvm/Support/CommandLine.h"
#include "llvm/ADT/STLExtras.h"
+#include "llvm/ADT/SmallString.h"
#include "llvm/Config/config.h"
-#include "llvm/Support/CommandLine.h"
#include "llvm/Support/FileSystem.h"
#include "llvm/Support/Path.h"
#include "llvm/Support/StringSaver.h"
diff --git a/unittests/Support/CompressionTest.cpp b/unittests/Support/CompressionTest.cpp
index 18a6175460d3..505714bd2da5 100644
--- a/unittests/Support/CompressionTest.cpp
+++ b/unittests/Support/CompressionTest.cpp
@@ -12,10 +12,10 @@
//===----------------------------------------------------------------------===//
#include "llvm/Support/Compression.h"
-#include "llvm/Support/Error.h"
#include "llvm/ADT/SmallString.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/Config/config.h"
+#include "llvm/Support/Error.h"
#include "gtest/gtest.h"
using namespace llvm;
diff --git a/unittests/Support/CrashRecoveryTest.cpp b/unittests/Support/CrashRecoveryTest.cpp
index e9ffd1f8871f..3f13693632db 100644
--- a/unittests/Support/CrashRecoveryTest.cpp
+++ b/unittests/Support/CrashRecoveryTest.cpp
@@ -7,8 +7,8 @@
//
//===----------------------------------------------------------------------===//
-#include "llvm/Support/CrashRecoveryContext.h"
#include "llvm/Support/Compiler.h"
+#include "llvm/Support/CrashRecoveryContext.h"
#include "gtest/gtest.h"
#ifdef LLVM_ON_WIN32
diff --git a/unittests/Support/DataExtractorTest.cpp b/unittests/Support/DataExtractorTest.cpp
index 81de983d2265..8b645524ec6c 100644
--- a/unittests/Support/DataExtractorTest.cpp
+++ b/unittests/Support/DataExtractorTest.cpp
@@ -7,8 +7,8 @@
//
//===----------------------------------------------------------------------===//
-#include "gtest/gtest.h"
#include "llvm/Support/DataExtractor.h"
+#include "gtest/gtest.h"
using namespace llvm;
namespace {
diff --git a/unittests/Support/DwarfTest.cpp b/unittests/Support/DwarfTest.cpp
deleted file mode 100644
index 148ea2736e15..000000000000
--- a/unittests/Support/DwarfTest.cpp
+++ /dev/null
@@ -1,141 +0,0 @@
-//===- unittest/Support/DwarfTest.cpp - Dwarf support tests ---------------===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-
-#include "llvm/Support/Dwarf.h"
-#include "gtest/gtest.h"
-
-using namespace llvm;
-using namespace llvm::dwarf;
-
-namespace {
-
-TEST(DwarfTest, TagStringOnInvalid) {
- // This is invalid, so it shouldn't be stringified.
- EXPECT_EQ(StringRef(), TagString(DW_TAG_invalid));
-
- // These aren't really tags: they describe ranges within tags. They
- // shouldn't be stringified either.
- EXPECT_EQ(StringRef(), TagString(DW_TAG_lo_user));
- EXPECT_EQ(StringRef(), TagString(DW_TAG_hi_user));
- EXPECT_EQ(StringRef(), TagString(DW_TAG_user_base));
-}
-
-TEST(DwarfTest, getTag) {
- // A couple of valid tags.
- EXPECT_EQ(DW_TAG_array_type, getTag("DW_TAG_array_type"));
- EXPECT_EQ(DW_TAG_module, getTag("DW_TAG_module"));
-
- // Invalid tags.
- EXPECT_EQ(DW_TAG_invalid, getTag("DW_TAG_invalid"));
- EXPECT_EQ(DW_TAG_invalid, getTag("DW_TAG_madeuptag"));
- EXPECT_EQ(DW_TAG_invalid, getTag("something else"));
-
- // Tag range markers should not be recognized.
- EXPECT_EQ(DW_TAG_invalid, getTag("DW_TAG_lo_user"));
- EXPECT_EQ(DW_TAG_invalid, getTag("DW_TAG_hi_user"));
- EXPECT_EQ(DW_TAG_invalid, getTag("DW_TAG_user_base"));
-}
-
-TEST(DwarfTest, getOperationEncoding) {
- // Some valid ops.
- EXPECT_EQ(DW_OP_deref, getOperationEncoding("DW_OP_deref"));
- EXPECT_EQ(DW_OP_bit_piece, getOperationEncoding("DW_OP_bit_piece"));
-
- // Invalid ops.
- EXPECT_EQ(0u, getOperationEncoding("DW_OP_otherthings"));
- EXPECT_EQ(0u, getOperationEncoding("other"));
-
- // Markers shouldn't be recognized.
- EXPECT_EQ(0u, getOperationEncoding("DW_OP_lo_user"));
- EXPECT_EQ(0u, getOperationEncoding("DW_OP_hi_user"));
-}
-
-TEST(DwarfTest, LanguageStringOnInvalid) {
- // This is invalid, so it shouldn't be stringified.
- EXPECT_EQ(StringRef(), LanguageString(0));
-
- // These aren't really tags: they describe ranges within tags. They
- // shouldn't be stringified either.
- EXPECT_EQ(StringRef(), LanguageString(DW_LANG_lo_user));
- EXPECT_EQ(StringRef(), LanguageString(DW_LANG_hi_user));
-}
-
-TEST(DwarfTest, getLanguage) {
- // A couple of valid languages.
- EXPECT_EQ(DW_LANG_C89, getLanguage("DW_LANG_C89"));
- EXPECT_EQ(DW_LANG_C_plus_plus_11, getLanguage("DW_LANG_C_plus_plus_11"));
- EXPECT_EQ(DW_LANG_OCaml, getLanguage("DW_LANG_OCaml"));
- EXPECT_EQ(DW_LANG_Mips_Assembler, getLanguage("DW_LANG_Mips_Assembler"));
-
- // Invalid languages.
- EXPECT_EQ(0u, getLanguage("DW_LANG_invalid"));
- EXPECT_EQ(0u, getLanguage("DW_TAG_array_type"));
- EXPECT_EQ(0u, getLanguage("something else"));
-
- // Language range markers should not be recognized.
- EXPECT_EQ(0u, getLanguage("DW_LANG_lo_user"));
- EXPECT_EQ(0u, getLanguage("DW_LANG_hi_user"));
-}
-
-TEST(DwarfTest, AttributeEncodingStringOnInvalid) {
- // This is invalid, so it shouldn't be stringified.
- EXPECT_EQ(StringRef(), AttributeEncodingString(0));
-
- // These aren't really tags: they describe ranges within tags. They
- // shouldn't be stringified either.
- EXPECT_EQ(StringRef(), AttributeEncodingString(DW_ATE_lo_user));
- EXPECT_EQ(StringRef(), AttributeEncodingString(DW_ATE_hi_user));
-}
-
-TEST(DwarfTest, getAttributeEncoding) {
- // A couple of valid languages.
- EXPECT_EQ(DW_ATE_boolean, getAttributeEncoding("DW_ATE_boolean"));
- EXPECT_EQ(DW_ATE_imaginary_float,
- getAttributeEncoding("DW_ATE_imaginary_float"));
-
- // Invalid languages.
- EXPECT_EQ(0u, getAttributeEncoding("DW_ATE_invalid"));
- EXPECT_EQ(0u, getAttributeEncoding("DW_TAG_array_type"));
- EXPECT_EQ(0u, getAttributeEncoding("something else"));
-
- // AttributeEncoding range markers should not be recognized.
- EXPECT_EQ(0u, getAttributeEncoding("DW_ATE_lo_user"));
- EXPECT_EQ(0u, getAttributeEncoding("DW_ATE_hi_user"));
-}
-
-TEST(DwarfTest, VirtualityString) {
- EXPECT_EQ(StringRef("DW_VIRTUALITY_none"),
- VirtualityString(DW_VIRTUALITY_none));
- EXPECT_EQ(StringRef("DW_VIRTUALITY_virtual"),
- VirtualityString(DW_VIRTUALITY_virtual));
- EXPECT_EQ(StringRef("DW_VIRTUALITY_pure_virtual"),
- VirtualityString(DW_VIRTUALITY_pure_virtual));
-
- // DW_VIRTUALITY_max should be pure virtual.
- EXPECT_EQ(StringRef("DW_VIRTUALITY_pure_virtual"),
- VirtualityString(DW_VIRTUALITY_max));
-
- // Invalid numbers shouldn't be stringified.
- EXPECT_EQ(StringRef(), VirtualityString(DW_VIRTUALITY_max + 1));
- EXPECT_EQ(StringRef(), VirtualityString(DW_VIRTUALITY_max + 77));
-}
-
-TEST(DwarfTest, getVirtuality) {
- EXPECT_EQ(DW_VIRTUALITY_none, getVirtuality("DW_VIRTUALITY_none"));
- EXPECT_EQ(DW_VIRTUALITY_virtual, getVirtuality("DW_VIRTUALITY_virtual"));
- EXPECT_EQ(DW_VIRTUALITY_pure_virtual,
- getVirtuality("DW_VIRTUALITY_pure_virtual"));
-
- // Invalid strings.
- EXPECT_EQ(DW_VIRTUALITY_invalid, getVirtuality("DW_VIRTUALITY_invalid"));
- EXPECT_EQ(DW_VIRTUALITY_invalid, getVirtuality("DW_VIRTUALITY_max"));
- EXPECT_EQ(DW_VIRTUALITY_invalid, getVirtuality("something else"));
-}
-
-} // end namespace
diff --git a/unittests/Support/DynamicLibrary/CMakeLists.txt b/unittests/Support/DynamicLibrary/CMakeLists.txt
index f0e945e78b18..2fa4bf237d40 100644
--- a/unittests/Support/DynamicLibrary/CMakeLists.txt
+++ b/unittests/Support/DynamicLibrary/CMakeLists.txt
@@ -4,16 +4,21 @@ add_llvm_unittest(DynamicLibraryTests DynamicLibraryTest.cpp)
export_executable_symbols(DynamicLibraryTests)
-add_library(PipSqueak SHARED PipSqueak.cxx)
+function(dynlib_add_module NAME)
+ add_library(${NAME} SHARED PipSqueak.cxx)
-set_output_directory(PipSqueak
- BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}
- LIBRARY_DIR ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}
- )
+ set_output_directory(${NAME}
+ BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}
+ LIBRARY_DIR ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}
+ )
-set_target_properties(PipSqueak
- PROPERTIES PREFIX ""
- SUFFIX ".so"
- )
+ set_target_properties(${NAME}
+ PROPERTIES PREFIX ""
+ SUFFIX ".so"
+ )
-add_dependencies(DynamicLibraryTests PipSqueak)
+ add_dependencies(DynamicLibraryTests ${NAME})
+endfunction(dynlib_add_module)
+
+dynlib_add_module(PipSqueak)
+dynlib_add_module(SecondLib)
diff --git a/unittests/Support/DynamicLibrary/DynamicLibraryTest.cpp b/unittests/Support/DynamicLibrary/DynamicLibraryTest.cpp
index 0674a91282a1..80a20990de18 100644
--- a/unittests/Support/DynamicLibrary/DynamicLibraryTest.cpp
+++ b/unittests/Support/DynamicLibrary/DynamicLibraryTest.cpp
@@ -7,34 +7,34 @@
//
//===----------------------------------------------------------------------===//
-#include "llvm/Config/config.h"
#include "llvm/Support/DynamicLibrary.h"
+#include "llvm/Config/config.h"
#include "llvm/Support/FileSystem.h"
#include "llvm/Support/ManagedStatic.h"
#include "llvm/Support/Path.h"
#include "gtest/gtest.h"
#include "PipSqueak.h"
-#include <string>
using namespace llvm;
using namespace llvm::sys;
extern "C" PIPSQUEAK_EXPORT const char *TestA() { return "ProcessCall"; }
-std::string LibPath() {
+std::string LibPath(const std::string Name = "PipSqueak") {
const std::vector<testing::internal::string>& Argvs = testing::internal::GetArgvs();
const char *Argv0 = Argvs.size() > 0 ? Argvs[0].c_str() : "DynamicLibraryTests";
void *Ptr = (void*)(intptr_t)TestA;
std::string Path = fs::getMainExecutable(Argv0, Ptr);
llvm::SmallString<256> Buf(path::parent_path(Path));
- path::append(Buf, "PipSqueak.so");
+ path::append(Buf, (Name+".so").c_str());
return Buf.str();
}
#if defined(_WIN32) || (defined(HAVE_DLFCN_H) && defined(HAVE_DLOPEN))
typedef void (*SetStrings)(std::string &GStr, std::string &LStr);
+typedef void (*TestOrder)(std::vector<std::string> &V);
typedef const char *(*GetString)();
template <class T> static T FuncPtr(void *Ptr) {
@@ -100,26 +100,59 @@ TEST(DynamicLibrary, Overload) {
}
TEST(DynamicLibrary, Shutdown) {
- std::string A, B;
+ std::string A("PipSqueak"), B, C("SecondLib");
+ std::vector<std::string> Order;
{
std::string Err;
llvm_shutdown_obj Shutdown;
DynamicLibrary DL =
- DynamicLibrary::getPermanentLibrary(LibPath().c_str(), &Err);
+ DynamicLibrary::getPermanentLibrary(LibPath(A).c_str(), &Err);
EXPECT_TRUE(DL.isValid());
EXPECT_TRUE(Err.empty());
- SetStrings SS = FuncPtr<SetStrings>(
+ SetStrings SS_0 = FuncPtr<SetStrings>(
DynamicLibrary::SearchForAddressOfSymbol("SetStrings"));
- EXPECT_TRUE(SS != nullptr);
+ EXPECT_TRUE(SS_0 != nullptr);
+
+ SS_0(A, B);
+ EXPECT_EQ(B, "Local::Local(PipSqueak)");
+
+ TestOrder TO_0 = FuncPtr<TestOrder>(
+ DynamicLibrary::SearchForAddressOfSymbol("TestOrder"));
+ EXPECT_TRUE(TO_0 != nullptr);
+
+ DynamicLibrary DL2 =
+ DynamicLibrary::getPermanentLibrary(LibPath(C).c_str(), &Err);
+ EXPECT_TRUE(DL2.isValid());
+ EXPECT_TRUE(Err.empty());
- SS(A, B);
- EXPECT_EQ(B, "Local::Local");
+ // Should find latest version of symbols in SecondLib
+ SetStrings SS_1 = FuncPtr<SetStrings>(
+ DynamicLibrary::SearchForAddressOfSymbol("SetStrings"));
+ EXPECT_TRUE(SS_1 != nullptr);
+ EXPECT_TRUE(SS_0 != SS_1);
+
+ TestOrder TO_1 = FuncPtr<TestOrder>(
+ DynamicLibrary::SearchForAddressOfSymbol("TestOrder"));
+ EXPECT_TRUE(TO_1 != nullptr);
+ EXPECT_TRUE(TO_0 != TO_1);
+
+ B.clear();
+ SS_1(C, B);
+ EXPECT_EQ(B, "Local::Local(SecondLib)");
+
+ TO_0(Order);
+ TO_1(Order);
}
EXPECT_EQ(A, "Global::~Global");
EXPECT_EQ(B, "Local::~Local");
EXPECT_TRUE(FuncPtr<SetStrings>(DynamicLibrary::SearchForAddressOfSymbol(
"SetStrings")) == nullptr);
+
+ // Test unload/destruction ordering
+ EXPECT_EQ(Order.size(), 2UL);
+ EXPECT_EQ(Order.front(), "SecondLib");
+ EXPECT_EQ(Order.back(), "PipSqueak");
}
#else
diff --git a/unittests/Support/DynamicLibrary/PipSqueak.cxx b/unittests/Support/DynamicLibrary/PipSqueak.cxx
index d1cf7c042b72..79cf59255a4f 100644
--- a/unittests/Support/DynamicLibrary/PipSqueak.cxx
+++ b/unittests/Support/DynamicLibrary/PipSqueak.cxx
@@ -9,38 +9,40 @@
#include "PipSqueak.h"
-#if defined(_WIN32) && !defined(__GNUC__)
-// Disable warnings from inclusion of xlocale & exception
-#pragma warning(push)
-#pragma warning(disable: 4530)
-#pragma warning(disable: 4577)
-#include <string>
-#pragma warning(pop)
-#else
-#include <string>
-#endif
-
struct Global {
std::string *Str;
- Global() : Str(nullptr) {}
+ std::vector<std::string> *Vec;
+ Global() : Str(nullptr), Vec(nullptr) {}
~Global() {
- if (Str)
+ if (Str) {
+ if (Vec)
+ Vec->push_back(*Str);
*Str = "Global::~Global";
+ }
}
};
+static Global Glb;
+
struct Local {
std::string &Str;
- Local(std::string &S) : Str(S) { Str = "Local::Local"; }
+ Local(std::string &S) : Str(S) {
+ Str = "Local::Local";
+ if (Glb.Str && !Glb.Str->empty())
+ Str += std::string("(") + *Glb.Str + std::string(")");
+ }
~Local() { Str = "Local::~Local"; }
};
-static Global Glb;
extern "C" PIPSQUEAK_EXPORT void SetStrings(std::string &GStr,
std::string &LStr) {
- static Local Lcl(LStr);
Glb.Str = &GStr;
+ static Local Lcl(LStr);
+}
+
+extern "C" PIPSQUEAK_EXPORT void TestOrder(std::vector<std::string> &V) {
+ Glb.Vec = &V;
}
extern "C" PIPSQUEAK_EXPORT const char *TestA() { return "LibCall"; }
diff --git a/unittests/Support/DynamicLibrary/PipSqueak.h b/unittests/Support/DynamicLibrary/PipSqueak.h
index e6a859d60716..3e4f79a9a6f4 100644
--- a/unittests/Support/DynamicLibrary/PipSqueak.h
+++ b/unittests/Support/DynamicLibrary/PipSqueak.h
@@ -10,6 +10,19 @@
#ifndef LLVM_PIPSQUEAK_H
#define LLVM_PIPSQUEAK_H
+#if defined(_WIN32) && !defined(__GNUC__)
+// Disable warnings from inclusion of xlocale & exception
+#pragma warning(push)
+#pragma warning(disable: 4530)
+#pragma warning(disable: 4577)
+#include <string>
+#include <vector>
+#pragma warning(pop)
+#else
+#include <string>
+#include <vector>
+#endif
+
#ifdef _WIN32
#define PIPSQUEAK_EXPORT __declspec(dllexport)
#else
diff --git a/unittests/Support/EndianStreamTest.cpp b/unittests/Support/EndianStreamTest.cpp
index ea6c308c560a..48c5c3bc8175 100644
--- a/unittests/Support/EndianStreamTest.cpp
+++ b/unittests/Support/EndianStreamTest.cpp
@@ -7,8 +7,8 @@
//
//===----------------------------------------------------------------------===//
-#include "llvm/ADT/SmallString.h"
#include "llvm/Support/EndianStream.h"
+#include "llvm/ADT/SmallString.h"
#include "llvm/Support/DataTypes.h"
#include "gtest/gtest.h"
using namespace llvm;
diff --git a/unittests/Support/FileOutputBufferTest.cpp b/unittests/Support/FileOutputBufferTest.cpp
index 53a2ae0aadde..5f20634d66c2 100644
--- a/unittests/Support/FileOutputBufferTest.cpp
+++ b/unittests/Support/FileOutputBufferTest.cpp
@@ -7,9 +7,9 @@
//
//===----------------------------------------------------------------------===//
+#include "llvm/Support/FileOutputBuffer.h"
#include "llvm/Support/Errc.h"
#include "llvm/Support/ErrorHandling.h"
-#include "llvm/Support/FileOutputBuffer.h"
#include "llvm/Support/FileSystem.h"
#include "llvm/Support/Path.h"
#include "llvm/Support/raw_ostream.h"
diff --git a/unittests/Support/FormatVariadicTest.cpp b/unittests/Support/FormatVariadicTest.cpp
index b0c843870afc..99b90b17ae44 100644
--- a/unittests/Support/FormatVariadicTest.cpp
+++ b/unittests/Support/FormatVariadicTest.cpp
@@ -7,8 +7,8 @@
//
//===----------------------------------------------------------------------===//
-#include "llvm/Support/FormatAdapters.h"
#include "llvm/Support/FormatVariadic.h"
+#include "llvm/Support/FormatAdapters.h"
#include "gtest/gtest.h"
using namespace llvm;
diff --git a/unittests/Support/LEB128Test.cpp b/unittests/Support/LEB128Test.cpp
index 061936df1d19..09db6dfdc593 100644
--- a/unittests/Support/LEB128Test.cpp
+++ b/unittests/Support/LEB128Test.cpp
@@ -7,10 +7,10 @@
//
//===----------------------------------------------------------------------===//
-#include "gtest/gtest.h"
-#include "llvm/Support/DataTypes.h"
#include "llvm/Support/LEB128.h"
+#include "llvm/Support/DataTypes.h"
#include "llvm/Support/raw_ostream.h"
+#include "gtest/gtest.h"
#include <string>
using namespace llvm;
diff --git a/unittests/Support/MD5Test.cpp b/unittests/Support/MD5Test.cpp
index fa9372fde33f..8b151827a7bd 100644
--- a/unittests/Support/MD5Test.cpp
+++ b/unittests/Support/MD5Test.cpp
@@ -11,9 +11,9 @@
//
//===----------------------------------------------------------------------===//
+#include "llvm/Support/MD5.h"
#include "llvm/ADT/ArrayRef.h"
#include "llvm/ADT/SmallString.h"
-#include "llvm/Support/MD5.h"
#include "gtest/gtest.h"
using namespace llvm;
diff --git a/unittests/Support/MathExtrasTest.cpp b/unittests/Support/MathExtrasTest.cpp
index f46d94e9e577..e26653b8a656 100644
--- a/unittests/Support/MathExtrasTest.cpp
+++ b/unittests/Support/MathExtrasTest.cpp
@@ -7,8 +7,8 @@
//
//===----------------------------------------------------------------------===//
-#include "gtest/gtest.h"
#include "llvm/Support/MathExtras.h"
+#include "gtest/gtest.h"
using namespace llvm;
diff --git a/unittests/Support/MemoryBufferTest.cpp b/unittests/Support/MemoryBufferTest.cpp
index 0efa22c157d9..294581aeb928 100644
--- a/unittests/Support/MemoryBufferTest.cpp
+++ b/unittests/Support/MemoryBufferTest.cpp
@@ -11,9 +11,9 @@
//
//===----------------------------------------------------------------------===//
+#include "llvm/Support/MemoryBuffer.h"
#include "llvm/Support/FileSystem.h"
#include "llvm/Support/FileUtilities.h"
-#include "llvm/Support/MemoryBuffer.h"
#include "llvm/Support/raw_ostream.h"
#include "gtest/gtest.h"
diff --git a/unittests/Support/MemoryTest.cpp b/unittests/Support/MemoryTest.cpp
index f439cb2af9b1..140219ffd1d6 100644
--- a/unittests/Support/MemoryTest.cpp
+++ b/unittests/Support/MemoryTest.cpp
@@ -360,6 +360,6 @@ unsigned MemoryFlags[] = {
INSTANTIATE_TEST_CASE_P(AllocationTests,
MappedMemoryTest,
- ::testing::ValuesIn(MemoryFlags));
+ ::testing::ValuesIn(MemoryFlags),);
} // anonymous namespace
diff --git a/unittests/Support/Path.cpp b/unittests/Support/Path.cpp
index a4bdcb5c79a2..3e474f33ca6d 100644
--- a/unittests/Support/Path.cpp
+++ b/unittests/Support/Path.cpp
@@ -8,9 +8,10 @@
//===----------------------------------------------------------------------===//
#include "llvm/Support/Path.h"
-#include "llvm/ADT/SmallVector.h"
#include "llvm/ADT/STLExtras.h"
+#include "llvm/ADT/SmallVector.h"
#include "llvm/ADT/Triple.h"
+#include "llvm/BinaryFormat/Magic.h"
#include "llvm/Support/ConvertUTF.h"
#include "llvm/Support/Errc.h"
#include "llvm/Support/ErrorHandling.h"
@@ -919,86 +920,6 @@ TEST_F(FileSystemTest, Remove) {
ASSERT_FALSE(fs::exists(BaseDir));
}
-const char archive[] = "!<arch>\x0A";
-const char bitcode[] = "\xde\xc0\x17\x0b";
-const char coff_object[] = "\x00\x00......";
-const char coff_bigobj[] = "\x00\x00\xff\xff\x00\x02......"
- "\xc7\xa1\xba\xd1\xee\xba\xa9\x4b\xaf\x20\xfa\xf6\x6a\xa4\xdc\xb8";
-const char coff_import_library[] = "\x00\x00\xff\xff....";
-const char elf_relocatable[] = { 0x7f, 'E', 'L', 'F', 1, 2, 1, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 1 };
-const char macho_universal_binary[] = "\xca\xfe\xba\xbe...\x00";
-const char macho_object[] =
- "\xfe\xed\xfa\xce........\x00\x00\x00\x01............";
-const char macho_executable[] =
- "\xfe\xed\xfa\xce........\x00\x00\x00\x02............";
-const char macho_fixed_virtual_memory_shared_lib[] =
- "\xfe\xed\xfa\xce........\x00\x00\x00\x03............";
-const char macho_core[] =
- "\xfe\xed\xfa\xce........\x00\x00\x00\x04............";
-const char macho_preload_executable[] =
- "\xfe\xed\xfa\xce........\x00\x00\x00\x05............";
-const char macho_dynamically_linked_shared_lib[] =
- "\xfe\xed\xfa\xce........\x00\x00\x00\x06............";
-const char macho_dynamic_linker[] =
- "\xfe\xed\xfa\xce........\x00\x00\x00\x07............";
-const char macho_bundle[] =
- "\xfe\xed\xfa\xce........\x00\x00\x00\x08............";
-const char macho_dsym_companion[] =
- "\xfe\xed\xfa\xce........\x00\x00\x00\x0a............";
-const char macho_kext_bundle[] =
- "\xfe\xed\xfa\xce........\x00\x00\x00\x0b............";
-const char windows_resource[] = "\x00\x00\x00\x00\x020\x00\x00\x00\xff";
-const char macho_dynamically_linked_shared_lib_stub[] =
- "\xfe\xed\xfa\xce........\x00\x00\x00\x09............";
-
-TEST_F(FileSystemTest, Magic) {
- struct type {
- const char *filename;
- const char *magic_str;
- size_t magic_str_len;
- fs::file_magic magic;
- } types[] = {
-#define DEFINE(magic) \
- { #magic, magic, sizeof(magic), fs::file_magic::magic }
- DEFINE(archive),
- DEFINE(bitcode),
- DEFINE(coff_object),
- { "coff_bigobj", coff_bigobj, sizeof(coff_bigobj), fs::file_magic::coff_object },
- DEFINE(coff_import_library),
- DEFINE(elf_relocatable),
- DEFINE(macho_universal_binary),
- DEFINE(macho_object),
- DEFINE(macho_executable),
- DEFINE(macho_fixed_virtual_memory_shared_lib),
- DEFINE(macho_core),
- DEFINE(macho_preload_executable),
- DEFINE(macho_dynamically_linked_shared_lib),
- DEFINE(macho_dynamic_linker),
- DEFINE(macho_bundle),
- DEFINE(macho_dynamically_linked_shared_lib_stub),
- DEFINE(macho_dsym_companion),
- DEFINE(macho_kext_bundle),
- DEFINE(windows_resource)
-#undef DEFINE
- };
-
- // Create some files filled with magic.
- for (type *i = types, *e = types + (sizeof(types) / sizeof(type)); i != e;
- ++i) {
- SmallString<128> file_pathname(TestDirectory);
- path::append(file_pathname, i->filename);
- std::error_code EC;
- raw_fd_ostream file(file_pathname, EC, sys::fs::F_None);
- ASSERT_FALSE(file.has_error());
- StringRef magic(i->magic_str, i->magic_str_len);
- file << magic;
- file.close();
- EXPECT_EQ(i->magic, fs::identify_magic(magic));
- ASSERT_NO_ERROR(fs::remove(Twine(file_pathname)));
- }
-}
-
#ifdef LLVM_ON_WIN32
TEST_F(FileSystemTest, CarriageReturn) {
SmallString<128> FilePathname(TestDirectory);
diff --git a/unittests/Support/ProgramTest.cpp b/unittests/Support/ProgramTest.cpp
index 3926ceb92b3e..f658980073da 100644
--- a/unittests/Support/ProgramTest.cpp
+++ b/unittests/Support/ProgramTest.cpp
@@ -7,11 +7,11 @@
//
//===----------------------------------------------------------------------===//
-#include "llvm/Support/ConvertUTF.h"
+#include "llvm/Support/Program.h"
#include "llvm/Support/CommandLine.h"
+#include "llvm/Support/ConvertUTF.h"
#include "llvm/Support/FileSystem.h"
#include "llvm/Support/Path.h"
-#include "llvm/Support/Program.h"
#include "gtest/gtest.h"
#include <stdlib.h>
#if defined(__APPLE__)
diff --git a/unittests/Support/SpecialCaseListTest.cpp b/unittests/Support/SpecialCaseListTest.cpp
index e86eecb527bb..130848845e45 100644
--- a/unittests/Support/SpecialCaseListTest.cpp
+++ b/unittests/Support/SpecialCaseListTest.cpp
@@ -7,9 +7,9 @@
//
//===----------------------------------------------------------------------===//
+#include "llvm/Support/SpecialCaseList.h"
#include "llvm/Support/FileSystem.h"
#include "llvm/Support/MemoryBuffer.h"
-#include "llvm/Support/SpecialCaseList.h"
#include "gtest/gtest.h"
using namespace llvm;
diff --git a/unittests/Support/SwapByteOrderTest.cpp b/unittests/Support/SwapByteOrderTest.cpp
index 4f2537c4d5de..474eac6bbb38 100644
--- a/unittests/Support/SwapByteOrderTest.cpp
+++ b/unittests/Support/SwapByteOrderTest.cpp
@@ -7,8 +7,8 @@
//
//===----------------------------------------------------------------------===//
-#include "gtest/gtest.h"
#include "llvm/Support/SwapByteOrder.h"
+#include "gtest/gtest.h"
#include <cstdlib>
#include <ctime>
using namespace llvm;
diff --git a/unittests/Support/TarWriterTest.cpp b/unittests/Support/TarWriterTest.cpp
index 84005de56c12..927c8ed9be14 100644
--- a/unittests/Support/TarWriterTest.cpp
+++ b/unittests/Support/TarWriterTest.cpp
@@ -7,9 +7,9 @@
//
//===----------------------------------------------------------------------===//
+#include "llvm/Support/TarWriter.h"
#include "llvm/Support/FileSystem.h"
#include "llvm/Support/MemoryBuffer.h"
-#include "llvm/Support/TarWriter.h"
#include "gtest/gtest.h"
using namespace llvm;
diff --git a/unittests/Support/TargetParserTest.cpp b/unittests/Support/TargetParserTest.cpp
index 76d1917d537a..b252641f1a13 100644
--- a/unittests/Support/TargetParserTest.cpp
+++ b/unittests/Support/TargetParserTest.cpp
@@ -7,9 +7,9 @@
//
//===----------------------------------------------------------------------===//
+#include "llvm/Support/TargetParser.h"
#include "llvm/ADT/STLExtras.h"
#include "llvm/Support/ARMBuildAttributes.h"
-#include "llvm/Support/TargetParser.h"
#include "gtest/gtest.h"
#include <string>
diff --git a/unittests/Support/TrigramIndexTest.cpp b/unittests/Support/TrigramIndexTest.cpp
index fb0ad1749bbd..df42c1efd8a0 100644
--- a/unittests/Support/TrigramIndexTest.cpp
+++ b/unittests/Support/TrigramIndexTest.cpp
@@ -7,8 +7,8 @@
//
//===----------------------------------------------------------------------===//
-#include "llvm/ADT/STLExtras.h"
#include "llvm/Support/TrigramIndex.h"
+#include "llvm/ADT/STLExtras.h"
#include "gtest/gtest.h"
#include <string>
diff --git a/unittests/Support/YAMLIOTest.cpp b/unittests/Support/YAMLIOTest.cpp
index 5a0280c8ca5b..21c8430f9588 100644
--- a/unittests/Support/YAMLIOTest.cpp
+++ b/unittests/Support/YAMLIOTest.cpp
@@ -14,7 +14,6 @@
#include "llvm/Support/YAMLTraits.h"
#include "gtest/gtest.h"
-
using llvm::yaml::Input;
using llvm::yaml::Output;
using llvm::yaml::IO;
diff --git a/unittests/Support/YAMLParserTest.cpp b/unittests/Support/YAMLParserTest.cpp
index 3f12a53fd9c5..d411a286830b 100644
--- a/unittests/Support/YAMLParserTest.cpp
+++ b/unittests/Support/YAMLParserTest.cpp
@@ -7,11 +7,11 @@
//
//===----------------------------------------------------------------------===//
+#include "llvm/Support/YAMLParser.h"
#include "llvm/ADT/Twine.h"
#include "llvm/Support/Casting.h"
#include "llvm/Support/MemoryBuffer.h"
#include "llvm/Support/SourceMgr.h"
-#include "llvm/Support/YAMLParser.h"
#include "gtest/gtest.h"
namespace llvm {
diff --git a/unittests/Support/formatted_raw_ostream_test.cpp b/unittests/Support/formatted_raw_ostream_test.cpp
index 9bb804691337..2b8f06523beb 100644
--- a/unittests/Support/formatted_raw_ostream_test.cpp
+++ b/unittests/Support/formatted_raw_ostream_test.cpp
@@ -7,8 +7,8 @@
//
//===----------------------------------------------------------------------===//
-#include "llvm/Support/FormattedStream.h"
#include "llvm/ADT/SmallString.h"
+#include "llvm/Support/FormattedStream.h"
#include "llvm/Support/raw_ostream.h"
#include "gtest/gtest.h"
diff --git a/unittests/Support/raw_ostream_test.cpp b/unittests/Support/raw_ostream_test.cpp
index 777e555949ee..a7a5ce8dd6d4 100644
--- a/unittests/Support/raw_ostream_test.cpp
+++ b/unittests/Support/raw_ostream_test.cpp
@@ -7,11 +7,11 @@
//
//===----------------------------------------------------------------------===//
-#include "gtest/gtest.h"
#include "llvm/ADT/SmallString.h"
#include "llvm/Support/FileSystem.h"
#include "llvm/Support/Format.h"
#include "llvm/Support/raw_ostream.h"
+#include "gtest/gtest.h"
using namespace llvm;
diff --git a/unittests/Support/raw_pwrite_stream_test.cpp b/unittests/Support/raw_pwrite_stream_test.cpp
index 08b2f90d6054..249780a8c829 100644
--- a/unittests/Support/raw_pwrite_stream_test.cpp
+++ b/unittests/Support/raw_pwrite_stream_test.cpp
@@ -7,11 +7,11 @@
//
//===----------------------------------------------------------------------===//
-#include "gtest/gtest.h"
#include "llvm/ADT/SmallString.h"
#include "llvm/Support/FileSystem.h"
#include "llvm/Support/FileUtilities.h"
#include "llvm/Support/raw_ostream.h"
+#include "gtest/gtest.h"
using namespace llvm;
diff --git a/unittests/Support/raw_sha1_ostream_test.cpp b/unittests/Support/raw_sha1_ostream_test.cpp
index 1bb4e2eb1d58..e176f3f7a19b 100644
--- a/unittests/Support/raw_sha1_ostream_test.cpp
+++ b/unittests/Support/raw_sha1_ostream_test.cpp
@@ -7,9 +7,9 @@
//
//===----------------------------------------------------------------------===//
-#include "gtest/gtest.h"
#include "llvm/Support/Format.h"
#include "llvm/Support/raw_sha1_ostream.h"
+#include "gtest/gtest.h"
#include <string>