fix building against recent LLVM 4.0

This commit is contained in:
Rainer Schuetze 2016-10-03 10:26:24 +02:00
parent 47e1251298
commit 8f0f29c239
3 changed files with 20 additions and 4 deletions

View file

@ -66,6 +66,9 @@ static bool ReadPathFromRegistry(llvm::SmallString<128> &p) {
if (RegGetValue(hkey, NULL, _T("Path"), RRF_RT_REG_SZ, NULL, data, &length) ==
ERROR_SUCCESS) {
#if UNICODE
#if LDC_LLVM_VER >= 400
using UTF16 = llvm::UTF16;
#endif
std::string out;
res = llvm::convertUTF16ToUTF8String(
llvm::ArrayRef<UTF16>(reinterpret_cast<UTF16 *>(data), length), out);

View file

@ -87,18 +87,28 @@ public:
// Implement virtual functions needed by generic_parser_base
unsigned getNumOptions() const LLVM_OVERRIDE { return 1; }
const char *getOption(unsigned N) const LLVM_OVERRIDE {
#if LDC_LLVM_VER >= 400
llvm::StringRef
#else
const char *
#endif
getOption(unsigned N) const LLVM_OVERRIDE {
assert(N == 0);
#if LDC_LLVM_VER >= 308
#if LDC_LLVM_VER >= 308 && LDC_LLVM_VER < 400
return owner().ArgStr.data();
#else
return owner().ArgStr;
#endif
}
const char *getDescription(unsigned N) const LLVM_OVERRIDE {
#if LDC_LLVM_VER >= 400
llvm::StringRef
#else
const char *
#endif
getDescription(unsigned N) const LLVM_OVERRIDE {
assert(N == 0);
#if LDC_LLVM_VER >= 308
#if LDC_LLVM_VER >= 308 && LDC_LLVM_VER < 400
return owner().HelpStr.data();
#else
return owner().HelpStr;

View file

@ -1375,6 +1375,9 @@ bool isLLVMUnsigned(Type *t) { return t->isunsigned() || t->ty == Tpointer; }
void printLabelName(std::ostream &target, const char *func_mangle,
const char *label_name) {
target << gTargetMachine->getMCAsmInfo()->getPrivateGlobalPrefix()
#if LDC_LLVM_VER >= 400
.str()
#endif
<< func_mangle << "_" << label_name;
}