mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-10-06 06:44:46 +01:00
[MLIR][NFC] Inline lambda to workaround gcc 9.1,9.2 bug
gcc 9.1/9.2 has a bug (https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90538) which leads to an incorrect error when expanding parameter packs multiple times in a lambda. Inlining this lambda to work around this issue. Reviewed By: rriddle, CarolineConcatto Differential Revision: https://reviews.llvm.org/D81828
This commit is contained in:
+19
-13
@@ -1547,24 +1547,30 @@ void ModulePrinter::printDenseIntOrFPElementsAttr(DenseIntOrFPElementsAttr attr,
|
||||
}
|
||||
|
||||
if (ComplexType complexTy = elementType.dyn_cast<ComplexType>()) {
|
||||
auto printComplexValue = [&](auto complexValues, auto printFn,
|
||||
raw_ostream &os, auto &&... params) {
|
||||
Type complexElementType = complexTy.getElementType();
|
||||
// Note: The if and else below had a common lambda function which invoked
|
||||
// printDenseElementsAttrImpl. This lambda was hitting a bug in gcc 9.1,9.2
|
||||
// and hence was replaced.
|
||||
if (complexElementType.isa<IntegerType>()) {
|
||||
bool isSigned = !complexElementType.isUnsignedInteger();
|
||||
printDenseElementsAttrImpl(attr.isSplat(), type, os, [&](unsigned index) {
|
||||
auto complexValue = *(complexValues.begin() + index);
|
||||
auto complexValue = *(attr.getComplexIntValues().begin() + index);
|
||||
os << "(";
|
||||
printFn(complexValue.real(), os, params...);
|
||||
printDenseIntElement(complexValue.real(), os, isSigned);
|
||||
os << ",";
|
||||
printFn(complexValue.imag(), os, params...);
|
||||
printDenseIntElement(complexValue.imag(), os, isSigned);
|
||||
os << ")";
|
||||
});
|
||||
};
|
||||
|
||||
Type complexElementType = complexTy.getElementType();
|
||||
if (complexElementType.isa<IntegerType>())
|
||||
printComplexValue(attr.getComplexIntValues(), printDenseIntElement, os,
|
||||
/*isSigned=*/!complexElementType.isUnsignedInteger());
|
||||
else
|
||||
printComplexValue(attr.getComplexFloatValues(), printFloatValue, os);
|
||||
} else {
|
||||
printDenseElementsAttrImpl(attr.isSplat(), type, os, [&](unsigned index) {
|
||||
auto complexValue = *(attr.getComplexFloatValues().begin() + index);
|
||||
os << "(";
|
||||
printFloatValue(complexValue.real(), os);
|
||||
os << ",";
|
||||
printFloatValue(complexValue.imag(), os);
|
||||
os << ")";
|
||||
});
|
||||
}
|
||||
} else if (elementType.isIntOrIndex()) {
|
||||
bool isSigned = !elementType.isUnsignedInteger();
|
||||
auto intValues = attr.getIntValues();
|
||||
|
||||
Reference in New Issue
Block a user