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
Event Timeline
Please also propose this mangling scheme on cxx-abi-dev.
lib/AST/ExprCXX.cpp | ||
---|---|---|
1458–1459 | auto ES = new (ExtendedBy->getASTContext()) ExtraState; | |
1464–1465 | Maybe stash the ExtraState* in a variable to avoid repeateding geting it here? | |
lib/Sema/SemaInit.cpp | ||
5767–5771 | 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 | 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 | Maybe make this allocate a mangling number and return it, rather than returning a reference to the member? | |
lib/Sema/SemaInit.cpp | ||
5381 | Maybe pass the ExtendingEntity * into here instead of its decl and a reference to its mangling number? | |
5791–5808 | 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 | Likewise here. |
Maybe make this allocate a mangling number and return it, rather than returning a reference to the member?