Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions src/aggregate.d
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,17 @@ extern (C++) abstract class AggregateDeclaration : ScopeDsymbol
return 1; // unresolvable forward reference

auto ad = cast(AggregateDeclaration)param;
version(IN_LLVM)
{
for (size_t i = 0; i < ad.fields.dim; i++)
{
if (ad.fields[i] == v)
{
// already a field
return 0;
}
}
}
ad.fields.push(v);

if (v.storage_class & STCref)
Expand Down
5 changes: 5 additions & 0 deletions src/arrayop.d
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import ddmd.visitor;
/**************************************
* Hash table of array op functions already generated or known about.
*/
version(IN_LLVM) {} else
private __gshared FuncDeclaration[void*] arrayfuncs;


Expand Down Expand Up @@ -200,6 +201,10 @@ extern (C++) Expression arrayOp(BinExp e, Scope* sc)

auto ident = Identifier.idPool(buf.peekSlice());

version(IN_LLVM)
{
auto arrayfuncs = sc._module.arrayfuncs;
}
FuncDeclaration* pFd = cast(void*)ident in arrayfuncs;
FuncDeclaration fd;
if (pFd)
Expand Down
54 changes: 52 additions & 2 deletions src/attrib.d
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,12 @@ import ddmd.utf;
import ddmd.utils;
import ddmd.visitor;

version(IN_LLVM)
{
import gen.dpragma;
}


/***********************************************************
*/
extern (C++) abstract class AttribDeclaration : Dsymbol
Expand Down Expand Up @@ -917,13 +923,35 @@ extern (C++) final class PragmaDeclaration : AttribDeclaration
}
return createNewScope(sc, sc.stc, sc.linkage, sc.cppmangle, sc.protection, sc.explicitProtection, sc.aligndecl, inlining);
}
else if (IN_LLVM && ident == Id.LDC_profile_instr) {
bool emitInstr = true;
if (!args || args.dim != 1 || !DtoCheckProfileInstrPragma((*args)[0], emitInstr)) {
error("pragma(LDC_profile_instr, true or false) expected");
(*args)[0] = new ErrorExp();
} else {
// Only create a new scope if the emitInstrumentation flag is changed
if (sc.emitInstrumentation != emitInstr) {
auto newscope = sc.copy();
newscope.emitInstrumentation = emitInstr;
return newscope;
}
}
}

return sc;
}

override void semantic(Scope* sc)
{
// Should be merged with PragmaStatement
//printf("\tPragmaDeclaration::semantic '%s'\n",toChars());

version(IN_LLVM)
{
LDCPragma llvm_internal = LDCPragma.LLVMnone;
const(char)* arg1str = null;
}

if (ident == Id.msg)
{
if (args)
Expand Down Expand Up @@ -1075,6 +1103,11 @@ extern (C++) final class PragmaDeclaration : AttribDeclaration
}
}
}
// IN_LLVM
else if ((llvm_internal = DtoGetPragma(sc, this, arg1str)) != LDCPragma.LLVMnone)
{
// nothing to do anymore
}
else if (global.params.ignoreUnsupportedPragmas)
{
if (global.params.verbose)
Expand All @@ -1087,6 +1120,12 @@ extern (C++) final class PragmaDeclaration : AttribDeclaration
for (size_t i = 0; i < args.dim; i++)
{
Expression e = (*args)[i];
version(IN_LLVM)
{
// ignore errors in ignored pragmas.
global.gag++;
uint errors_save = global.errors;
}
sc = sc.startCTFE();
e = e.semantic(sc);
e = resolveProperties(sc, e);
Expand All @@ -1097,14 +1136,20 @@ extern (C++) final class PragmaDeclaration : AttribDeclaration
else
fprintf(global.stdmsg, ",");
fprintf(global.stdmsg, "%s", e.toChars());
version(IN_LLVM)
{
// restore error state.
global.gag--;
global.errors = errors_save;
}
}
if (args.dim)
fprintf(global.stdmsg, ")");
}
fprintf(global.stdmsg, "\n");
}
goto Lnodecl;
}
static if (!IN_LLVM)
goto Lnodecl; }
else
error("unrecognized pragma(%s)", ident.toChars());
Ldecl:
Expand All @@ -1128,6 +1173,11 @@ extern (C++) final class PragmaDeclaration : AttribDeclaration
error("can only apply to a single declaration");
}
}
// IN_LLVM: add else clause
else
{
DtoCheckPragma(this, s, llvm_internal, arg1str);
}
}
if (sc2 != sc)
sc2.pop();
Expand Down
14 changes: 7 additions & 7 deletions src/attrib.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ class AttribDeclaration : public Dsymbol
void semantic2(Scope *sc);
void semantic3(Scope *sc);
void addComment(const utf8_t *comment);
const char *kind() const;
const char *kind();
bool oneMember(Dsymbol **ps, Identifier *ident);
void setFieldOffset(AggregateDeclaration *ad, unsigned *poffset, bool isunion);
bool hasPointers();
Expand Down Expand Up @@ -114,7 +114,7 @@ class ProtDeclaration : public AttribDeclaration
Dsymbol *syntaxCopy(Dsymbol *s);
Scope *newScope(Scope *sc);
void addMember(Scope *sc, ScopeDsymbol *sds);
const char *kind() const;
const char *kind();
const char *toPrettyChars(bool unused);
void accept(Visitor *v) { v->visit(this); }
};
Expand Down Expand Up @@ -147,7 +147,7 @@ class AnonDeclaration : public AttribDeclaration
void setScope(Scope *sc);
void semantic(Scope *sc);
void setFieldOffset(AggregateDeclaration *ad, unsigned *poffset, bool isunion);
const char *kind() const;
const char *kind();
AnonDeclaration *isAnonDeclaration() { return this; }
void accept(Visitor *v) { v->visit(this); }
};
Expand All @@ -160,7 +160,7 @@ class PragmaDeclaration : public AttribDeclaration
Dsymbol *syntaxCopy(Dsymbol *s);
Scope *newScope(Scope *sc);
void semantic(Scope *sc);
const char *kind() const;
const char *kind();
void accept(Visitor *v) { v->visit(this); }
};

Expand Down Expand Up @@ -190,7 +190,7 @@ class StaticIfDeclaration : public ConditionalDeclaration
void setScope(Scope *sc);
void importAll(Scope *sc);
void semantic(Scope *sc);
const char *kind() const;
const char *kind();
void accept(Visitor *v) { v->visit(this); }
};

Expand All @@ -209,7 +209,7 @@ class CompileDeclaration : public AttribDeclaration
void setScope(Scope *sc);
void compileIt(Scope *sc);
void semantic(Scope *sc);
const char *kind() const;
const char *kind();
void accept(Visitor *v) { v->visit(this); }
};

Expand All @@ -229,7 +229,7 @@ class UserAttributeDeclaration : public AttribDeclaration
void semantic2(Scope *sc);
static Expressions *concat(Expressions *udas1, Expressions *udas2);
Expressions *getAttributes();
const char *kind() const;
const char *kind();
void accept(Visitor *v) { v->visit(this); }
};

Expand Down
Loading