This CL also makes ScopedEDSCContexts to reset the Bindable numbering when
creating a new context.
This is useful to write minimal tests that don't use FileCheck pattern
captures for now.
PiperOrigin-RevId:
230079997
assert(!ptr || isa<Bindable>() && "expected Bindable");
}
+ friend struct ScopedEDSCContext;
+
private:
+ static void resetIds() { newId() = 0; }
static unsigned &newId();
};
} // namespace detail
-ScopedEDSCContext::ScopedEDSCContext() { Expr::globalAllocator() = &allocator; }
+ScopedEDSCContext::ScopedEDSCContext() {
+ Expr::globalAllocator() = &allocator;
+ Bindable::resetIds();
+}
ScopedEDSCContext::~ScopedEDSCContext() { Expr::globalAllocator() = nullptr; }
} else if (auto un = this->dyn_cast<UnaryExpr>()) {
os << "unknown_unary";
} else if (auto bin = this->dyn_cast<BinaryExpr>()) {
- os << bin.getLHS();
+ os << "(" << bin.getLHS();
switch (bin.getKind()) {
case ExprKind::Add:
os << " + ";
os << "unknown_binary";
}
}
- os << bin.getRHS();
+ os << bin.getRHS() << ")";
+ return;
} else if (auto ter = this->dyn_cast<TernaryExpr>()) {
switch (ter.getKind()) {
case ExprKind::Select:
if (auto stmtExpr = rhs.dyn_cast<StmtBlockLikeExpr>()) {
switch (stmtExpr.getKind()) {
case ExprKind::For:
- os << indent << "for(idx(" << lhs << ")=" << stmtExpr << ") {";
- os << " // @" << storage;
+ os << indent << "for(" << lhs << " = " << stmtExpr << ") {";
os << "\n";
for (const auto &s : getEnclosedStmts()) {
if (!s.getRHS().isa<StmtBlockLikeExpr>()) {
}
}
} else {
- os << "lhs(" << lhs << ") = " << rhs;
+ os << lhs << " = " << rhs;
}
}
}
// CHECK: block {
-// CHECK: for(idx({{.*}})=[[zero1:.*]] to {{.*}} step [[step1:.*]]) {
-// CHECK: for(idx({{.*}})=[[zero1]] to {{.*}} step [[step1]]) {
-// CHECK: for(idx({{.*}})=[[zero1]] to {{.*}} step [[step1]]) {
-// CHECK: for(idx({{.*}})=[[zero1]] to {{.*}} step [[step1]]) {
-// CHECK: lhs({{.*}}) = store( ... );
+// CHECK: for({{.*}}=[[zero1:.*]] to {{.*}} step [[step1:.*]]) {
+// CHECK: for({{.*}}=[[zero1]] to {{.*}} step [[step1]]) {
+// CHECK: for({{.*}}=[[zero1]] to {{.*}} step [[step1]]) {
+// CHECK: for({{.*}}=[[zero1]] to {{.*}} step [[step1]]) {
+// CHECK: {{.*}} = store( ... );
// CHECK: };
// CHECK: };
// CHECK: };
// CHECK: }
// CHECK: }
// CHECK: block {
-// CHECK: for(idx({{.*}})=[[zero2:.*]] to {{.*}} step [[step2:.*]]) {
-// CHECK: for(idx({{.*}})=[[zero2]] to {{.*}} step [[step2]]) {
-// CHECK: lhs({{.*}}) = store( ... );
+// CHECK: for({{.*}}=[[zero2:.*]] to {{.*}} step [[step2:.*]]) {
+// CHECK: for({{.*}}=[[zero2]] to {{.*}} step [[step2]]) {
+// CHECK: {{.*}} = store( ... );
// CHECK: };
// CHECK: }
// CHECK: }