Move string utility functions into their own translation unit

[ROCm/clr commit: ab824ebd47]
Este commit está contenido en:
Chris Kitching
2017-10-25 19:23:32 +01:00
padre dcd770f25a
commit f659ad0eeb
Se han modificado 3 ficheros con 32 adiciones y 17 borrados
@@ -55,6 +55,7 @@ THE SOFTWARE.
#include "CUDA2HipMap.h"
#include "Types.h"
#include "LLVMCompat.h"
#include "StringUtils.h"
using namespace clang;
using namespace clang::ast_matchers;
@@ -121,23 +122,6 @@ uint64_t countApiRepsTotalUnsupported[API_LAST] = { 0 };
std::map<std::string, uint64_t> cuda2hipConvertedTotal;
std::map<std::string, uint64_t> cuda2hipUnconvertedTotal;
StringRef unquoteStr(StringRef s) {
if (s.size() > 1 && s.front() == '"' && s.back() == '"')
return s.substr(1, s.size() - 2);
return s;
}
/**
* If `s` starts with `prefix`, remove it. Otherwise, does nothing.
*/
void removePrefixIfPresent(std::string& s, std::string prefix) {
if (s.find(prefix) != 0) {
return;
}
s.erase(0, prefix.size());
}
class Cuda2Hip {
public:
Cuda2Hip(Replacements& R, const std::string &srcFileName) :
@@ -0,0 +1,17 @@
#include "StringUtils.h"
llvm::StringRef unquoteStr(llvm::StringRef s) {
if (s.size() > 1 && s.front() == '"' && s.back() == '"') {
return s.substr(1, s.size() - 2);
}
return s;
}
void removePrefixIfPresent(std::string &s, std::string prefix) {
if (s.find(prefix) != 0) {
return;
}
s.erase(0, prefix.size());
}
@@ -0,0 +1,14 @@
#pragma once
#include <string>
#include "llvm/ADT/StringRef.h"
/**
* Remove double-quotes from the start/end of a string, if present.
*/
llvm::StringRef unquoteStr(llvm::StringRef s);
/**
* If `s` starts with `prefix`, remove it. Otherwise, does nothing.
*/
void removePrefixIfPresent(std::string &s, std::string prefix);