mirror of
https://github.com/xomboverlord/ldc.git
synced 2026-12-01 13:14:19 +01:00
Merge pull request #398 from ldc-developers/merge-2.063
DMD 2.063.1 merge
This commit is contained in:
+10
-7
@@ -8,6 +8,7 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#include "driver/cl_options.h"
|
||||
#include "mars.h"
|
||||
#include "gen/cl_helpers.h"
|
||||
#include "gen/logger.h"
|
||||
#include "llvm/Support/CommandLine.h"
|
||||
@@ -204,6 +205,10 @@ static cl::list<std::string, StringsAdapter> stringImportPaths("J",
|
||||
cl::location(strImpPathStore),
|
||||
cl::Prefix);
|
||||
|
||||
static cl::opt<bool, true> addMain("main",
|
||||
cl::desc("add empty main() (e.g. for unittesting)"),
|
||||
cl::ZeroOrMore,
|
||||
cl::location(global.params.addMain));
|
||||
|
||||
|
||||
// -d-debug is a bit messy, it has 3 modes:
|
||||
@@ -217,7 +222,7 @@ struct D_DebugStorage {
|
||||
if (str.empty()) {
|
||||
// Bare "-d-debug" has a special meaning.
|
||||
global.params.useAssert = true;
|
||||
global.params.useArrayBounds = true;
|
||||
global.params.useArrayBounds = 2;
|
||||
global.params.useInvariants = true;
|
||||
global.params.useIn = true;
|
||||
global.params.useOut = true;
|
||||
@@ -316,11 +321,8 @@ static cl::opt<bool, true, FlagParser> asserts("asserts",
|
||||
cl::location(global.params.useAssert),
|
||||
cl::init(true));
|
||||
|
||||
static cl::opt<bool, true, FlagParser> boundsChecks("boundscheck",
|
||||
cl::desc("(*) Enable array bounds checks"),
|
||||
cl::value_desc("bool"),
|
||||
cl::location(global.params.useArrayBounds),
|
||||
cl::init(true));
|
||||
cl::opt<BoolOrDefaultAdapter, false, FlagParser> boundsChecks("boundscheck",
|
||||
cl::desc("(*) Enable array bounds checks"));
|
||||
|
||||
static cl::opt<bool, true, FlagParser> invariants("invariants",
|
||||
cl::desc("(*) Enable invariants"),
|
||||
@@ -344,8 +346,9 @@ static cl::opt<MultiSetter, true, FlagParser> contracts("contracts",
|
||||
cl::desc("(*) Enable function pre- and post-conditions"),
|
||||
cl::location(ContractsSetter));
|
||||
|
||||
bool nonSafeBoundsChecks = true;
|
||||
static MultiSetter ReleaseSetter(true, &global.params.useAssert,
|
||||
&global.params.useArrayBounds, &global.params.useInvariants,
|
||||
&nonSafeBoundsChecks, &global.params.useInvariants,
|
||||
&global.params.useOut, &global.params.useIn, NULL);
|
||||
static cl::opt<MultiSetter, true, cl::parser<bool> > release("release",
|
||||
cl::desc("Disables asserts, invariants, contracts and boundscheck"),
|
||||
|
||||
+4
-1
@@ -15,7 +15,7 @@
|
||||
#ifndef LDC_DRIVER_CL_OPTIONS_H
|
||||
#define LDC_DRIVER_CL_OPTIONS_H
|
||||
|
||||
#include "mars.h"
|
||||
#include "gen/cl_helpers.h"
|
||||
#include "llvm/Support/CodeGen.h"
|
||||
#include "llvm/Support/CommandLine.h"
|
||||
#include <deque>
|
||||
@@ -63,6 +63,9 @@ namespace opts {
|
||||
extern cl::opt<bool, true> singleObj;
|
||||
extern cl::opt<bool> linkonceTemplates;
|
||||
|
||||
extern cl::opt<BoolOrDefaultAdapter, false, FlagParser> boundsChecks;
|
||||
extern bool nonSafeBoundsChecks;
|
||||
|
||||
// Arguments to -d-debug
|
||||
extern std::vector<std::string> debugArgs;
|
||||
// Arguments to -run
|
||||
|
||||
+8
-2
@@ -233,8 +233,12 @@ Usage:\n\
|
||||
-quiet suppress unnecessary messages\n\
|
||||
-release compile release version\n\
|
||||
-run srcfile args... run resulting program, passing args\n\
|
||||
-shared generate shared library\n\
|
||||
-unittest compile in unit tests\n\
|
||||
-shared generate shared library\n"
|
||||
#if 0
|
||||
" -transition=id show additional info about language change identified by 'id'\n\
|
||||
-transition=? list all language changes\n"
|
||||
#endif
|
||||
" -unittest compile in unit tests\n\
|
||||
-v verbose\n\
|
||||
-vdmd print the command used to invoke the underlying compiler\n\
|
||||
-version=level compile in version code >= level\n\
|
||||
@@ -529,6 +533,8 @@ Params parseArgs(size_t originalArgc, char** originalArgv, ls::Path ldcPath)
|
||||
result.targetModel = Model::m64;
|
||||
else if (strcmp(p + 1, "profile") == 0)
|
||||
result.profile = true;
|
||||
else if (memcmp(p + 1, "transition", 10) == 0)
|
||||
warning("-transition not yet supported by LDC.");
|
||||
else if (strcmp(p + 1, "v") == 0)
|
||||
result.verbose = true;
|
||||
else if (strcmp(p + 1, "vdmd") == 0)
|
||||
|
||||
+35
-2
@@ -14,6 +14,7 @@
|
||||
#include "mtype.h"
|
||||
#include "rmem.h"
|
||||
#include "root.h"
|
||||
#include "dmd2/target.h"
|
||||
#include "driver/cl_options.h"
|
||||
#include "driver/configfile.h"
|
||||
#include "driver/linker.h"
|
||||
@@ -163,6 +164,8 @@ int main(int argc, char** argv)
|
||||
Module *m;
|
||||
int status = EXIT_SUCCESS;
|
||||
|
||||
global.init();
|
||||
|
||||
// Set some default values
|
||||
#if _WIN32
|
||||
char buf[MAX_PATH];
|
||||
@@ -172,6 +175,7 @@ int main(int argc, char** argv)
|
||||
global.params.argv0 = argv[0];
|
||||
#endif
|
||||
global.params.useSwitchError = 1;
|
||||
global.params.useArrayBounds = 2;
|
||||
|
||||
global.params.linkswitches = new Strings();
|
||||
global.params.libfiles = new Strings();
|
||||
@@ -366,6 +370,14 @@ int main(int argc, char** argv)
|
||||
if (global.params.useUnitTests)
|
||||
global.params.useAssert = 1;
|
||||
|
||||
// Bounds checking is a bit peculiar: -enable/disable-boundscheck is an
|
||||
// absolute decision. Only if no explicit option is specified, -release
|
||||
// downgrades useArrayBounds 2 to 1 (only for safe functions).
|
||||
if (opts::boundsChecks == cl::BOU_UNSET)
|
||||
global.params.useArrayBounds = opts::nonSafeBoundsChecks ? 2 : 1;
|
||||
else
|
||||
global.params.useArrayBounds = (opts::boundsChecks == cl::BOU_TRUE) ? 2 : 0;
|
||||
|
||||
// LDC output determination
|
||||
|
||||
// if we don't link, autodetect target from extension
|
||||
@@ -648,6 +660,8 @@ int main(int argc, char** argv)
|
||||
Type::init(&ir);
|
||||
Id::initialize();
|
||||
Module::init();
|
||||
Target::init();
|
||||
Expression::init();
|
||||
initPrecedence();
|
||||
|
||||
backend_init();
|
||||
@@ -688,6 +702,12 @@ int main(int argc, char** argv)
|
||||
}
|
||||
}
|
||||
|
||||
if (global.params.addMain)
|
||||
{
|
||||
// a dummy name, we never actually look up this file
|
||||
files.push(const_cast<char*>(global.main_d));
|
||||
}
|
||||
|
||||
// Create Modules
|
||||
Modules modules;
|
||||
modules.reserve(files.dim);
|
||||
@@ -761,7 +781,8 @@ int main(int argc, char** argv)
|
||||
#endif
|
||||
|
||||
if (Port::stricmp(ext, global.mars_ext) == 0 ||
|
||||
Port::stricmp(ext, global.hdr_ext) == 0)
|
||||
Port::stricmp(ext, global.hdr_ext) == 0 ||
|
||||
FileName::equals(ext, "dd"))
|
||||
{
|
||||
ext--; // skip onto '.'
|
||||
assert(*ext == '.');
|
||||
@@ -808,7 +829,18 @@ int main(int argc, char** argv)
|
||||
if (!Module::rootModule)
|
||||
Module::rootModule = m;
|
||||
m->importedFrom = m;
|
||||
m->read(0);
|
||||
|
||||
if (strcmp(m->srcfile->name->str, global.main_d) == 0)
|
||||
{
|
||||
static const char buf[] = "void main(){}";
|
||||
m->srcfile->setbuffer((void *)buf, sizeof(buf));
|
||||
m->srcfile->ref = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
m->read(Loc());
|
||||
}
|
||||
|
||||
m->parse(global.params.doDocComments);
|
||||
m->buildTargetFiles(singleObj);
|
||||
m->deleteObjFile();
|
||||
@@ -924,6 +956,7 @@ int main(int argc, char** argv)
|
||||
if (global.errors)
|
||||
fatal();
|
||||
}
|
||||
global.inExtraInliningSemantic = false;
|
||||
}
|
||||
if (global.errors || global.warnings)
|
||||
fatal();
|
||||
|
||||
Reference in New Issue
Block a user