Move string utility functions into their own translation unit
[ROCm/clr commit: ab824ebd47]
Este commit está contenido en:
@@ -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);
|
||||
Referencia en una nueva incidencia
Block a user