mirror of
https://github.com/ldc-developers/ldc.git
synced 2025-05-08 11:56:12 +03:00
Create parameter for maximum number of template instantiations.
Currently, the maximum number is hard coded. This PR creates a command line parameter for it. Requested by bearophile: http://forum.dlang.org/post/tsphogrgyjeqyeadqkds@forum.dlang.org
This commit is contained in:
parent
956f1ff528
commit
a22518a7a6
4 changed files with 21 additions and 0 deletions
|
@ -178,6 +178,7 @@ struct Param
|
|||
bool enforcePropertySyntax;
|
||||
bool addMain; // LDC_FIXME: Implement.
|
||||
bool allInst; // LDC_FIXME: Implement.
|
||||
unsigned nestedTmpl; // maximum nested template instantiations
|
||||
#else
|
||||
bool pic; // generate position-independent-code for shared libs
|
||||
bool cov; // generate code coverage data
|
||||
|
|
|
@ -5235,7 +5235,11 @@ void TemplateInstance::tryExpandMembers(Scope *sc2)
|
|||
static int nest;
|
||||
// extracted to a function to allow windows SEH to work without destructors in the same function
|
||||
//printf("%d\n", nest);
|
||||
#if IN_LLVM
|
||||
if (++nest > global.params.nestedTmpl)
|
||||
#else
|
||||
if (++nest > 500)
|
||||
#endif
|
||||
{
|
||||
global.gag = 0; // ensure error message gets printed
|
||||
error("recursive expansion");
|
||||
|
@ -5705,7 +5709,11 @@ void TemplateInstance::semantic(Scope *sc, Expressions *fargs)
|
|||
while (ti && !ti->deferred && ti->tinst)
|
||||
{
|
||||
ti = ti->tinst;
|
||||
#if IN_LLVM
|
||||
if (++nest > global.params.nestedTmpl)
|
||||
#else
|
||||
if (++nest > 500)
|
||||
#endif
|
||||
{
|
||||
global.gag = 0; // ensure error message gets printed
|
||||
error("recursive expansion");
|
||||
|
@ -7530,7 +7538,11 @@ void TemplateMixin::semantic(Scope *sc)
|
|||
|
||||
static int nest;
|
||||
//printf("%d\n", nest);
|
||||
#if IN_LLVM
|
||||
if (++nest > global.params.nestedTmpl)
|
||||
#else
|
||||
if (++nest > 500)
|
||||
#endif
|
||||
{
|
||||
global.gag = 0; // ensure error message gets printed
|
||||
error("recursive expansion");
|
||||
|
|
|
@ -385,6 +385,12 @@ cl::opt<bool, true> allinst("allinst",
|
|||
cl::desc("generate code for all template instantiations"),
|
||||
cl::location(global.params.allInst));
|
||||
|
||||
cl::opt<unsigned, true> nestedTemplateDepth("template-depth",
|
||||
cl::desc("(experimental) set maximum number of nested template instantiations"),
|
||||
cl::location(global.params.nestedTmpl),
|
||||
cl::init(500));
|
||||
|
||||
|
||||
static cl::extrahelp footer("\n"
|
||||
"-d-debug can also be specified without options, in which case it enables all\n"
|
||||
"debug checks (i.e. (asserts, boundchecks, contracts and invariants) as well\n"
|
||||
|
|
|
@ -70,6 +70,8 @@ namespace opts {
|
|||
extern cl::opt<BoolOrDefaultAdapter, false, FlagParser> boundsChecks;
|
||||
extern bool nonSafeBoundsChecks;
|
||||
|
||||
extern cl::opt<unsigned, true> nestedTemplateDepth;
|
||||
|
||||
// Arguments to -d-debug
|
||||
extern std::vector<std::string> debugArgs;
|
||||
// Arguments to -run
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue