diff --git a/gen/arrays.cpp b/gen/arrays.cpp index 3493fd11..0bae1993 100644 --- a/gen/arrays.cpp +++ b/gen/arrays.cpp @@ -455,7 +455,7 @@ LLConstant* DtoConstArrayInitializer(ArrayInitializer* arrinit) LLConstant* idxs[2] = { DtoConstUint(0), DtoConstUint(0) }; - LLConstant* gep = llvm::ConstantExpr::getGetElementPtr(gvar,idxs,2); + LLConstant* gep = llvm::ConstantExpr::getGetElementPtr(gvar, idxs, true); gep = llvm::ConstantExpr::getBitCast(gvar, getPtrToType(llelemty)); return DtoConstSlice(DtoConstSize_t(arrlen), gep, arrty); diff --git a/gen/asm-x86-32.h b/gen/asm-x86-32.h index 00d9d90a..9c0fa987 100644 --- a/gen/asm-x86-32.h +++ b/gen/asm-x86-32.h @@ -2088,7 +2088,7 @@ namespace AsmParserx8632 Logger::cout() << "baseReg: " << operand->baseReg << '\n'; Logger::cout() << "segmentPrefix: " << operand->segmentPrefix << '\n'; Logger::cout() << "constDisplacement: " << operand->constDisplacement << '\n'; - for (int i = 0; i < operand->symbolDisplacement.dim; i++) { + for (unsigned i = 0; i < operand->symbolDisplacement.dim; i++) { Expression* expr = (Expression*) operand->symbolDisplacement.data[i]; Logger::cout() << "symbolDisplacement[" << i << "] = " << expr->toChars() << '\n'; } diff --git a/gen/asm-x86-64.h b/gen/asm-x86-64.h index 910c2921..a9a21953 100644 --- a/gen/asm-x86-64.h +++ b/gen/asm-x86-64.h @@ -2243,7 +2243,7 @@ namespace AsmParserx8664 Logger::cout() << "baseReg: " << operand->baseReg << '\n'; Logger::cout() << "segmentPrefix: " << operand->segmentPrefix << '\n'; Logger::cout() << "constDisplacement: " << operand->constDisplacement << '\n'; - for (int i = 0; i < operand->symbolDisplacement.dim; i++) { + for (unsigned i = 0; i < operand->symbolDisplacement.dim; i++) { Expression* expr = (Expression*) operand->symbolDisplacement.data[i]; Logger::cout() << "symbolDisplacement[" << i << "] = " << expr->toChars() << '\n'; } diff --git a/gen/asmstmt.cpp b/gen/asmstmt.cpp index 9daa9357..2c41e106 100644 --- a/gen/asmstmt.cpp +++ b/gen/asmstmt.cpp @@ -534,7 +534,7 @@ void AsmBlockStatement::toIR(IRState* p) p->asmBlock = asmblock; // do asm statements - for (int i=0; idim; i++) + for (unsigned i=0; idim; i++) { Statement* s = (Statement*)statements->data[i]; if (s) { diff --git a/gen/configfile.cpp b/gen/configfile.cpp index eacfeac2..7796d382 100644 --- a/gen/configfile.cpp +++ b/gen/configfile.cpp @@ -3,6 +3,7 @@ #include #include +#include "llvm/Support/FileSystem.h" #include "llvm/Support/Path.h" #include "libconfig.h++" @@ -31,14 +32,14 @@ bool ConfigFile::locate(sys::Path& p, const char* argv0, void* mainAddr, const c // try the current working dir p = sys::Path::GetCurrentDirectory(); p.appendComponent(filename); - if (p.exists()) + if (sys::fs::exists(p.str())) return true; // try next to the executable p = sys::Path::GetMainExecutable(argv0, mainAddr); p.eraseComponent(); p.appendComponent(filename); - if (p.exists()) + if (sys::fs::exists(p.str())) return true; // user configuration @@ -47,14 +48,14 @@ bool ConfigFile::locate(sys::Path& p, const char* argv0, void* mainAddr, const c p = sys::Path::GetUserHomeDirectory(); p.appendComponent(".ldc"); p.appendComponent(filename); - if (p.exists()) + if (sys::fs::exists(p.str())) return true; #if _WIN32 // try home dir p = sys::Path::GetUserHomeDirectory(); p.appendComponent(filename); - if (p.exists()) + if (sys::fs::exists(p.str())) return true; #endif @@ -64,14 +65,14 @@ bool ConfigFile::locate(sys::Path& p, const char* argv0, void* mainAddr, const c // try the install-prefix p = sys::Path(LDC_INSTALL_PREFIX); p.appendComponent(filename); - if (p.exists()) + if (sys::fs::exists(p.str())) return true; #else // try the install-prefix/etc p = sys::Path(LDC_INSTALL_PREFIX); p.appendComponent("etc"); p.appendComponent(filename); - if (p.exists()) + if (sys::fs::exists(p.str())) return true; // try the install-prefix/etc/ldc @@ -79,19 +80,19 @@ bool ConfigFile::locate(sys::Path& p, const char* argv0, void* mainAddr, const c p.appendComponent("etc"); p.appendComponent("ldc"); p.appendComponent(filename); - if (p.exists()) + if (sys::fs::exists(p.str())) return true; // try /etc (absolute path) p = sys::Path("/etc"); p.appendComponent(filename); - if (p.exists()) + if (sys::fs::exists(p.str())) return true; // try /etc/ldc (absolute path) p = sys::Path("/etc/ldc"); p.appendComponent(filename); - if (p.exists()) + if (sys::fs::exists(p.str())) return true; #endif @@ -134,7 +135,7 @@ bool ConfigFile::read(const char* argv0, void* mainAddr, const char* filename) { std::string binpathkey = "%%ldcbinarypath%%"; - std::string binpath = sys::Path::GetMainExecutable(argv0, mainAddr).getDirname(); + std::string binpath = sys::path::parent_path(sys::Path::GetMainExecutable(argv0, mainAddr).str()); libconfig::Setting& arr = cfg->lookup("default.switches"); int len = arr.getLength(); diff --git a/gen/declarations.cpp b/gen/declarations.cpp index 8750dc9b..b985ddee 100644 --- a/gen/declarations.cpp +++ b/gen/declarations.cpp @@ -221,7 +221,7 @@ void TemplateInstance::codegen(Ir* p) #endif if (!errors && members) { - for (int i = 0; i < members->dim; i++) + for (unsigned i = 0; i < members->dim; i++) { Dsymbol *s = (Dsymbol *)members->data[i]; s->codegen(p); @@ -235,7 +235,7 @@ void TemplateMixin::codegen(Ir* p) { if (!errors && members) { - for (int i = 0; i < members->dim; i++) + for (unsigned i = 0; i < members->dim; i++) { Dsymbol *s = (Dsymbol *)members->data[i]; if (s->isVarDeclaration()) diff --git a/gen/linker.cpp b/gen/linker.cpp index b10a2b28..1be12301 100644 --- a/gen/linker.cpp +++ b/gen/linker.cpp @@ -1,6 +1,7 @@ #include "gen/linker.h" #include "gen/llvm.h" #include "llvm/Linker.h" +#include "llvm/Support/FileSystem.h" #include "llvm/Support/Program.h" #if _WIN32 #include "llvm/Support/SystemUtils.h" @@ -96,9 +97,8 @@ int linkExecutable(const char* argv0) assert(gExePath.isValid()); // create path to exe - llvm::sys::Path exedir(gExePath); - exedir.set(gExePath.getDirname()); - if (!exedir.exists()) + llvm::sys::Path exedir(llvm::sys::path::parent_path(gExePath.str())); + if (!llvm::sys::fs::exists(exedir.str())) { exedir.createDirectoryOnDisk(true, &errstr); if (!errstr.empty()) @@ -145,7 +145,7 @@ int linkExecutable(const char* argv0) } // additional linker switches - for (int i = 0; i < global.params.linkswitches->dim; i++) + for (unsigned i = 0; i < global.params.linkswitches->dim; i++) { char *p = (char *)global.params.linkswitches->data[i]; args.push_back(p); @@ -156,7 +156,7 @@ int linkExecutable(const char* argv0) // user libs - for (int i = 0; i < global.params.libfiles->dim; i++) + for (unsigned i = 0; i < global.params.libfiles->dim; i++) { char *p = (char *)global.params.libfiles->data[i]; args.push_back(p); @@ -180,7 +180,7 @@ int linkExecutable(const char* argv0) } // object files - for (int i = 0; i < global.params.objfiles->dim; i++) + for (unsigned i = 0; i < global.params.objfiles->dim; i++) { char *p = (char *)global.params.objfiles->data[i]; args.push_back(p); @@ -232,7 +232,7 @@ int linkObjToExecutable(const char* argv0) args.push_back(gccStr); // object files - for (int i = 0; i < global.params.objfiles->dim; i++) + for (unsigned i = 0; i < global.params.objfiles->dim; i++) { char *p = (char *)global.params.objfiles->data[i]; args.push_back(p); @@ -265,9 +265,8 @@ int linkObjToExecutable(const char* argv0) assert(gExePath.isValid()); // create path to exe - llvm::sys::Path exedir(gExePath); - exedir.set(gExePath.getDirname()); - if (!exedir.exists()) + llvm::sys::Path exedir(llvm::sys::path::parent_path(gExePath.str())); + if (!llvm::sys::fs::exists(exedir.str())) { exedir.createDirectoryOnDisk(true, &errstr); if (!errstr.empty()) @@ -278,14 +277,14 @@ int linkObjToExecutable(const char* argv0) } // additional linker switches - for (int i = 0; i < global.params.linkswitches->dim; i++) + for (unsigned i = 0; i < global.params.linkswitches->dim; i++) { char *p = (char *)global.params.linkswitches->data[i]; args.push_back(p); } // user libs - for (int i = 0; i < global.params.libfiles->dim; i++) + for (unsigned i = 0; i < global.params.libfiles->dim; i++) { char *p = (char *)global.params.libfiles->data[i]; args.push_back(p); @@ -363,7 +362,8 @@ void deleteExecutable() if (!gExePath.isEmpty()) { assert(gExePath.isValid()); - assert(!gExePath.isDirectory()); + bool is_directory; + assert(!(!llvm::sys::fs::is_directory(gExePath.str(), is_directory) && is_directory)); gExePath.eraseFromDisk(false); } } @@ -392,7 +392,11 @@ int runExecutable() int status = llvm::sys::Program::ExecuteAndWait(gExePath, &args[0], NULL, NULL, 0,0, &errstr); if (status < 0) { +#if defined(_MSC_VER) + error("program received signal %d", -status); +#else error("program received signal %d (%s)", -status, strsignal(-status)); +#endif return -status; } diff --git a/gen/llvmhelpers.cpp b/gen/llvmhelpers.cpp index d9efbe1c..6c168404 100644 --- a/gen/llvmhelpers.cpp +++ b/gen/llvmhelpers.cpp @@ -1137,7 +1137,7 @@ DValue* DtoDeclarationExp(Dsymbol* declaration) // choose the right set in case this is a conditional declaration Array *d = a->include(NULL, NULL); if (d) - for (int i=0; i < d->dim; ++i) + for (unsigned i=0; i < d->dim; ++i) { DtoDeclarationExp((Dsymbol*)d->data[i]); } @@ -1146,7 +1146,7 @@ DValue* DtoDeclarationExp(Dsymbol* declaration) else if (TemplateMixin* m = declaration->isTemplateMixin()) { Logger::println("TemplateMixin"); - for (int i=0; i < m->members->dim; ++i) + for (unsigned i=0; i < m->members->dim; ++i) { Dsymbol* mdsym = (Dsymbol*)m->members->data[i]; DtoDeclarationExp(mdsym); @@ -1162,7 +1162,7 @@ DValue* DtoDeclarationExp(Dsymbol* declaration) } assert(tupled->objects); - for (int i=0; i < tupled->objects->dim; ++i) + for (unsigned i=0; i < tupled->objects->dim; ++i) { DsymbolExp* exp = (DsymbolExp*)tupled->objects->data[i]; DtoDeclarationExp(exp->s); @@ -1640,7 +1640,7 @@ bool hasUnalignedFields(Type* t) // go through all the fields and try to find something unaligned ts->unaligned = 2; - for (int i = 0; i < sym->fields.dim; i++) + for (unsigned i = 0; i < sym->fields.dim; i++) { VarDeclaration* f = (VarDeclaration*)sym->fields.data[i]; unsigned a = f->type->alignsize() - 1; diff --git a/gen/main.cpp b/gen/main.cpp index 289f167c..3ca170a2 100644 --- a/gen/main.cpp +++ b/gen/main.cpp @@ -322,7 +322,7 @@ int main(int argc, char** argv) { if (libs) { - for (int i = 0; i < libs->dim; i++) + for (unsigned i = 0; i < libs->dim; i++) { char* lib = (char *)libs->data[i]; char *arg = (char *)mem.malloc(strlen(lib) + 3); @@ -664,7 +664,7 @@ int main(int argc, char** argv) // Build import search path if (global.params.imppath) { - for (int i = 0; i < global.params.imppath->dim; i++) + for (unsigned i = 0; i < global.params.imppath->dim; i++) { char *path = (char *)global.params.imppath->data[i]; Strings *a = FileName::splitPath(path); @@ -681,7 +681,7 @@ int main(int argc, char** argv) // Build string import search path if (global.params.fileImppath) { - for (int i = 0; i < global.params.fileImppath->dim; i++) + for (unsigned i = 0; i < global.params.fileImppath->dim; i++) { char *path = (char *)global.params.fileImppath->data[i]; Strings *a = FileName::splitPath(path); @@ -698,7 +698,7 @@ int main(int argc, char** argv) // Create Modules Modules modules; modules.reserve(files.dim); - for (int i = 0; i < files.dim; i++) + for (unsigned i = 0; i < files.dim; i++) { Identifier *id; char *ext; char *name; @@ -805,7 +805,7 @@ int main(int argc, char** argv) } // Read files, parse them - for (int i = 0; i < modules.dim; i++) + for (unsigned i = 0; i < modules.dim; i++) { m = (Module *)modules.data[i]; if (global.params.verbose) @@ -840,7 +840,7 @@ int main(int argc, char** argv) * line switches and what else is imported, they are generated * before any semantic analysis. */ - for (int i = 0; i < modules.dim; i++) + for (unsigned i = 0; i < modules.dim; i++) { m = (Module *)modules.data[i]; if (global.params.verbose) @@ -853,7 +853,7 @@ int main(int argc, char** argv) #endif // load all unconditional imports for better symbol resolving - for (int i = 0; i < modules.dim; i++) + for (unsigned i = 0; i < modules.dim; i++) { m = (Module *)modules.data[i]; if (global.params.verbose) @@ -864,7 +864,7 @@ int main(int argc, char** argv) fatal(); // Do semantic analysis - for (int i = 0; i < modules.dim; i++) + for (unsigned i = 0; i < modules.dim; i++) { m = (Module *)modules.data[i]; if (global.params.verbose) @@ -878,7 +878,7 @@ int main(int argc, char** argv) Module::runDeferredSemantic(); // Do pass 2 semantic analysis - for (int i = 0; i < modules.dim; i++) + for (unsigned i = 0; i < modules.dim; i++) { m = (Module *)modules.data[i]; if (global.params.verbose) @@ -889,7 +889,7 @@ int main(int argc, char** argv) fatal(); // Do pass 3 semantic analysis - for (int i = 0; i < modules.dim; i++) + for (unsigned i = 0; i < modules.dim; i++) { m = (Module *)modules.data[i]; if (global.params.verbose) @@ -919,7 +919,7 @@ int main(int argc, char** argv) { // Do pass 3 semantic analysis on all imported modules, // since otherwise functions in them cannot be inlined - for (int i = 0; i < Module::amodules.dim; i++) + for (unsigned i = 0; i < Module::amodules.dim; i++) { m = (Module *)Module::amodules.data[i]; if (global.params.verbose) @@ -959,7 +959,7 @@ int main(int argc, char** argv) llvm::LLVMContext& context = llvm::getGlobalContext(); // Generate output files - for (int i = 0; i < modules.dim; i++) + for (unsigned i = 0; i < modules.dim; i++) { m = (Module *)modules.data[i]; if (global.params.verbose) @@ -1034,7 +1034,7 @@ int main(int argc, char** argv) /* Delete .obj files and .exe file */ - for (int i = 0; i < modules.dim; i++) + for (unsigned i = 0; i < modules.dim; i++) { m = (Module *)modules.data[i]; m->deleteObjFile(); diff --git a/gen/statements.cpp b/gen/statements.cpp index b3014b82..8cb84dd7 100644 --- a/gen/statements.cpp +++ b/gen/statements.cpp @@ -36,7 +36,7 @@ void CompoundStatement::toIR(IRState* p) Logger::println("CompoundStatement::toIR(): %s", loc.toChars()); LOG_SCOPE; - for (int i=0; idim; i++) + for (unsigned i=0; idim; i++) { Statement* s = (Statement*)statements->data[i]; if (s) { @@ -741,7 +741,7 @@ void TryCatchStatement::toIR(IRState* p) gIR->scope() = IRScope(landingpadbb, endbb); IRLandingPad& pad = gIR->func()->gen->landingPadInfo; - for (int i = 0; i < catches->dim; i++) + for (unsigned i = 0; i < catches->dim; i++) { Catch *c = (Catch *)catches->data[i]; pad.addCatch(c, endbb); @@ -870,7 +870,7 @@ void SwitchStatement::toIR(IRState* p) llvm::BasicBlock* oldend = gIR->scopeend(); // clear data from previous passes... :/ - for (int i=0; idim; ++i) + for (unsigned i=0; idim; ++i) { CaseStatement* cs = (CaseStatement*)cases->data[i]; cs->bodyBB = NULL; @@ -881,7 +881,7 @@ void SwitchStatement::toIR(IRState* p) // 'switch' instruction (that can happen because D2 allows to // initialize a global variable in a static constructor). bool useSwitchInst = true; - for (int i=0; idim; ++i) + for (unsigned i=0; idim; ++i) { CaseStatement* cs = (CaseStatement*)cases->data[i]; VarDeclaration* vd = 0; @@ -928,7 +928,7 @@ void SwitchStatement::toIR(IRState* p) Logger::println("is string switch"); // build array of the stringexpS caseArray.reserve(cases->dim); - for (int i=0; idim; ++i) + for (unsigned i=0; idim; ++i) { CaseStatement* cs = (CaseStatement*)cases->data[i]; @@ -980,7 +980,7 @@ void SwitchStatement::toIR(IRState* p) // create switch and add the cases llvm::SwitchInst* si = llvm::SwitchInst::Create(condVal, defbb ? defbb : endbb, cases->dim, p->scopebb()); - for (int i=0; idim; ++i) + for (unsigned i=0; idim; ++i) { CaseStatement* cs = (CaseStatement*)cases->data[i]; si->addCase(isaConstantInt(cs->llvmIdx), cs->bodyBB); @@ -995,7 +995,7 @@ void SwitchStatement::toIR(IRState* p) llvm::BranchInst::Create(nextbb, p->scopebb()); p->scope() = IRScope(nextbb, endbb); - for (int i=0; idim; ++i) + for (unsigned i=0; idim; ++i) { CaseStatement* cs = (CaseStatement*)cases->data[i]; diff --git a/gen/toir.cpp b/gen/toir.cpp index c11e1730..2401b96d 100644 --- a/gen/toir.cpp +++ b/gen/toir.cpp @@ -478,7 +478,7 @@ DValue* StringExp::toElem(IRState* p) llvm::ConstantInt* zero = LLConstantInt::get(LLType::getInt32Ty(gIR->context()), 0, false); LLConstant* idxs[2] = { zero, zero }; - LLConstant* arrptr = llvm::ConstantExpr::getGetElementPtr(gvar,idxs,2); + LLConstant* arrptr = llvm::ConstantExpr::getGetElementPtr(gvar, idxs, true); if (dtype->ty == Tarray) { LLConstant* clen = LLConstantInt::get(DtoSize_t(),len,false); @@ -554,7 +554,7 @@ LLConstant* StringExp::toConstElem(IRState* p) llvm::ConstantInt* zero = LLConstantInt::get(LLType::getInt32Ty(gIR->context()), 0, false); LLConstant* idxs[2] = { zero, zero }; - LLConstant* arrptr = llvm::ConstantExpr::getGetElementPtr(gvar,idxs,2); + LLConstant* arrptr = llvm::ConstantExpr::getGetElementPtr(gvar, idxs, true); if (t->ty == Tpointer) { return arrptr; @@ -1074,7 +1074,7 @@ LLConstant* CastExp::toConstElem(IRState* p) Type *type = vd->type->toBasetype(); if (type->ty == Tarray || type->ty == Tdelegate) { LLConstant* idxs[2] = { DtoConstSize_t(0), DtoConstSize_t(1) }; - value = llvm::ConstantExpr::getGetElementPtr(value, idxs, 2); + value = llvm::ConstantExpr::getGetElementPtr(value, idxs, true); } return DtoBitCast(value, DtoType(tb)); } @@ -1206,7 +1206,7 @@ LLConstant* AddrExp::toConstElem(IRState* p) LLConstant* idxs[2] = { DtoConstSize_t(0), index }; LLConstant *val = isaConstant(vd->ir.irGlobal->value); val = DtoBitCast(val, DtoType(vd->type->pointerTo())); - LLConstant* gep = llvm::ConstantExpr::getGetElementPtr(val, idxs, 2); + LLConstant* gep = llvm::ConstantExpr::getGetElementPtr(val, idxs, true); // bitcast to requested type assert(type->toBasetype()->ty == Tpointer); @@ -2751,7 +2751,7 @@ LLConstant* ArrayLiteralExp::toConstElem(IRState* p) // build a constant dynamic array reference with the .ptr field pointing into globalstore LLConstant* idxs[2] = { DtoConstUint(0), DtoConstUint(0) }; - LLConstant* globalstorePtr = llvm::ConstantExpr::getGetElementPtr(globalstore, idxs, 2); + LLConstant* globalstorePtr = llvm::ConstantExpr::getGetElementPtr(globalstore, idxs, true); return DtoConstSlice(DtoConstSize_t(elements->dim), globalstorePtr); } @@ -2975,14 +2975,14 @@ DValue* AssocArrayLiteralExp::toElem(IRState* p) LLArrayType* arrtype = LLArrayType::get(DtoType(indexType), keys->dim); LLConstant* initval = LLConstantArray::get(arrtype, keysInits); LLConstant* globalstore = new LLGlobalVariable(*gIR->module, arrtype, false, LLGlobalValue::InternalLinkage, initval, ".aaKeysStorage"); - LLConstant* slice = llvm::ConstantExpr::getGetElementPtr(globalstore, idxs, 2); + LLConstant* slice = llvm::ConstantExpr::getGetElementPtr(globalstore, idxs, true); slice = DtoConstSlice(DtoConstSize_t(keys->dim), slice); LLValue* keysArray = DtoAggrPaint(slice, funcTy->getParamType(1)); arrtype = LLArrayType::get(DtoType(vtype), values->dim); initval = LLConstantArray::get(arrtype, valuesInits); globalstore = new LLGlobalVariable(*gIR->module, arrtype, false, LLGlobalValue::InternalLinkage, initval, ".aaValuesStorage"); - slice = llvm::ConstantExpr::getGetElementPtr(globalstore, idxs, 2); + slice = llvm::ConstantExpr::getGetElementPtr(globalstore, idxs, true); slice = DtoConstSlice(DtoConstSize_t(keys->dim), slice); LLValue* valuesArray = DtoAggrPaint(slice, funcTy->getParamType(2)); diff --git a/gen/tollvm.cpp b/gen/tollvm.cpp index 1b1d4091..14274853 100644 --- a/gen/tollvm.cpp +++ b/gen/tollvm.cpp @@ -447,7 +447,7 @@ LLValue* DtoGEPi(LLValue* ptr, unsigned i0, unsigned i1, const char* var, llvm:: LLConstant* DtoGEPi(LLConstant* ptr, unsigned i0, unsigned i1) { LLValue* v[2] = { DtoConstUint(i0), DtoConstUint(i1) }; - return llvm::ConstantExpr::getGetElementPtr(ptr, v, 2); + return llvm::ConstantExpr::getGetElementPtr(ptr, v, true); } ////////////////////////////////////////////////////////////////////////////////////////// @@ -596,7 +596,7 @@ LLConstant* DtoConstString(const char* str) LLConstant* idxs[2] = { DtoConstUint(0), DtoConstUint(0) }; return DtoConstSlice( DtoConstSize_t(s.size()), - llvm::ConstantExpr::getGetElementPtr(gvar,idxs,2), + llvm::ConstantExpr::getGetElementPtr(gvar, idxs, true), Type::tchar->arrayOf() ); } @@ -608,7 +608,7 @@ LLConstant* DtoConstStringPtr(const char* str, const char* section) *gIR->module, init->getType(), true,llvm::GlobalValue::InternalLinkage, init, ".str"); if (section) gvar->setSection(section); LLConstant* idxs[2] = { DtoConstUint(0), DtoConstUint(0) }; - return llvm::ConstantExpr::getGetElementPtr(gvar,idxs,2); + return llvm::ConstantExpr::getGetElementPtr(gvar, idxs, true); } ////////////////////////////////////////////////////////////////////////////////////////// diff --git a/gen/toobj.cpp b/gen/toobj.cpp index 1e7737ed..0a18409a 100644 --- a/gen/toobj.cpp +++ b/gen/toobj.cpp @@ -134,7 +134,7 @@ llvm::Module* Module::genLLVMModule(llvm::LLVMContext& context, Ir* sir) LLVM_D_InitRuntime(); // process module members - for (int k=0; k < members->dim; k++) { + for (unsigned k=0; k < members->dim; k++) { Dsymbol* dsym = (Dsymbol*)(members->data[k]); assert(dsym); dsym->codegen(sir); @@ -275,7 +275,7 @@ void writeModule(llvm::Module* m, std::string filename) Logger::println("Writing object file to: %s\n", objpath.c_str()); std::string err; { - llvm::raw_fd_ostream out(objpath.c_str(), err); + llvm::raw_fd_ostream out(objpath.c_str(), err, llvm::raw_fd_ostream::F_Binary); if (err.empty()) { emit_file(*gTargetMachine, *m, out, llvm::TargetMachine::CGFT_ObjectFile); diff --git a/gen/typinf.cpp b/gen/typinf.cpp index b65e4c29..d62ba559 100644 --- a/gen/typinf.cpp +++ b/gen/typinf.cpp @@ -711,7 +711,7 @@ void TypeInfoStructDeclaration::llvmDefine() { TypeTuple *tup = tc->toArgTypes(); assert(tup->arguments->dim <= 2); - for (int i = 0; i < 2; i++) + for (unsigned i = 0; i < 2; i++) { if (i < tup->arguments->dim) { diff --git a/ir/irclass.cpp b/ir/irclass.cpp index 94d41e40..698e5835 100644 --- a/ir/irclass.cpp +++ b/ir/irclass.cpp @@ -377,7 +377,7 @@ llvm::GlobalVariable * IrStruct::getInterfaceVtbl(BaseClass * b, bool new_instan }; llvm::Constant* c = llvm::ConstantExpr::getGetElementPtr( - getInterfaceArraySymbol(), idxs, 2); + getInterfaceArraySymbol(), idxs, true); constants.push_back(c); @@ -533,7 +533,7 @@ LLConstant * IrStruct::getClassInfoInterfaces() }; LLConstant* ptr = llvm::ConstantExpr::getGetElementPtr( - classInterfacesArray, idxs, 2); + classInterfacesArray, idxs, true); // return as a slice return DtoConstSlice( DtoConstSize_t(cd->vtblInterfaces->dim), ptr );