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,7 +7,7 @@
#include "Notifier.h" // NOLINT(build/include_order)
#include <llvm/raw_ostream.h>
#include <wpi/raw_ostream.h>
#include "TestBench.h"
#include "Timer.h"
@@ -23,21 +23,21 @@ void notifierHandler(void*) { notifierCounter++; }
* Test if the Wait function works
*/
TEST(NotifierTest, DISABLED_TestTimerNotifications) {
llvm::outs() << "NotifierTest...\n";
wpi::outs() << "NotifierTest...\n";
notifierCounter = 0;
llvm::outs() << "notifier(notifierHandler, nullptr)...\n";
wpi::outs() << "notifier(notifierHandler, nullptr)...\n";
Notifier notifier(notifierHandler, nullptr);
llvm::outs() << "Start Periodic...\n";
wpi::outs() << "Start Periodic...\n";
notifier.StartPeriodic(1.0);
llvm::outs() << "Wait...\n";
wpi::outs() << "Wait...\n";
Wait(10.5);
llvm::outs() << "...Wait\n";
wpi::outs() << "...Wait\n";
EXPECT_EQ(10u, notifierCounter)
<< "Received " << notifierCounter << " notifications in 10.5 seconds";
llvm::outs() << "Received " << notifierCounter
<< " notifications in 10.5 seconds";
wpi::outs() << "Received " << notifierCounter
<< " notifications in 10.5 seconds";
llvm::outs() << "...NotifierTest\n";
wpi::outs() << "...NotifierTest\n";
}

View File

@@ -8,7 +8,7 @@
#include <cstdlib>
#include <HAL/HAL.h>
#include <llvm/raw_ostream.h>
#include <wpi/raw_ostream.h>
#include "DriverStation.h"
#include "LiveWindow/LiveWindow.h"
@@ -30,7 +30,7 @@ class TestEnvironment : public testing::Environment {
m_alreadySetUp = true;
if (!HAL_Initialize(500, 0)) {
llvm::errs() << "FATAL ERROR: HAL could not be initialized\n";
wpi::errs() << "FATAL ERROR: HAL could not be initialized\n";
std::exit(-1);
}
@@ -43,20 +43,20 @@ class TestEnvironment : public testing::Environment {
HAL_ObserveUserProgramStarting();
LiveWindow::GetInstance()->SetEnabled(false);
llvm::outs() << "Started coms\n";
wpi::outs() << "Started coms\n";
int enableCounter = 0;
while (!DriverStation::GetInstance().IsEnabled()) {
if (enableCounter > 50) {
// Robot did not enable properly after 5 seconds.
// Force exit
llvm::errs() << " Failed to enable. Aborting\n";
wpi::errs() << " Failed to enable. Aborting\n";
std::terminate();
}
Wait(0.1);
llvm::outs() << "Waiting for enable: " << enableCounter++ << "\n";
wpi::outs() << "Waiting for enable: " << enableCounter++ << "\n";
}
}

View File

@@ -10,24 +10,23 @@
#include <stdint.h>
#include <HAL/cpp/fpga_clock.h>
#include <llvm/SmallString.h>
#include <llvm/SmallVector.h>
#include <llvm/raw_ostream.h>
#include <support/Logger.h>
#include "udpsockets/UDPClient.h"
#include <wpi/Logger.h>
#include <wpi/SmallString.h>
#include <wpi/SmallVector.h>
#include <wpi/UDPClient.h>
#include <wpi/raw_ostream.h>
static void LoggerFunc(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 << "DS: " << 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)
@@ -37,10 +36,10 @@ static void LoggerFunc(unsigned int level, const char* file, unsigned int line,
else
return;
oss << "DS: " << levelmsg << msg << " (" << file << ':' << line << ")\n";
llvm::errs() << oss.str();
wpi::errs() << oss.str();
}
static void generateEnabledDsPacket(llvm::SmallVectorImpl<uint8_t>& data,
static void generateEnabledDsPacket(wpi::SmallVectorImpl<uint8_t>& data,
uint16_t sendCount) {
data.clear();
data.push_back(sendCount >> 8);
@@ -63,7 +62,7 @@ void MockDS::start() {
auto timeout_time = hal::fpga_clock::now();
int initCount = 0;
uint16_t sendCount = 0;
llvm::SmallVector<uint8_t, 8> data;
wpi::SmallVector<uint8_t, 8> data;
while (m_active) {
// Keep 20ms intervals, and increase time to next interval
auto current = hal::fpga_clock::now();