================
@@ -325,19 +348,27 @@ void FactsGenerator::VisitInitListExpr(const InitListExpr
*ILE) {
void FactsGenerator::VisitMaterializeTemporaryExpr(
const MaterializeTemporaryExpr *MTE) {
OriginList *MTEList = getOriginsList(*MTE);
- if (!MTEList)
+ // Here we also defer from handling lifetime extended materializations.
+ if (!MTEList || MTE->getStorageDuration() != SD_FullExpression)
return;
OriginList *SubExprList = getOriginsList(*MTE->getSubExpr());
if (MTE->isGLValue()) {
assert(!SubExprList ||
MTEList->getLength() == SubExprList->getLength() + 1 &&
"MTE top level origin should contain a loan to the MTE itself");
MTEList = getRValueOrigins(MTE, MTEList);
- // TODO: Issue a loan to the MTE.
+ if (getChildBinding(MTE)) {
+ // Issue a loan to MTE for the storage location represented by MTE.
+ const Loan *L = createLoan(FactMgr, MTE);
+ OriginList *List = getOriginsList(*MTE);
+ CurrentBlockFacts.push_back(
+ FactMgr.createFact<IssueFact>(L->getID(), List->getOuterOriginID()));
+ }
flow(MTEList, SubExprList, /*Kill=*/true);
} else {
- assert(MTE->isXValue());
- flow(MTEList, SubExprList, /*Kill=*/true);
+ // A temporary object's origin is the same as the origin of the
----------------
AbhinavPradeep wrote:
If my understand of value categories is correct, then an `xvalue` is
simultaneously a `glvalue` and an `rvalue`, so I dont know if the else branch
will ever be reached by an `xvalue`? The only thing that would reach there
should be a `prvalue`, and then the `assert(MTE->isXValue());` will throw. Is
this intended behaviour, and if so would you like for me to leave the assert in?
https://github.com/llvm/llvm-project/pull/172007
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits