Please use GitHub pull requests for new patches. Phabricator shutdown timeline
Changeset View
Changeset View
Standalone View
Standalone View
clang/lib/AST/Interp/ByteCodeExprGen.cpp
Show First 20 Lines • Show All 1,390 Lines • ▼ Show 20 Lines | if (const auto CtorExpr = dyn_cast<CXXConstructExpr>(Initializer)) { | ||||
} | } | ||||
return this->emitCall(Func, Initializer); | return this->emitCall(Func, Initializer); | ||||
} else if (const auto *InitList = dyn_cast<InitListExpr>(Initializer)) { | } else if (const auto *InitList = dyn_cast<InitListExpr>(Initializer)) { | ||||
const Record *R = getRecord(InitList->getType()); | const Record *R = getRecord(InitList->getType()); | ||||
unsigned InitIndex = 0; | unsigned InitIndex = 0; | ||||
for (const Expr *Init : InitList->inits()) { | for (const Expr *Init : InitList->inits()) { | ||||
const Record::Field *FieldToInit = R->getField(InitIndex); | |||||
if (!this->emitDupPtr(Initializer)) | if (!this->emitDupPtr(Initializer)) | ||||
return false; | return false; | ||||
if (std::optional<PrimType> T = classify(Init)) { | if (std::optional<PrimType> T = classify(Init)) { | ||||
const Record::Field *FieldToInit = R->getField(InitIndex); | |||||
if (!this->visit(Init)) | if (!this->visit(Init)) | ||||
return false; | return false; | ||||
if (!this->emitInitField(*T, FieldToInit->Offset, Initializer)) | if (!this->emitInitField(*T, FieldToInit->Offset, Initializer)) | ||||
return false; | return false; | ||||
if (!this->emitPopPtr(Initializer)) | if (!this->emitPopPtr(Initializer)) | ||||
return false; | return false; | ||||
} else { | } else { | ||||
// Initializer for a direct base class. | |||||
if (const Record::Base *B = R->getBase(Init->getType())) { | |||||
if (!this->emitGetPtrBasePop(B->Offset, Init)) | |||||
return false; | |||||
if (!this->visitInitializer(Init)) | |||||
return false; | |||||
if (!this->emitPopPtr(Initializer)) | |||||
return false; | |||||
} else { | |||||
const Record::Field *FieldToInit = R->getField(InitIndex); | |||||
// Non-primitive case. Get a pointer to the field-to-initialize | // Non-primitive case. Get a pointer to the field-to-initialize | ||||
// on the stack and recurse into visitInitializer(). | // on the stack and recurse into visitInitializer(). | ||||
if (!this->emitGetPtrField(FieldToInit->Offset, Init)) | if (!this->emitGetPtrField(FieldToInit->Offset, Init)) | ||||
return false; | return false; | ||||
if (!this->visitInitializer(Init)) | if (!this->visitInitializer(Init)) | ||||
return false; | return false; | ||||
if (!this->emitPopPtr(Initializer)) | if (!this->emitPopPtr(Initializer)) | ||||
return false; | return false; | ||||
} | } | ||||
} | |||||
++InitIndex; | ++InitIndex; | ||||
} | } | ||||
return true; | return true; | ||||
} else if (const CallExpr *CE = dyn_cast<CallExpr>(Initializer)) { | } else if (const CallExpr *CE = dyn_cast<CallExpr>(Initializer)) { | ||||
// RVO functions expect a pointer to initialize on the stack. | // RVO functions expect a pointer to initialize on the stack. | ||||
// Dup our existing pointer so it has its own copy to use. | // Dup our existing pointer so it has its own copy to use. | ||||
if (!this->emitDupPtr(Initializer)) | if (!this->emitDupPtr(Initializer)) | ||||
▲ Show 20 Lines • Show All 580 Lines • Show Last 20 Lines |