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

@@ -7,24 +7,24 @@
#include "LoggerImpl.h"
#include <llvm/Path.h>
#include <llvm/SmallString.h>
#include <llvm/StringRef.h>
#include <llvm/raw_ostream.h>
#include <wpi/Path.h>
#include <wpi/SmallString.h>
#include <wpi/StringRef.h>
#include <wpi/raw_ostream.h>
using namespace nt;
static void DefaultLogger(unsigned int level, const char* file,
unsigned int line, const char* msg) {
llvm::SmallString<128> buf;
llvm::raw_svector_ostream oss(buf);
wpi::SmallString<128> buf;
wpi::raw_svector_ostream oss(buf);
if (level == 20) {
oss << "NT: " << msg << '\n';
llvm::errs() << oss.str();
wpi::errs() << oss.str();
return;
}
llvm::StringRef levelmsg;
wpi::StringRef levelmsg;
if (level >= 50)
levelmsg = "CRITICAL: ";
else if (level >= 40)
@@ -34,7 +34,7 @@ static void DefaultLogger(unsigned int level, const char* file,
else
return;
oss << "NT: " << levelmsg << msg << " (" << file << ':' << line << ")\n";
llvm::errs() << oss.str();
wpi::errs() << oss.str();
}
LoggerImpl::LoggerImpl(int inst) : m_inst(inst) {}
@@ -67,7 +67,7 @@ unsigned int LoggerImpl::GetMinLevel() {
void LoggerImpl::Log(unsigned int level, const char* file, unsigned int line,
const char* msg) {
// this is safe because it's null terminated and always the end
const char* filename = llvm::sys::path::filename(file).data();
const char* filename = wpi::sys::path::filename(file).data();
{
auto thr = GetThread();
if (!thr || thr->m_listeners.empty())