Added '-Hkeep-all-bodies' switch.

The same behavior is triggered by the '-inline' switch for
DMD, but this doesn't quite translate to LDC.
This commit is contained in:
David Nadlinger 2013-03-16 11:52:19 +01:00
parent 82ba7fe548
commit 32eb24eebf
4 changed files with 28 additions and 3 deletions

View file

@ -1948,7 +1948,13 @@ void FuncDeclaration::toCBuffer(OutBuffer *buf, HdrGenState *hgs)
bodyToCBuffer(buf, hgs);
hgs->autoMember--;
}
else if(hgs->tpltMember == 0 && global.params.useInline == 0)
else if(hgs->tpltMember == 0 &&
#if IN_LLVM
!global.params.hdrKeepAllBodies
#else
global.params.useInline == 0
#endif
)
buf->writestring(";");
else
bodyToCBuffer(buf, hgs);
@ -2022,7 +2028,13 @@ int FuncDeclaration::equals(Object *o)
void FuncDeclaration::bodyToCBuffer(OutBuffer *buf, HdrGenState *hgs)
{
if (fbody && (!hgs->hdrgen || global.params.useInline || hgs->autoMember || hgs->tpltMember))
if (fbody && (!hgs->hdrgen ||
#if IN_LLVM
global.params.hdrKeepAllBodies ||
#else
global.params.useInline ||
#endif
hgs->autoMember || hgs->tpltMember))
{
int savetlpt = hgs->tpltMember;
int saveauto = hgs->autoMember;

View file

@ -282,6 +282,11 @@ struct Param
char *exefile;
char *mapfile;
#if IN_LLVM
// Whether to keep all function bodies in .di file generation or to strip
// those of plain functions. For DMD, this is govenered by the -inline
// flag, which does not directly translate to LDC.
bool hdrKeepAllBodies;
// LDC stuff
OUTPUTFLAG output_ll;
OUTPUTFLAG output_bc;

View file

@ -187,6 +187,10 @@ cl::opt<std::string> hdrFile("Hf",
cl::value_desc("filename"),
cl::Prefix);
static cl::opt<bool, true> hdrKeepAllBodies("Hkeep-all-bodies",
cl::desc("Keep all function bodies in .di files"),
cl::ZeroOrMore,
cl::location(global.params.hdrKeepAllBodies));
static cl::opt<bool, true> unittest("unittest",
cl::desc("Compile in unit tests"),

View file

@ -822,7 +822,11 @@ void buildCommandLine(std::vector<const char*>& r, const Params& p)
if (p.jsonName) r.push_back(concat("-Xf=", p.jsonName));
if (p.ignoreUnsupportedPragmas) r.push_back("-ignore");
if (p.enforcePropertySyntax) r.push_back("-property");
if (p.enableInline) r.push_back("-enable-inlining");
if (p.enableInline) {
// -inline also influences .di generation with DMD.
r.push_back("-enable-inlining");
r.push_back("-Hkeep-all-bodies");
}
if (p.emitStaticLib) r.push_back("-lib");
if (p.noFloat) warning("-nofloat is ignored by LDC.");
if (p.quiet) r.push_back("-quiet"); // Undocumented.