Random comment cleanup [nfc]

This commit is contained in:
David Nadlinger 2016-03-27 13:07:02 +01:00
parent e3e2a2a1e0
commit 6c15b4bc8e
2 changed files with 22 additions and 41 deletions

View file

@ -873,23 +873,21 @@ void DtoVarDeclaration(VarDeclaration *vd) {
if (isIrLocalCreated(vd)) {
// Nothing to do if it has already been allocated.
}
/* Named Return Value Optimization (NRVO):
T f(){
T ret; // &ret == hidden pointer
ret = ...
return ret; // NRVO.
}
*/
else if (gIR->func()->retArg && gIR->func()->decl->nrvo_can &&
} else if (gIR->func()->retArg && gIR->func()->decl->nrvo_can &&
gIR->func()->decl->nrvo_var == vd) {
// Named Return Value Optimization (NRVO):
// T f() {
// T ret; // &ret == hidden pointer
// ret = ...
// return ret; // NRVO.
// }
assert(!isSpecialRefVar(vd) && "Can this happen?");
IrLocal *irLocal = getIrLocal(vd, true);
irLocal->value = gIR->func()->retArg;
getIrLocal(vd, true)->value = gIR->func()->retArg;
}
// normal stack variable, allocate storage on the stack if it has not already
// been done
else {
// normal stack variable, allocate storage on the stack if it has not
// already been done
IrLocal *irLocal = getIrLocal(vd, true);
Type *type = isSpecialRefVar(vd) ? vd->type->pointerTo() : vd->type;
@ -967,7 +965,6 @@ DValue *DtoDeclarationExp(Dsymbol *declaration) {
IF_LOG Logger::print("DtoDeclarationExp: %s\n", declaration->toChars());
LOG_SCOPE;
// variable declaration
if (VarDeclaration *vd = declaration->isVarDeclaration()) {
Logger::println("VarDeclaration");
@ -991,23 +988,17 @@ DValue *DtoDeclarationExp(Dsymbol *declaration) {
}
return makeVarDValue(vd->type, vd);
}
// struct declaration
if (StructDeclaration *s = declaration->isStructDeclaration()) {
Logger::println("StructDeclaration");
Declaration_codegen(s);
}
// function declaration
else if (FuncDeclaration *f = declaration->isFuncDeclaration()) {
} else if (FuncDeclaration *f = declaration->isFuncDeclaration()) {
Logger::println("FuncDeclaration");
Declaration_codegen(f);
}
// class
else if (ClassDeclaration *e = declaration->isClassDeclaration()) {
} else if (ClassDeclaration *e = declaration->isClassDeclaration()) {
Logger::println("ClassDeclaration");
Declaration_codegen(e);
}
// attribute declaration
else if (AttribDeclaration *a = declaration->isAttribDeclaration()) {
} else if (AttribDeclaration *a = declaration->isAttribDeclaration()) {
Logger::println("AttribDeclaration");
// choose the right set in case this is a conditional declaration
Dsymbols *d = a->include(nullptr, nullptr);
@ -1016,17 +1007,13 @@ DValue *DtoDeclarationExp(Dsymbol *declaration) {
DtoDeclarationExp((*d)[i]);
}
}
}
// mixin declaration
else if (TemplateMixin *m = declaration->isTemplateMixin()) {
} else if (TemplateMixin *m = declaration->isTemplateMixin()) {
Logger::println("TemplateMixin");
for (unsigned i = 0; i < m->members->dim; ++i) {
Dsymbol *mdsym = static_cast<Dsymbol *>(m->members->data[i]);
DtoDeclarationExp(mdsym);
}
}
// tuple declaration
else if (TupleDeclaration *tupled = declaration->isTupleDeclaration()) {
} else if (TupleDeclaration *tupled = declaration->isTupleDeclaration()) {
Logger::println("TupleDeclaration");
assert(tupled->isexp && "Non-expression tuple decls not handled yet.");
assert(tupled->objects);

View file

@ -1304,25 +1304,20 @@ public:
e->type->toChars());
LOG_SCOPE;
// this is the new slicing code, it's different in that a full slice will no
// longer retain the original pointer.
// but this was broken if there *was* no original pointer, ie. a slice of a
// slice...
// now all slices have *both* the 'len' and 'ptr' fields set to != null.
// value being sliced
LLValue *elen = nullptr;
LLValue *eptr;
DValue *v = toElem(e->e1);
// handle pointer slicing
Type *etype = e->e1->type->toBasetype();
if (etype->ty == Tpointer) {
// pointer slicing
assert(e->lwr);
eptr = v->getRVal();
}
// array slice
else {
// array slice
eptr = DtoArrayPtr(v);
}
@ -1383,8 +1378,7 @@ public:
// no bounds or full slice -> just convert to slice
else {
assert(e->e1->type->toBasetype()->ty != Tpointer);
// if the sliceee is a static array, we use the length of that as DMD
// seems
// if the slicee is a static array, we use the length of that as DMD seems
// to give contrary inconsistent sizesin some multidimensional static
// array cases.
// (namely default initialization, int[16][16] arr; -> int[256] arr = 0;)