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

@@ -55,10 +55,10 @@
*
*/
#include "support/Base64.h"
#include "wpi/Base64.h"
#include "llvm/SmallVector.h"
#include "llvm/raw_ostream.h"
#include "wpi/SmallVector.h"
#include "wpi/raw_ostream.h"
namespace wpi {
@@ -80,7 +80,7 @@ static const unsigned char pr2six[256] = {
64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
64, 64, 64, 64, 64, 64, 64, 64, 64};
size_t Base64Decode(llvm::raw_ostream& os, llvm::StringRef encoded) {
size_t Base64Decode(raw_ostream& os, StringRef encoded) {
const unsigned char* end = encoded.bytes_begin();
while (pr2six[*end] <= 63 && end != encoded.bytes_end()) ++end;
size_t nprbytes = end - encoded.bytes_begin();
@@ -107,18 +107,18 @@ size_t Base64Decode(llvm::raw_ostream& os, llvm::StringRef encoded) {
return (end - encoded.bytes_begin()) + ((4 - nprbytes) & 3);
}
size_t Base64Decode(llvm::StringRef encoded, std::string* plain) {
size_t Base64Decode(StringRef encoded, std::string* plain) {
plain->resize(0);
llvm::raw_string_ostream os(*plain);
raw_string_ostream os(*plain);
size_t rv = Base64Decode(os, encoded);
os.flush();
return rv;
}
llvm::StringRef Base64Decode(llvm::StringRef encoded, size_t* num_read,
llvm::SmallVectorImpl<char>& buf) {
StringRef Base64Decode(StringRef encoded, size_t* num_read,
SmallVectorImpl<char>& buf) {
buf.clear();
llvm::raw_svector_ostream os(buf);
raw_svector_ostream os(buf);
*num_read = Base64Decode(os, encoded);
return os.str();
}
@@ -126,7 +126,7 @@ llvm::StringRef Base64Decode(llvm::StringRef encoded, size_t* num_read,
static const char basis_64[] =
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
void Base64Encode(llvm::raw_ostream& os, llvm::StringRef plain) {
void Base64Encode(raw_ostream& os, StringRef plain) {
if (plain.empty()) return;
size_t len = plain.size();
@@ -153,17 +153,16 @@ void Base64Encode(llvm::raw_ostream& os, llvm::StringRef plain) {
}
}
void Base64Encode(llvm::StringRef plain, std::string* encoded) {
void Base64Encode(StringRef plain, std::string* encoded) {
encoded->resize(0);
llvm::raw_string_ostream os(*encoded);
raw_string_ostream os(*encoded);
Base64Encode(os, plain);
os.flush();
}
llvm::StringRef Base64Encode(llvm::StringRef plain,
llvm::SmallVectorImpl<char>& buf) {
StringRef Base64Encode(StringRef plain, SmallVectorImpl<char>& buf) {
buf.clear();
llvm::raw_svector_ostream os(buf);
raw_svector_ostream os(buf);
Base64Encode(os, plain);
return os.str();
}

View File

@@ -5,22 +5,22 @@
/* the project. */
/*----------------------------------------------------------------------------*/
#include "support/HttpUtil.h"
#include "wpi/HttpUtil.h"
#include <cctype>
#include "llvm/STLExtras.h"
#include "llvm/StringExtras.h"
#include "llvm/raw_ostream.h"
#include "support/Base64.h"
#include "tcpsockets/TCPConnector.h"
#include "wpi/Base64.h"
#include "wpi/STLExtras.h"
#include "wpi/StringExtras.h"
#include "wpi/TCPConnector.h"
#include "wpi/raw_ostream.h"
namespace wpi {
llvm::StringRef UnescapeURI(const llvm::Twine& str,
llvm::SmallVectorImpl<char>& buf, bool* error) {
llvm::SmallString<128> strBuf;
llvm::StringRef strStr = str.toStringRef(strBuf);
StringRef UnescapeURI(const Twine& str, SmallVectorImpl<char>& buf,
bool* error) {
SmallString<128> strBuf;
StringRef strStr = str.toStringRef(strBuf);
buf.clear();
for (auto i = strStr.begin(), end = strStr.end(); i != end; ++i) {
// pass non-escaped characters to output
@@ -36,33 +36,33 @@ llvm::StringRef UnescapeURI(const llvm::Twine& str,
// are there enough characters left?
if (i + 2 >= end) {
*error = true;
return llvm::StringRef{};
return StringRef{};
}
// replace %xx with the corresponding character
unsigned val1 = llvm::hexDigitValue(*++i);
unsigned val1 = hexDigitValue(*++i);
if (val1 == -1U) {
*error = true;
return llvm::StringRef{};
return StringRef{};
}
unsigned val2 = llvm::hexDigitValue(*++i);
unsigned val2 = hexDigitValue(*++i);
if (val2 == -1U) {
*error = true;
return llvm::StringRef{};
return StringRef{};
}
buf.push_back((val1 << 4) | val2);
}
*error = false;
return llvm::StringRef{buf.data(), buf.size()};
return StringRef{buf.data(), buf.size()};
}
llvm::StringRef EscapeURI(const llvm::Twine& str,
llvm::SmallVectorImpl<char>& buf, bool spacePlus) {
StringRef EscapeURI(const Twine& str, SmallVectorImpl<char>& buf,
bool spacePlus) {
static const char* const hexLut = "0123456789ABCDEF";
llvm::SmallString<128> strBuf;
llvm::StringRef strStr = str.toStringRef(strBuf);
SmallString<128> strBuf;
StringRef strStr = str.toStringRef(strBuf);
buf.clear();
for (auto i = strStr.begin(), end = strStr.end(); i != end; ++i) {
// pass unreserved characters to output
@@ -83,19 +83,19 @@ llvm::StringRef EscapeURI(const llvm::Twine& str,
buf.push_back(hexLut[(*i) & 0x0f]);
}
return llvm::StringRef{buf.data(), buf.size()};
return StringRef{buf.data(), buf.size()};
}
bool ParseHttpHeaders(raw_istream& is, llvm::SmallVectorImpl<char>* contentType,
llvm::SmallVectorImpl<char>* contentLength) {
bool ParseHttpHeaders(raw_istream& is, SmallVectorImpl<char>* contentType,
SmallVectorImpl<char>* contentLength) {
if (contentType) contentType->clear();
if (contentLength) contentLength->clear();
bool inContentType = false;
bool inContentLength = false;
llvm::SmallString<64> lineBuf;
SmallString<64> lineBuf;
for (;;) {
llvm::StringRef line = is.getline(lineBuf, 1024).rtrim();
StringRef line = is.getline(lineBuf, 1024).rtrim();
if (is.has_error()) return false;
if (line.empty()) return true; // empty line signals end of headers
@@ -103,7 +103,7 @@ bool ParseHttpHeaders(raw_istream& is, llvm::SmallVectorImpl<char>* contentType,
if (!std::isspace(line[0])) {
inContentType = false;
inContentLength = false;
llvm::StringRef field;
StringRef field;
std::tie(field, line) = line.split(':');
field = field.rtrim();
if (field.equals_lower("content-type"))
@@ -125,9 +125,9 @@ bool ParseHttpHeaders(raw_istream& is, llvm::SmallVectorImpl<char>* contentType,
}
}
bool FindMultipartBoundary(raw_istream& is, llvm::StringRef boundary,
bool FindMultipartBoundary(raw_istream& is, StringRef boundary,
std::string* saveBuf) {
llvm::SmallString<64> searchBuf;
SmallString<64> searchBuf;
searchBuf.resize(boundary.size() + 2);
size_t searchPos = 0;
@@ -157,7 +157,7 @@ bool FindMultipartBoundary(raw_istream& is, llvm::StringRef boundary,
// Fast-scan for '-'
size_t pos = searchBuf.find('-', searchBuf[0] == '-' ? 1 : 0);
if (pos == llvm::StringRef::npos) {
if (pos == StringRef::npos) {
if (saveBuf) saveBuf->append(searchBuf.data(), searchBuf.size());
} else {
if (saveBuf) saveBuf->append(searchBuf.data(), pos);
@@ -170,14 +170,14 @@ bool FindMultipartBoundary(raw_istream& is, llvm::StringRef boundary,
}
}
HttpLocation::HttpLocation(const llvm::Twine& url_, bool* error,
HttpLocation::HttpLocation(const Twine& url_, bool* error,
std::string* errorMsg)
: url{url_.str()} {
// Split apart into components
llvm::StringRef query{url};
StringRef query{url};
// scheme:
llvm::StringRef scheme;
StringRef scheme;
std::tie(scheme, query) = query.split(':');
if (!scheme.equals_lower("http")) {
*errorMsg = "only supports http URLs";
@@ -194,38 +194,38 @@ HttpLocation::HttpLocation(const llvm::Twine& url_, bool* error,
query = query.drop_front(2);
// user:password@host:port/
llvm::StringRef authority;
StringRef authority;
std::tie(authority, query) = query.split('/');
llvm::StringRef userpass, hostport;
StringRef userpass, hostport;
std::tie(userpass, hostport) = authority.split('@');
// split leaves the RHS empty if the split char isn't present...
if (hostport.empty()) {
hostport = userpass;
userpass = llvm::StringRef{};
userpass = StringRef{};
}
if (!userpass.empty()) {
llvm::StringRef rawUser, rawPassword;
StringRef rawUser, rawPassword;
std::tie(rawUser, rawPassword) = userpass.split(':');
llvm::SmallString<64> userBuf, passBuf;
SmallString<64> userBuf, passBuf;
user = UnescapeURI(rawUser, userBuf, error);
if (*error) {
llvm::raw_string_ostream oss(*errorMsg);
raw_string_ostream oss(*errorMsg);
oss << "could not unescape user \"" << rawUser << "\"";
oss.flush();
return;
}
password = UnescapeURI(rawPassword, passBuf, error);
if (*error) {
llvm::raw_string_ostream oss(*errorMsg);
raw_string_ostream oss(*errorMsg);
oss << "could not unescape password \"" << rawPassword << "\"";
oss.flush();
return;
}
}
llvm::StringRef portStr;
StringRef portStr;
std::tie(host, portStr) = hostport.rsplit(':');
if (host.empty()) {
*errorMsg = "host is empty";
@@ -235,7 +235,7 @@ HttpLocation::HttpLocation(const llvm::Twine& url_, bool* error,
if (portStr.empty()) {
port = 80;
} else if (portStr.getAsInteger(10, port)) {
llvm::raw_string_ostream oss(*errorMsg);
raw_string_ostream oss(*errorMsg);
oss << "port \"" << portStr << "\" is not an integer";
oss.flush();
*error = true;
@@ -249,27 +249,27 @@ HttpLocation::HttpLocation(const llvm::Twine& url_, bool* error,
// Split query string into parameters
while (!query.empty()) {
// split out next param and value
llvm::StringRef rawParam, rawValue;
StringRef rawParam, rawValue;
std::tie(rawParam, query) = query.split('&');
if (rawParam.empty()) continue; // ignore "&&"
std::tie(rawParam, rawValue) = rawParam.split('=');
// unescape param
*error = false;
llvm::SmallString<64> paramBuf;
llvm::StringRef param = UnescapeURI(rawParam, paramBuf, error);
SmallString<64> paramBuf;
StringRef param = UnescapeURI(rawParam, paramBuf, error);
if (*error) {
llvm::raw_string_ostream oss(*errorMsg);
raw_string_ostream oss(*errorMsg);
oss << "could not unescape parameter \"" << rawParam << "\"";
oss.flush();
return;
}
// unescape value
llvm::SmallString<64> valueBuf;
llvm::StringRef value = UnescapeURI(rawValue, valueBuf, error);
SmallString<64> valueBuf;
StringRef value = UnescapeURI(rawValue, valueBuf, error);
if (*error) {
llvm::raw_string_ostream oss(*errorMsg);
raw_string_ostream oss(*errorMsg);
oss << "could not unescape value \"" << rawValue << "\"";
oss.flush();
return;
@@ -283,7 +283,7 @@ HttpLocation::HttpLocation(const llvm::Twine& url_, bool* error,
void HttpRequest::SetAuth(const HttpLocation& loc) {
if (!loc.user.empty()) {
llvm::SmallString<64> userpass;
SmallString<64> userpass;
userpass += loc.user;
userpass += ':';
userpass += loc.password;
@@ -302,15 +302,15 @@ bool HttpConnection::Handshake(const HttpRequest& request,
os.flush();
// read first line of response
llvm::SmallString<64> lineBuf;
llvm::StringRef line = is.getline(lineBuf, 1024).rtrim();
SmallString<64> lineBuf;
StringRef line = is.getline(lineBuf, 1024).rtrim();
if (is.has_error()) {
*warnMsg = "disconnected before response";
return false;
}
// see if we got a HTTP 200 response
llvm::StringRef httpver, code, codeText;
StringRef httpver, code, codeText;
std::tie(httpver, line) = line.split(' ');
std::tie(code, codeText) = line.split(' ');
if (!httpver.startswith("HTTP")) {
@@ -318,7 +318,7 @@ bool HttpConnection::Handshake(const HttpRequest& request,
return false;
}
if (code != "200") {
llvm::raw_string_ostream oss(*warnMsg);
raw_string_ostream oss(*warnMsg);
oss << "received " << code << " " << codeText << " response";
oss.flush();
return false;

View File

@@ -5,7 +5,7 @@
/* the project. */
/*----------------------------------------------------------------------------*/
#include "tcpsockets/SocketError.h"
#include "wpi/SocketError.h"
#ifdef _WIN32
#include <winsock2.h>

View File

@@ -21,7 +21,7 @@
limitations under the License.
*/
#include "tcpsockets/TCPAcceptor.h"
#include "wpi/TCPAcceptor.h"
#include <cstdio>
#include <cstring>
@@ -37,9 +37,9 @@
#include <unistd.h>
#endif
#include "llvm/SmallString.h"
#include "support/Logger.h"
#include "tcpsockets/SocketError.h"
#include "wpi/Logger.h"
#include "wpi/SmallString.h"
#include "wpi/SocketError.h"
using namespace wpi;
@@ -85,7 +85,7 @@ int TCPAcceptor::start() {
address.sin_family = PF_INET;
if (m_address.size() > 0) {
#ifdef _WIN32
llvm::SmallString<128> addr_copy(m_address);
SmallString<128> addr_copy(m_address);
addr_copy.push_back('\0');
int res = InetPton(PF_INET, addr_copy.data(), &(address.sin_addr));
#else
@@ -139,7 +139,7 @@ void TCPAcceptor::shutdown() {
std::memset(&address, 0, sizeof(address));
address.sin_family = PF_INET;
llvm::SmallString<128> addr_copy;
SmallString<128> addr_copy;
if (m_address.size() > 0)
addr_copy = m_address;
else

View File

@@ -21,7 +21,7 @@
limitations under the License
*/
#include "tcpsockets/TCPConnector.h"
#include "wpi/TCPConnector.h"
#include <fcntl.h>
@@ -40,10 +40,10 @@
#include <unistd.h>
#endif
#include "llvm/SmallString.h"
#include "support/Logger.h"
#include "tcpsockets/SocketError.h"
#include "tcpsockets/TCPStream.h"
#include "wpi/Logger.h"
#include "wpi/SmallString.h"
#include "wpi/SocketError.h"
#include "wpi/TCPStream.h"
using namespace wpi;
@@ -89,7 +89,7 @@ std::unique_ptr<NetworkStream> TCPConnector::connect(const char* server,
address.sin_family = AF_INET;
if (ResolveHostName(server, &(address.sin_addr)) != 0) {
#ifdef _WIN32
llvm::SmallString<128> addr_copy(server);
SmallString<128> addr_copy(server);
addr_copy.push_back('\0');
int res = InetPton(PF_INET, addr_copy.data(), &(address.sin_addr));
#else

View File

@@ -5,16 +5,16 @@
/* the project. */
/*----------------------------------------------------------------------------*/
#include "tcpsockets/TCPConnector.h" // NOLINT(build/include_order)
#include "wpi/TCPConnector.h" // NOLINT(build/include_order)
#include <atomic>
#include <chrono>
#include <thread>
#include <tuple>
#include "llvm/SmallSet.h"
#include "support/condition_variable.h"
#include "support/mutex.h"
#include "wpi/SmallSet.h"
#include "wpi/condition_variable.h"
#include "wpi/mutex.h"
using namespace wpi;
@@ -27,7 +27,7 @@ using namespace wpi;
#endif
std::unique_ptr<NetworkStream> TCPConnector::connect_parallel(
llvm::ArrayRef<std::pair<const char*, int>> servers, Logger& logger,
ArrayRef<std::pair<const char*, int>> servers, Logger& logger,
int timeout) {
if (servers.empty()) return nullptr;
@@ -35,9 +35,9 @@ std::unique_ptr<NetworkStream> TCPConnector::connect_parallel(
struct GlobalState {
wpi::mutex mtx;
#ifdef HAVE_THREAD_LOCAL
llvm::SmallSet<std::pair<std::string, int>, 16> active;
SmallSet<std::pair<std::string, int>, 16> active;
#else
llvm::SmallSet<std::tuple<std::thread::id, std::string, int>, 16> active;
SmallSet<std::tuple<std::thread::id, std::string, int>, 16> active;
#endif
};
#ifdef HAVE_THREAD_LOCAL

View File

@@ -21,7 +21,7 @@
limitations under the License.
*/
#include "tcpsockets/TCPStream.h"
#include "wpi/TCPStream.h"
#include <fcntl.h>
@@ -162,7 +162,7 @@ void TCPStream::close() {
m_sd = -1;
}
llvm::StringRef TCPStream::getPeerIP() const { return m_peerIP; }
StringRef TCPStream::getPeerIP() const { return m_peerIP; }
int TCPStream::getPeerPort() const { return m_peerPort; }

View File

@@ -5,7 +5,7 @@
/* the project. */
/*----------------------------------------------------------------------------*/
#include "udpsockets/UDPClient.h"
#include "wpi/UDPClient.h"
#ifdef _WIN32
#include <WinSock2.h>
@@ -18,14 +18,14 @@
#include <unistd.h>
#endif
#include "support/Logger.h"
#include "tcpsockets/SocketError.h"
#include "wpi/Logger.h"
#include "wpi/SocketError.h"
using namespace wpi;
UDPClient::UDPClient(Logger& logger) : UDPClient("", logger) {}
UDPClient::UDPClient(llvm::StringRef address, Logger& logger)
UDPClient::UDPClient(StringRef address, Logger& logger)
: m_lsd(0), m_address(address), m_logger(logger) {}
UDPClient::UDPClient(UDPClient&& other)
@@ -72,7 +72,7 @@ int UDPClient::start() {
addr.sin_family = AF_INET;
if (m_address.size() > 0) {
#ifdef _WIN32
llvm::SmallString<128> addr_copy(m_address);
SmallString<128> addr_copy(m_address);
addr_copy.push_back('\0');
int res = InetPton(PF_INET, addr_copy.data(), &(addr.sin_addr));
#else
@@ -109,14 +109,13 @@ void UDPClient::shutdown() {
}
}
int UDPClient::send(llvm::ArrayRef<uint8_t> data, llvm::StringRef server,
int port) {
int UDPClient::send(ArrayRef<uint8_t> data, StringRef server, int port) {
// server must be a resolvable IP address
struct sockaddr_in addr;
std::memset(&addr, 0, sizeof(addr));
addr.sin_family = AF_INET;
if (server.size() > 0) {
llvm::SmallVector<char, 128> addr_store;
SmallVector<char, 128> addr_store;
auto remoteAddr = server.c_str(addr_store);
#ifdef _WIN32
int res = InetPton(AF_INET, remoteAddr, &(addr.sin_addr));
@@ -140,13 +139,13 @@ int UDPClient::send(llvm::ArrayRef<uint8_t> data, llvm::StringRef server,
return result;
}
int UDPClient::send(llvm::StringRef data, llvm::StringRef server, int port) {
int UDPClient::send(StringRef data, StringRef server, int port) {
// server must be a resolvable IP address
struct sockaddr_in addr;
std::memset(&addr, 0, sizeof(addr));
addr.sin_family = AF_INET;
if (server.size() > 0) {
llvm::SmallVector<char, 128> addr_store;
SmallVector<char, 128> addr_store;
auto remoteAddr = server.c_str(addr_store);
#ifdef _WIN32
int res = InetPton(AF_INET, remoteAddr, &(addr.sin_addr));

View File

@@ -5,7 +5,7 @@
/* the project. */
/*----------------------------------------------------------------------------*/
#include "support/hostname.h"
#include "wpi/hostname.h"
#ifdef _WIN32
#include <Winsock2.h>
@@ -16,8 +16,8 @@
#include <string>
#include "llvm/SmallVector.h"
#include "llvm/StringRef.h"
#include "wpi/SmallVector.h"
#include "wpi/StringRef.h"
#ifdef _WIN32
struct WSAHelper {
@@ -51,15 +51,15 @@ std::string GetHostname() {
return name;
}
llvm::StringRef GetHostname(llvm::SmallVectorImpl<char>& name) {
StringRef GetHostname(SmallVectorImpl<char>& name) {
// Use a tmp array to not require the SmallVector to be too large.
char tmpName[256];
if (!GetHostnameImpl(tmpName, sizeof(tmpName))) {
return llvm::StringRef{};
return StringRef{};
}
name.clear();
name.append(tmpName, tmpName + std::strlen(tmpName) + 1);
return llvm::StringRef{name.data(), name.size(), true};
return StringRef{name.data(), name.size(), true};
}
} // namespace wpi

View File

@@ -32,7 +32,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
#define WPI_JSON_IMPLEMENTATION
#include "support/json.h"
#include "wpi/json.h"
using namespace wpi;
@@ -141,7 +141,7 @@ json::json_value::json_value(value_t t)
}
}
json::json_value::json_value(llvm::StringRef value)
json::json_value::json_value(StringRef value)
{
string = create<std::string>(value);
}
@@ -727,7 +727,7 @@ void json::push_back(const json& val)
m_value.array->push_back(val);
}
void json::push_back(const std::pair<llvm::StringRef, json>& val)
void json::push_back(const std::pair<StringRef, json>& val)
{
// push_back only works for null objects or objects
if (!(is_null() || is_object()))
@@ -752,7 +752,7 @@ void json::push_back(std::initializer_list<json> init)
if (is_object() && init.size() == 2 && init.begin()->is_string())
{
const std::string key = *init.begin();
push_back(std::pair<llvm::StringRef, json>(key, *(init.begin() + 1)));
push_back(std::pair<StringRef, json>(key, *(init.begin() + 1)));
}
else
{
@@ -802,7 +802,7 @@ json::const_reference json::at(size_type idx) const
}
}
json::reference json::at(llvm::StringRef key)
json::reference json::at(StringRef key)
{
// at only works for objects
if (is_object())
@@ -820,7 +820,7 @@ json::reference json::at(llvm::StringRef key)
}
}
json::const_reference json::at(llvm::StringRef key) const
json::const_reference json::at(StringRef key) const
{
// at only works for objects
if (is_object())
@@ -877,7 +877,7 @@ json::const_reference json::operator[](size_type idx) const
JSON_THROW(type_error::create(305, "cannot use operator[] with " + type_name()));
}
json::reference json::operator[](llvm::StringRef key)
json::reference json::operator[](StringRef key)
{
// implicitly convert null value to an empty object
if (is_null())
@@ -896,7 +896,7 @@ json::reference json::operator[](llvm::StringRef key)
JSON_THROW(type_error::create(305, "cannot use operator[] with " + type_name()));
}
json::const_reference json::operator[](llvm::StringRef key) const
json::const_reference json::operator[](StringRef key) const
{
// const operator[] only works for objects
if (is_object())
@@ -960,7 +960,7 @@ json::const_reference json::back() const
}
}
json::size_type json::erase(llvm::StringRef key)
json::size_type json::erase(StringRef key)
{
// this erase only works for objects
if (is_object())
@@ -989,7 +989,7 @@ void json::erase(const size_type idx)
}
}
json::iterator json::find(llvm::StringRef key)
json::iterator json::find(StringRef key)
{
auto result = end();
@@ -1001,7 +1001,7 @@ json::iterator json::find(llvm::StringRef key)
return result;
}
json::const_iterator json::find(llvm::StringRef key) const
json::const_iterator json::find(StringRef key) const
{
auto result = cend();
@@ -1173,8 +1173,8 @@ std::size_t hash<wpi::json>::operator()(const wpi::json& j) const
{
// a naive hashing via the string representation
const auto& h = hash<std::string>();
llvm::SmallVector<char, 128> buf;
llvm::raw_svector_ostream os(buf);
SmallVector<char, 128> buf;
raw_svector_ostream os(buf);
j.dump(os);
return h(os.str());
}

View File

@@ -32,13 +32,13 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
#define WPI_JSON_IMPLEMENTATION
#include "support/json.h"
#include "wpi/json.h"
#include <array>
#include "llvm/Format.h"
#include "llvm/raw_ostream.h"
#include "support/raw_istream.h"
#include "wpi/Format.h"
#include "wpi/raw_istream.h"
#include "wpi/raw_ostream.h"
using namespace wpi;
@@ -627,9 +627,9 @@ json binary_reader::parse_cbor(bool get_char)
default: // anything else (0xFF is handled inside the other types)
{
std::string s;
llvm::raw_string_ostream ss(s);
raw_string_ostream ss(s);
ss << "error reading CBOR; last byte: ";
ss << llvm::format_hex(current, 2);
ss << format_hex(current, 2);
JSON_THROW(json::parse_error::create(112, chars_read, ss.str()));
}
}
@@ -709,9 +709,9 @@ std::string binary_reader::get_cbor_string()
default:
{
std::string s;
llvm::raw_string_ostream ss(s);
raw_string_ostream ss(s);
ss << "expected a CBOR string; last byte: ";
ss << llvm::format_hex(current, 2);
ss << format_hex(current, 2);
JSON_THROW(json::parse_error::create(113, chars_read, ss.str()));
}
}
@@ -1113,9 +1113,9 @@ json binary_reader::parse_msgpack()
default: // anything else
{
std::string s;
llvm::raw_string_ostream ss(s);
raw_string_ostream ss(s);
ss << "error reading MessagePack; last byte: ";
ss << llvm::format_hex(current, 2);
ss << format_hex(current, 2);
JSON_THROW(json::parse_error::create(112, chars_read, ss.str()));
}
}
@@ -1186,9 +1186,9 @@ std::string binary_reader::get_msgpack_string()
default:
{
std::string s;
llvm::raw_string_ostream ss(s);
raw_string_ostream ss(s);
ss << "expected a MessagePack string; last byte: ";
ss << llvm::format_hex(current, 2);
ss << format_hex(current, 2);
JSON_THROW(json::parse_error::create(113, chars_read, ss.str()));
}
}
@@ -1212,7 +1212,7 @@ json json::from_cbor(wpi::raw_istream& is)
return br.parse_cbor();
}
json json::from_cbor(llvm::StringRef s)
json json::from_cbor(StringRef s)
{
wpi::raw_mem_istream is(s.data(), s.size());
binary_reader br(is);
@@ -1225,7 +1225,7 @@ json json::from_msgpack(wpi::raw_istream& is)
return br.parse_msgpack();
}
json json::from_msgpack(llvm::StringRef s)
json json::from_msgpack(StringRef s)
{
wpi::raw_mem_istream is(s.data(), s.size());
binary_reader br(is);

View File

@@ -32,16 +32,16 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
#define WPI_JSON_IMPLEMENTATION
#include "support/json.h"
#include "wpi/json.h"
#include <array>
#include <clocale> // lconv, localeconv
#include <locale> // locale
#include <numeric> // accumulate
#include "llvm/raw_ostream.h"
#include "llvm/SmallString.h"
#include "llvm/StringExtras.h"
#include "wpi/SmallString.h"
#include "wpi/StringExtras.h"
#include "wpi/raw_ostream.h"
using namespace wpi;
@@ -56,7 +56,7 @@ class json::binary_writer
@param[in] adapter output adapter to write to
*/
explicit binary_writer(llvm::raw_ostream& s)
explicit binary_writer(raw_ostream& s)
: is_little_endian(little_endianess()), o(s)
{
}
@@ -88,12 +88,12 @@ class json::binary_writer
/*!
@brief[in] str string to serialize
*/
void write_cbor_string(llvm::StringRef str);
void write_cbor_string(StringRef str);
/*!
@brief[in] str string to serialize
*/
void write_msgpack_string(llvm::StringRef str);
void write_msgpack_string(StringRef str);
/*
@brief write a number to output input
@@ -132,7 +132,7 @@ class json::binary_writer
const bool is_little_endian = true;
/// the output
llvm::raw_ostream& o;
raw_ostream& o;
};
void json::binary_writer::write_cbor(const json& j)
@@ -345,7 +345,7 @@ void json::binary_writer::write_cbor(const json& j)
}
}
void json::binary_writer::write_cbor_string(llvm::StringRef str)
void json::binary_writer::write_cbor_string(StringRef str)
{
// step 1: write control byte and the string length
const auto N = str.size();
@@ -587,7 +587,7 @@ void json::binary_writer::write_msgpack(const json& j)
}
}
void json::binary_writer::write_msgpack_string(llvm::StringRef str)
void json::binary_writer::write_msgpack_string(StringRef str)
{
// step 1: write control byte and the string length
const auto N = str.size();
@@ -619,15 +619,15 @@ void json::binary_writer::write_msgpack_string(llvm::StringRef str)
o << str;
}
void json::to_cbor(llvm::raw_ostream& os, const json& j)
void json::to_cbor(raw_ostream& os, const json& j)
{
binary_writer bw(os);
bw.write_cbor(j);
}
llvm::StringRef json::to_cbor(const json& j, llvm::SmallVectorImpl<char> buf)
StringRef json::to_cbor(const json& j, SmallVectorImpl<char> buf)
{
llvm::raw_svector_ostream os(buf);
raw_svector_ostream os(buf);
binary_writer bw(os);
bw.write_cbor(j);
return os.str();
@@ -636,22 +636,22 @@ llvm::StringRef json::to_cbor(const json& j, llvm::SmallVectorImpl<char> buf)
std::string json::to_cbor(const json& j)
{
std::string s;
llvm::raw_string_ostream os(s);
raw_string_ostream os(s);
binary_writer bw(os);
bw.write_cbor(j);
os.flush();
return s;
}
void json::to_msgpack(llvm::raw_ostream& os, const json& j)
void json::to_msgpack(raw_ostream& os, const json& j)
{
binary_writer bw(os);
bw.write_msgpack(j);
}
llvm::StringRef json::to_msgpack(const json& j, llvm::SmallVectorImpl<char> buf)
StringRef json::to_msgpack(const json& j, SmallVectorImpl<char> buf)
{
llvm::raw_svector_ostream os(buf);
raw_svector_ostream os(buf);
binary_writer bw(os);
bw.write_msgpack(j);
return os.str();
@@ -660,7 +660,7 @@ llvm::StringRef json::to_msgpack(const json& j, llvm::SmallVectorImpl<char> buf)
std::string json::to_msgpack(const json& j)
{
std::string s;
llvm::raw_string_ostream os(s);
raw_string_ostream os(s);
binary_writer bw(os);
bw.write_msgpack(j);
os.flush();

View File

@@ -32,16 +32,16 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
#define WPI_JSON_IMPLEMENTATION
#include "support/json.h"
#include "wpi/json.h"
#include <array>
#include <clocale> // lconv, localeconv
#include <locale> // locale
#include "llvm/Format.h"
#include "llvm/raw_ostream.h"
#include "llvm/SmallString.h"
#include "support/raw_istream.h"
#include "wpi/Format.h"
#include "wpi/SmallString.h"
#include "wpi/raw_istream.h"
#include "wpi/raw_ostream.h"
using namespace wpi;
@@ -259,7 +259,7 @@ class lexer
}
/// return string value
llvm::StringRef get_string()
StringRef get_string()
{
return yytext.str();
}
@@ -303,10 +303,10 @@ class lexer
size_t chars_read = 0;
/// buffer for raw byte sequence of the current token
llvm::SmallString<128> token_string;
SmallString<128> token_string;
/// buffer for variable-length tokens (numbers, strings)
llvm::SmallString<128> yytext;
SmallString<128> yytext;
/// a description of occurred lexer errors
std::string error_message = "";
@@ -616,8 +616,8 @@ int lexer::get_codepoint()
std::string lexer::codepoint_to_string(int codepoint)
{
std::string s;
llvm::raw_string_ostream ss(s);
ss << "U+" << llvm::format_hex_no_prefix(codepoint, 4, true);
raw_string_ostream ss(s);
ss << "U+" << format_hex_no_prefix(codepoint, 4, true);
return ss.str();
}
@@ -2073,7 +2073,7 @@ void json::parser::unexpect(lexer::token_type t) const
}
}
json json::parse(llvm::StringRef s, const parser_callback_t cb)
json json::parse(StringRef s, const parser_callback_t cb)
{
wpi::raw_mem_istream is(s.data(), s.size());
return parser(is, cb).parse(true);

View File

@@ -32,7 +32,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
#define WPI_JSON_IMPLEMENTATION
#include "support/json.h"
#include "wpi/json.h"
#include <algorithm>
#include <numeric> // accumulate
@@ -505,7 +505,7 @@ json json::json_pointer::unflatten(const json& value)
}
// we need to iterate over the object values in sorted key order
llvm::SmallVector<llvm::StringMapConstIterator<json>, 64> sorted;
SmallVector<StringMapConstIterator<json>, 64> sorted;
for (auto i = value.m_value.object->begin(),
end = value.m_value.object->end(); i != end; ++i)
{
@@ -516,8 +516,8 @@ json json::json_pointer::unflatten(const json& value)
sorted.push_back(i);
}
std::sort(sorted.begin(), sorted.end(),
[](const llvm::StringMapConstIterator<json>& a,
const llvm::StringMapConstIterator<json>& b) {
[](const StringMapConstIterator<json>& a,
const StringMapConstIterator<json>& b) {
return a->getKey() < b->getKey();
});

View File

@@ -32,10 +32,10 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
#define WPI_JSON_IMPLEMENTATION
#include "support/json.h"
#include "wpi/json.h"
#include "llvm/SmallString.h"
#include "llvm/StringExtras.h"
#include "wpi/SmallString.h"
#include "wpi/StringExtras.h"
#include "json_serializer.h"
@@ -221,7 +221,7 @@ void json::serializer::dump(const json& val,
}
}
void json::serializer::dump_escaped(llvm::StringRef s) const
void json::serializer::dump_escaped(StringRef s) const
{
for (const auto& c : s)
{
@@ -307,8 +307,8 @@ void json::serializer::dump_escaped(llvm::StringRef s) const
{
// print character c as \uxxxx
o << "\\u00";
o << llvm::hexdigit((c >> 4) & 0xf, true);
o << llvm::hexdigit((c >> 0) & 0xf, true);
o << hexdigit((c >> 4) & 0xf, true);
o << hexdigit((c >> 0) & 0xf, true);
break;
}
@@ -349,7 +349,7 @@ void json::serializer::dump_float(double x)
static constexpr auto d = std::numeric_limits<double>::digits10;
// the actual conversion
llvm::SmallString<64> number_buffer;
SmallString<64> number_buffer;
number_buffer.resize(64);
std::ptrdiff_t len = snprintf(number_buffer.data(), number_buffer.size(),
"%.*g", d, x);
@@ -401,7 +401,7 @@ void json::serializer::dump_float(double x)
namespace wpi {
llvm::raw_ostream& operator<<(llvm::raw_ostream& o, const json& j)
raw_ostream& operator<<(raw_ostream& o, const json& j)
{
j.dump(o, 0);
return o;
@@ -412,13 +412,13 @@ llvm::raw_ostream& operator<<(llvm::raw_ostream& o, const json& j)
std::string json::dump(int indent) const
{
std::string s;
llvm::raw_string_ostream os(s);
raw_string_ostream os(s);
dump(os, indent);
os.flush();
return s;
}
void json::dump(llvm::raw_ostream& os, int indent) const
void json::dump(raw_ostream& os, int indent) const
{
serializer s(os);

View File

@@ -31,12 +31,12 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
#include "support/json.h"
#include "wpi/json.h"
#include <clocale> // lconv, localeconv
#include <locale> // locale
#include "llvm/raw_ostream.h"
#include "wpi/raw_ostream.h"
namespace wpi {
@@ -53,7 +53,7 @@ class json::serializer
@param[in] s output stream to serialize to
@param[in] ichar indentation character to use
*/
explicit serializer(llvm::raw_ostream& s)
explicit serializer(raw_ostream& s)
: o(s), loc(std::localeconv()),
thousands_sep(!loc->thousands_sep ? '\0' : loc->thousands_sep[0]),
decimal_point(!loc->decimal_point ? '\0' : loc->decimal_point[0])
@@ -93,7 +93,7 @@ class json::serializer
@complexity Linear in the length of string @a s.
*/
void dump_escaped(llvm::StringRef s) const;
void dump_escaped(StringRef s) const;
/*!
@brief dump a floating-point number
@@ -107,7 +107,7 @@ class json::serializer
private:
/// the output of the serializer
llvm::raw_ostream& o;
raw_ostream& o;
/// the locale
const std::lconv* loc = nullptr;

View File

@@ -5,9 +5,9 @@
/* the project. */
/*----------------------------------------------------------------------------*/
#include "support/leb128.h"
#include "wpi/leb128.h"
#include "support/raw_istream.h"
#include "wpi/raw_istream.h"
namespace wpi {
@@ -39,7 +39,7 @@ uint64_t SizeUleb128(uint64_t val) {
* encodings refer to section "7.6 - Variable Length Data". Return
* the number of bytes written.
*/
uint64_t WriteUleb128(llvm::SmallVectorImpl<char>& dest, uint64_t val) {
uint64_t WriteUleb128(SmallVectorImpl<char>& dest, uint64_t val) {
size_t count = 0;
do {

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;
}

View File

@@ -5,7 +5,7 @@
/* the project. */
/*----------------------------------------------------------------------------*/
#include "support/raw_istream.h"
#include "wpi/raw_istream.h"
#ifdef _WIN32
#include <io.h>
@@ -16,9 +16,9 @@
#include <cstdlib>
#include <cstring>
#include "llvm/FileSystem.h"
#include "llvm/SmallVector.h"
#include "llvm/StringRef.h"
#include "wpi/FileSystem.h"
#include "wpi/SmallVector.h"
#include "wpi/StringRef.h"
#if defined(_MSC_VER)
#ifndef STDIN_FILENO
@@ -34,21 +34,20 @@
using namespace wpi;
llvm::StringRef raw_istream::getline(llvm::SmallVectorImpl<char>& buf,
int maxLen) {
StringRef raw_istream::getline(SmallVectorImpl<char>& buf, int maxLen) {
buf.clear();
for (int i = 0; i < maxLen; ++i) {
char c;
read(c);
if (has_error()) return llvm::StringRef{buf.data(), buf.size()};
if (has_error()) return StringRef{buf.data(), buf.size()};
if (c == '\r') continue;
buf.push_back(c);
if (c == '\n') break;
}
return llvm::StringRef{buf.data(), buf.size()};
return StringRef{buf.data(), buf.size()};
}
raw_mem_istream::raw_mem_istream(llvm::StringRef mem)
raw_mem_istream::raw_mem_istream(StringRef mem)
: raw_mem_istream(mem.data(), mem.size()) {}
void raw_mem_istream::close() {}
@@ -65,7 +64,7 @@ void raw_mem_istream::read_impl(void* data, size_t len) {
m_left -= len;
}
static int getFD(const llvm::Twine& Filename, std::error_code& EC) {
static int getFD(const Twine& Filename, std::error_code& EC) {
// Handle "-" as stdin. Note that when we do this, we consider ourself
// the owner of stdin. This means that we can do things like close the
// file descriptor when we're done and set the "binary" flag globally.
@@ -76,14 +75,14 @@ static int getFD(const llvm::Twine& Filename, std::error_code& EC) {
int FD;
EC = llvm::sys::fs::openFileForRead(Filename, FD);
EC = sys::fs::openFileForRead(Filename, FD);
if (EC) return -1;
EC = std::error_code();
return FD;
}
raw_fd_istream::raw_fd_istream(const llvm::Twine& filename, std::error_code& ec,
raw_fd_istream::raw_fd_istream(const Twine& filename, std::error_code& ec,
size_t bufSize)
: raw_fd_istream(getFD(filename, ec), true, bufSize) {}

View File

@@ -5,9 +5,9 @@
/* the project. */
/*----------------------------------------------------------------------------*/
#include "support/raw_socket_istream.h"
#include "wpi/raw_socket_istream.h"
#include "tcpsockets/NetworkStream.h"
#include "wpi/NetworkStream.h"
using namespace wpi;

View File

@@ -5,9 +5,9 @@
/* the project. */
/*----------------------------------------------------------------------------*/
#include "support/raw_socket_ostream.h"
#include "wpi/raw_socket_ostream.h"
#include "tcpsockets/NetworkStream.h"
#include "wpi/NetworkStream.h"
using namespace wpi;

View File

@@ -17,12 +17,12 @@
-- Eugene Hopkinson <slowriot at voxelstorm dot com>
*/
#include "support/sha1.h"
#include "wpi/sha1.h"
#include "llvm/SmallVector.h"
#include "llvm/StringExtras.h"
#include "llvm/raw_ostream.h"
#include "support/raw_istream.h"
#include "wpi/SmallVector.h"
#include "wpi/StringExtras.h"
#include "wpi/raw_istream.h"
#include "wpi/raw_ostream.h"
using namespace wpi;
@@ -214,7 +214,7 @@ static void buffer_to_block(const unsigned char* buffer,
SHA1::SHA1() { reset(digest, buf_size, transforms); }
void SHA1::Update(llvm::StringRef s) {
void SHA1::Update(StringRef s) {
raw_mem_istream is(s);
Update(is);
}
@@ -237,7 +237,7 @@ void SHA1::Update(raw_istream& is) {
*/
static void finalize(uint32_t digest[], unsigned char* buffer, size_t& buf_size,
uint64_t& transforms, llvm::raw_ostream& os) {
uint64_t& transforms, raw_ostream& os) {
/* Total number of hashed bits */
uint64_t total_bits = (transforms * BLOCK_BYTES + buf_size) * 8;
@@ -277,22 +277,22 @@ static void finalize(uint32_t digest[], unsigned char* buffer, size_t& buf_size,
std::string SHA1::Final() {
std::string out;
llvm::raw_string_ostream os(out);
raw_string_ostream os(out);
finalize(digest, buffer, buf_size, transforms, os);
return os.str();
}
llvm::StringRef SHA1::Final(llvm::SmallVectorImpl<char>& buf) {
llvm::raw_svector_ostream os(buf);
StringRef SHA1::Final(SmallVectorImpl<char>& buf) {
raw_svector_ostream os(buf);
finalize(digest, buffer, buf_size, transforms, os);
return os.str();
}
std::string SHA1::FromFile(llvm::StringRef filename) {
std::string SHA1::FromFile(StringRef filename) {
std::error_code ec;
raw_fd_istream stream(filename, ec);
SHA1 checksum;

View File

@@ -5,7 +5,7 @@
/* the project. */
/*----------------------------------------------------------------------------*/
#include "support/timestamp.h"
#include "wpi/timestamp.h"
#include <atomic>