Move entirety of llvm namespace to wpi namespace.

During shared library loading, a different libLLVM can be pulled in, causing
llvm symbols from dependent libraries to resolve to that library instead of
this one. This has been seen in the wild with the Mesa OpenGL implementation
in JavaFX applications (see wpilibsuite/shuffleboard#361).

This is clearly a very breaking change. For some level of backwards
compatibility, a namespace alias from llvm to wpi is performed in the "llvm"
headers.  Unfortunately, forward declarations of llvm classes will still break,
but compilers seem to generate clear error messages in those cases
("namespace alias 'llvm' not allowed here, assuming 'wpi'").

This change also moves all the wpiutil headers to a single "wpi" subdirectory
from the previously split "llvm", "support", "tcpsockets", and "udpsockets".
Shim headers will be added for backwards compatibility in a later commit.
This commit is contained in:
Peter Johnson
2018-04-29 23:33:19 -07:00
parent 93859eb84f
commit f84018af5f
377 changed files with 2747 additions and 2742 deletions

View File

@@ -47,7 +47,7 @@
------------------------------------------------------------------------ */
#include "llvm/ConvertUTF.h"
#include "wpi/ConvertUTF.h"
#ifdef CVTUTF_DEBUG
#include <stdio.h>
#endif

View File

@@ -7,11 +7,11 @@
//
//===----------------------------------------------------------------------===//
#include "llvm/ConvertUTF.h"
#include "wpi/ConvertUTF.h"
#include <string>
#include <vector>
namespace llvm {
namespace wpi {
bool ConvertCodePointToUTF8(unsigned Source, char *&ResultPtr) {
const UTF32 *SourceStart = &Source;
@@ -118,5 +118,5 @@ bool convertUTF8ToUTF16String(StringRef SrcUTF8,
return true;
}
} // end namespace llvm
} // end namespace wpi

View File

@@ -12,7 +12,7 @@
//
//===----------------------------------------------------------------------===//
#include "llvm/WindowsError.h"
#include "wpi/WindowsError.h"
#ifdef _WIN32
@@ -24,7 +24,7 @@
case x: \
return std::make_error_code(std::errc::y)
std::error_code llvm::mapWindowsError(unsigned EV) {
std::error_code wpi::mapWindowsError(unsigned EV) {
switch (EV) {
MAP_ERR_TO_COND(ERROR_ACCESS_DENIED, permission_denied);
MAP_ERR_TO_COND(ERROR_ALREADY_EXISTS, file_exists);

View File

@@ -13,17 +13,17 @@
//
//===----------------------------------------------------------------------===//
#include "llvm/Hashing.h"
#include "wpi/Hashing.h"
using namespace llvm;
using namespace wpi;
// Provide a definition and static initializer for the fixed seed. This
// initializer should always be zero to ensure its value can never appear to be
// non-zero, even during dynamic initialization.
size_t llvm::hashing::detail::fixed_seed_override = 0;
size_t wpi::hashing::detail::fixed_seed_override = 0;
// Implement the function for forced setting of the fixed seed.
// FIXME: Use atomic operations here so that there is no data race.
void llvm::set_fixed_execution_hash_seed(size_t fixed_value) {
void wpi::set_fixed_execution_hash_seed(size_t fixed_value) {
hashing::detail::fixed_seed_override = fixed_value;
}

View File

@@ -11,7 +11,7 @@
//
//===----------------------------------------------------------------------===//
#include "llvm/Path.h"
#include "wpi/Path.h"
#include <cctype>
#include <cstring>
@@ -22,14 +22,14 @@
#include <io.h>
#endif
#include "llvm/FileSystem.h"
#include "llvm/SmallString.h"
#include "wpi/FileSystem.h"
#include "wpi/SmallString.h"
using namespace llvm;
using namespace wpi;
namespace {
using llvm::StringRef;
using llvm::sys::path::is_separator;
using wpi::StringRef;
using wpi::sys::path::is_separator;
#ifdef _WIN32
const char *separators = "\\/";
@@ -148,7 +148,7 @@ namespace {
}
} // end unnamed namespace
namespace llvm {
namespace wpi {
namespace sys {
namespace path {
@@ -626,7 +626,7 @@ static SmallString<256> remove_dots(StringRef path, bool remove_dot_dot) {
// Skip the root path, then look for traversal in the components.
StringRef rel = path::relative_path(path);
for (StringRef C : llvm::make_range(path::begin(rel), path::end(rel))) {
for (StringRef C : wpi::make_range(path::begin(rel), path::end(rel))) {
if (C == ".")
continue;
if (remove_dot_dot) {
@@ -795,7 +795,7 @@ std::error_code directory_entry::status(file_status &result) const {
} // end namespace fs
} // end namespace sys
} // end namespace llvm
} // end namespace wpi
// Include the truly platform-specific parts.
#ifdef _WIN32
@@ -804,7 +804,7 @@ std::error_code directory_entry::status(file_status &result) const {
#include "Unix/Path.inc"
#endif
namespace llvm {
namespace wpi {
namespace sys {
namespace path {
@@ -819,4 +819,4 @@ bool user_cache_directory(SmallVectorImpl<char> &Result, const Twine &Path1,
} // end namespace path
} // end namsspace sys
} // end namespace llvm
} // end namespace wpi

View File

@@ -12,13 +12,13 @@
//
//===----------------------------------------------------------------------===//
#include "llvm/SmallPtrSet.h"
#include "llvm/DenseMapInfo.h"
#include "llvm/MathExtras.h"
#include "wpi/SmallPtrSet.h"
#include "wpi/DenseMapInfo.h"
#include "wpi/MathExtras.h"
#include <algorithm>
#include <cstdlib>
using namespace llvm;
using namespace wpi;
void SmallPtrSetImplBase::shrink_and_clear() {
assert(!isSmall() && "Can't shrink a small set!");

View File

@@ -11,8 +11,8 @@
//
//===----------------------------------------------------------------------===//
#include "llvm/SmallVector.h"
using namespace llvm;
#include "wpi/SmallVector.h"
using namespace wpi;
/// grow_pod - This is an implementation of the grow() method which only works
/// on POD-like datatypes and is out of line to reduce code duplication.

View File

@@ -11,14 +11,14 @@
//
//===----------------------------------------------------------------------===//
#include "llvm/StringExtras.h"
#include "llvm/SmallVector.h"
using namespace llvm;
#include "wpi/StringExtras.h"
#include "wpi/SmallVector.h"
using namespace wpi;
/// StrInStrNoCase - Portable version of strcasestr. Locates the first
/// occurrence of string 's1' in string 's2', ignoring case. Returns
/// the offset of s2 in s1 or npos if s2 cannot be found.
StringRef::size_type llvm::StrInStrNoCase(StringRef s1, StringRef s2) {
StringRef::size_type wpi::StrInStrNoCase(StringRef s1, StringRef s2) {
size_t N = s2.size(), M = s1.size();
if (N > M)
return StringRef::npos;
@@ -34,7 +34,7 @@ StringRef::size_type llvm::StrInStrNoCase(StringRef s1, StringRef s2) {
/// there are no tokens in the source string, an empty string is returned.
/// The function returns a pair containing the extracted token and the
/// remaining tail string.
std::pair<StringRef, StringRef> llvm::getToken(StringRef Source,
std::pair<StringRef, StringRef> wpi::getToken(StringRef Source,
StringRef Delimiters) {
// Figure out where the token starts.
StringRef::size_type Start = Source.find_first_not_of(Delimiters);
@@ -47,7 +47,7 @@ std::pair<StringRef, StringRef> llvm::getToken(StringRef Source,
/// SplitString - Split up the specified string according to the specified
/// delimiters, appending the result fragments to the output list.
void llvm::SplitString(StringRef Source,
void wpi::SplitString(StringRef Source,
SmallVectorImpl<StringRef> &OutFragments,
StringRef Delimiters) {
std::pair<StringRef, StringRef> S = getToken(Source, Delimiters);

View File

@@ -11,12 +11,12 @@
//
//===----------------------------------------------------------------------===//
#include "llvm/StringMap.h"
#include "llvm/MathExtras.h"
#include "llvm/StringExtras.h"
#include "llvm/Compiler.h"
#include "wpi/StringMap.h"
#include "wpi/MathExtras.h"
#include "wpi/StringExtras.h"
#include "wpi/Compiler.h"
#include <cassert>
using namespace llvm;
using namespace wpi;
/// Returns the number of buckets to allocate to ensure that the DenseMap can
/// accommodate \p NumEntries without need to grow().

View File

@@ -7,13 +7,13 @@
//
//===----------------------------------------------------------------------===//
#include "llvm/StringRef.h"
#include "llvm/Hashing.h"
#include "llvm/SmallVector.h"
#include "wpi/StringRef.h"
#include "wpi/Hashing.h"
#include "wpi/SmallVector.h"
#include <bitset>
#include <climits>
using namespace llvm;
using namespace wpi;
// MSVC emits references to this into the translation units which reference it.
#ifndef _MSC_VER
@@ -120,7 +120,7 @@ std::string StringRef::upper() const {
return Result;
}
const char *StringRef::c_str(llvm::SmallVectorImpl<char>& buf) const {
const char *StringRef::c_str(wpi::SmallVectorImpl<char>& buf) const {
if (is_null_terminated()) {
// If null terminated, return data directly
return data();
@@ -379,7 +379,7 @@ static unsigned GetAutoSenseRadix(StringRef &Str) {
/// GetAsUnsignedInteger - Workhorse method that converts a integer character
/// sequence of radix up to 36 to an unsigned long long value.
bool llvm::getAsUnsignedInteger(StringRef Str, unsigned Radix,
bool wpi::getAsUnsignedInteger(StringRef Str, unsigned Radix,
unsigned long long &Result) {
// Autosense radix if not specified.
if (Radix == 0)
@@ -420,7 +420,7 @@ bool llvm::getAsUnsignedInteger(StringRef Str, unsigned Radix,
return false;
}
bool llvm::getAsSignedInteger(StringRef Str, unsigned Radix,
bool wpi::getAsSignedInteger(StringRef Str, unsigned Radix,
long long &Result) {
unsigned long long ULLVal;
@@ -447,6 +447,6 @@ bool llvm::getAsSignedInteger(StringRef Str, unsigned Radix,
}
// Implementation of StringRef hashing.
hash_code llvm::hash_value(StringRef S) {
hash_code wpi::hash_value(StringRef S) {
return hash_combine_range(S.begin(), S.end());
}

View File

@@ -7,10 +7,10 @@
//
//===----------------------------------------------------------------------===//
#include "llvm/Twine.h"
#include "llvm/SmallString.h"
#include "llvm/raw_ostream.h"
using namespace llvm;
#include "wpi/Twine.h"
#include "wpi/SmallString.h"
#include "wpi/raw_ostream.h"
using namespace wpi;
std::string Twine::str() const {
// If we're storing only a std::string, just return it.

View File

@@ -28,7 +28,7 @@
#include <sys/types.h>
#include <unistd.h>
namespace llvm {
namespace wpi {
namespace sys {
namespace fs {
UniqueID file_status::getUniqueID() const {
@@ -39,10 +39,10 @@ std::error_code current_path(SmallVectorImpl<char> &result) {
result.clear();
const char *pwd = ::getenv("PWD");
llvm::sys::fs::file_status PWDStatus, DotStatus;
if (pwd && llvm::sys::path::is_absolute(pwd) &&
!llvm::sys::fs::status(pwd, PWDStatus) &&
!llvm::sys::fs::status(".", DotStatus) &&
wpi::sys::fs::file_status PWDStatus, DotStatus;
if (pwd && wpi::sys::path::is_absolute(pwd) &&
!wpi::sys::fs::status(pwd, PWDStatus) &&
!wpi::sys::fs::status(".", DotStatus) &&
PWDStatus.getUniqueID() == DotStatus.getUniqueID()) {
result.append(pwd, pwd + strlen(pwd));
return std::error_code();
@@ -387,4 +387,4 @@ void system_temp_directory(bool ErasedOnReboot, SmallVectorImpl<char> &Result) {
} // end namespace path
} // end namespace sys
} // end namespace llvm
} // end namespace wpi

View File

@@ -16,8 +16,8 @@
//=== is guaranteed to work on *all* Windows variants.
//===----------------------------------------------------------------------===//
#include "llvm/STLExtras.h"
#include "llvm/WindowsError.h"
#include "wpi/STLExtras.h"
#include "wpi/WindowsError.h"
#include <fcntl.h>
#include <io.h>
#include <sys/stat.h>
@@ -35,11 +35,11 @@
# pragma comment(lib, "ole32.lib")
#endif
using namespace llvm;
using namespace wpi;
using llvm::sys::windows::UTF8ToUTF16;
using llvm::sys::windows::UTF16ToUTF8;
using llvm::sys::path::widenPath;
using wpi::sys::windows::UTF8ToUTF16;
using wpi::sys::windows::UTF16ToUTF8;
using wpi::sys::path::widenPath;
static bool is_separator(const wchar_t value) {
switch (value) {
@@ -51,7 +51,7 @@ static bool is_separator(const wchar_t value) {
}
}
namespace llvm {
namespace wpi {
namespace sys {
namespace path {
@@ -69,7 +69,7 @@ std::error_code widenPath(const Twine &Path8,
// If we made this path absolute, how much longer would it get?
size_t CurPathLen;
if (llvm::sys::path::is_absolute(Twine(Path8Str)))
if (wpi::sys::path::is_absolute(Twine(Path8Str)))
CurPathLen = 0; // No contribution from current_path needed.
else {
CurPathLen = ::GetCurrentDirectoryW(0, NULL);
@@ -83,7 +83,7 @@ std::error_code widenPath(const Twine &Path8,
SmallString<2*MAX_PATH> FullPath("\\\\?\\");
if (CurPathLen) {
SmallString<80> CurPath;
if (std::error_code EC = llvm::sys::fs::current_path(CurPath))
if (std::error_code EC = wpi::sys::fs::current_path(CurPath))
return EC;
FullPath.append(CurPath);
}
@@ -91,15 +91,15 @@ std::error_code widenPath(const Twine &Path8,
// the \\?\ prefix is documented to treat them as real components).
// The iterators don't report separators and append() always attaches
// preferred_separator so we don't need to call native() on the result.
for (llvm::sys::path::const_iterator I = llvm::sys::path::begin(Path8Str),
E = llvm::sys::path::end(Path8Str);
for (wpi::sys::path::const_iterator I = wpi::sys::path::begin(Path8Str),
E = wpi::sys::path::end(Path8Str);
I != E; ++I) {
if (I->size() == 1 && *I == ".")
continue;
if (I->size() == 2 && *I == "..")
llvm::sys::path::remove_filename(FullPath);
wpi::sys::path::remove_filename(FullPath);
else
llvm::sys::path::append(FullPath, *I);
wpi::sys::path::append(FullPath, *I);
}
return UTF8ToUTF16(FullPath, Path16);
}
@@ -577,8 +577,8 @@ void system_temp_directory(bool ErasedOnReboot, SmallVectorImpl<char> &Result) {
} // end namespace path
namespace windows {
std::error_code UTF8ToUTF16(llvm::StringRef utf8,
llvm::SmallVectorImpl<wchar_t> &utf16) {
std::error_code UTF8ToUTF16(wpi::StringRef utf8,
wpi::SmallVectorImpl<wchar_t> &utf16) {
if (!utf8.empty()) {
int len = ::MultiByteToWideChar(CP_UTF8, MB_ERR_INVALID_CHARS, utf8.begin(),
utf8.size(), utf16.begin(), 0);
@@ -606,7 +606,7 @@ std::error_code UTF8ToUTF16(llvm::StringRef utf8,
static
std::error_code UTF16ToCodePage(unsigned codepage, const wchar_t *utf16,
size_t utf16_len,
llvm::SmallVectorImpl<char> &utf8) {
wpi::SmallVectorImpl<char> &utf8) {
if (utf16_len) {
// Get length.
int len = ::WideCharToMultiByte(codepage, 0, utf16, utf16_len, utf8.begin(),
@@ -634,15 +634,15 @@ std::error_code UTF16ToCodePage(unsigned codepage, const wchar_t *utf16,
}
std::error_code UTF16ToUTF8(const wchar_t *utf16, size_t utf16_len,
llvm::SmallVectorImpl<char> &utf8) {
wpi::SmallVectorImpl<char> &utf8) {
return UTF16ToCodePage(CP_UTF8, utf16, utf16_len, utf8);
}
std::error_code UTF16ToCurCP(const wchar_t *utf16, size_t utf16_len,
llvm::SmallVectorImpl<char> &utf8) {
wpi::SmallVectorImpl<char> &utf8) {
return UTF16ToCodePage(CP_ACP, utf16, utf16_len, utf8);
}
} // end namespace windows
} // end namespace sys
} // end namespace llvm
} // end namespace wpi

View File

@@ -34,11 +34,11 @@
#define NOMINMAX
#endif
#include "llvm/SmallVector.h"
#include "llvm/StringExtras.h"
#include "llvm/StringRef.h"
#include "llvm/Twine.h"
#include "llvm/Compiler.h"
#include "wpi/SmallVector.h"
#include "wpi/StringExtras.h"
#include "wpi/StringRef.h"
#include "wpi/Twine.h"
#include "wpi/Compiler.h"
#include <system_error>
#include <windows.h>
#include <cassert>
@@ -79,7 +79,7 @@ inline bool MakeErrMsg(std::string *ErrMsg, const std::string &prefix) {
*ErrMsg = prefix + ": " + buffer;
else
*ErrMsg = prefix + ": Unknown error";
*ErrMsg += " (0x" + llvm::utohexstr(LastError) + ")";
*ErrMsg += " (0x" + wpi::utohexstr(LastError) + ")";
LocalFree(buffer);
return R != 0;
@@ -179,7 +179,7 @@ typedef ScopedHandle<RegTraits> ScopedRegHandle;
typedef ScopedHandle<FindHandleTraits> ScopedFindHandle;
typedef ScopedHandle<JobHandleTraits> ScopedJobHandle;
namespace llvm {
namespace wpi {
template <class T>
class SmallVectorImpl;
@@ -206,6 +206,6 @@ std::error_code UTF16ToCurCP(const wchar_t *utf16, size_t utf16_len,
SmallVectorImpl<char> &utf8);
} // end namespace windows
} // end namespace sys
} // end namespace llvm.
} // end namespace wpi.
#endif

View File

@@ -11,9 +11,9 @@
//
//===----------------------------------------------------------------------===//
#include "llvm/raw_os_ostream.h"
#include "wpi/raw_os_ostream.h"
#include <ostream>
using namespace llvm;
using namespace wpi;
//===----------------------------------------------------------------------===//
// raw_os_ostream

View File

@@ -11,14 +11,14 @@
//
//===----------------------------------------------------------------------===//
#include "llvm/raw_ostream.h"
#include "llvm/SmallString.h"
#include "llvm/SmallVector.h"
#include "llvm/StringExtras.h"
#include "llvm/Compiler.h"
#include "llvm/Format.h"
#include "llvm/MathExtras.h"
#include "llvm/WindowsError.h"
#include "wpi/raw_ostream.h"
#include "wpi/SmallString.h"
#include "wpi/SmallVector.h"
#include "wpi/StringExtras.h"
#include "wpi/Compiler.h"
#include "wpi/Format.h"
#include "wpi/MathExtras.h"
#include "wpi/WindowsError.h"
#include <cctype>
#include <cerrno>
#include <sys/stat.h>
@@ -53,7 +53,7 @@
#include "Windows/WindowsSupport.h"
#endif
using namespace llvm;
using namespace wpi;
raw_ostream::~raw_ostream() {
// raw_ostream's subclasses should take care to flush the buffer
@@ -657,7 +657,7 @@ size_t raw_fd_ostream::preferred_buffer_size() const {
/// outs() - This returns a reference to a raw_ostream for standard output.
/// Use it like: outs() << "foo" << "bar";
raw_ostream &llvm::outs() {
raw_ostream &wpi::outs() {
// Set buffer settings to model stdout behavior. Delete the file descriptor
// when the program exits, forcing error detection. This means that if you
// ever call outs(), you can't open another raw_fd_ostream on stdout, as we'll
@@ -670,14 +670,14 @@ raw_ostream &llvm::outs() {
/// errs() - This returns a reference to a raw_ostream for standard error.
/// Use it like: errs() << "foo" << "bar";
raw_ostream &llvm::errs() {
raw_ostream &wpi::errs() {
// Set standard error to be unbuffered by default.
static raw_fd_ostream S(STDERR_FILENO, false, true);
return S;
}
/// nulls() - This returns a reference to a raw_ostream which discards output.
raw_ostream &llvm::nulls() {
raw_ostream &wpi::nulls() {
static raw_null_ostream S;
return S;
}