Previously, we would generate a single name for all reference
temporaries and allow LLVM to rename them for us. Instead, number the
reference temporaries as we build them in Sema.
Details
Diff Detail
- Repository
- rL LLVM
Event Timeline
Please also propose this mangling scheme on cxx-abi-dev.
lib/AST/ExprCXX.cpp | ||
---|---|---|
1458–1459 ↗ | (On Diff #8947) | auto ES = new (ExtendedBy->getASTContext()) ExtraState; |
1464–1465 ↗ | (On Diff #8947) | Maybe stash the ExtraState* in a variable to avoid repeateding geting it here? |
lib/Sema/SemaInit.cpp | ||
5769 ↗ | (On Diff #8947) | It's not sufficient to start the numbering from 1 each time: we need to number within the topmost InitializedEntity, not just within the subentity for which we're currently building an initializer. Example: struct S { const int &a, const int &b; }; S s = { 1, 2 }; |
lib/Serialization/ASTWriterStmt.cpp | ||
1569–1573 ↗ | (On Diff #8947) | We usually serialize fields in the order they appear in the class (so mangling number would go last). Not a big deal, though. |
include/clang/Sema/Initialization.h | ||
---|---|---|
424 ↗ | (On Diff #8951) | Maybe make this allocate a mangling number and return it, rather than returning a reference to the member? |
lib/Sema/SemaInit.cpp | ||
5381 ↗ | (On Diff #8951) | Maybe pass the ExtendingEntity * into here instead of its decl and a reference to its mangling number? |
5791–5808 ↗ | (On Diff #8951) | You could reorder these to first create the MTE and then performReferenceExtension on it, and avoid the special-casing of the ManglingNumber here: auto *MTE = new (S.Context) MaterializeTemporaryExpr(... /*no extending decl or mangling number*/ ...); if (auto *ExtendingEntity = getEntityForTemporaryLifetimeExtension(&Entity)) { performReferenceExtension(MTE, ExtendingEntity); warnOnLifetimeExtension(...); } |
6196–6218 ↗ | (On Diff #8951) | Likewise here. |