class StringList {
public:
+ enum Format {
+ kArrayBrackets,
+ kSetBrackets,
+ };
+
// Create an empty list
- StringList() : is_empty_(true) {}
+ StringList(Format format = kArrayBrackets) : format_(format), is_empty_(true) {}
// Construct StringList from a linked list. List element class T
// must provide methods `GetNext` and `Dump`.
template<class T>
- explicit StringList(T* first_entry) : StringList() {
+ explicit StringList(T* first_entry, Format format = kArrayBrackets) : StringList(format) {
for (T* current = first_entry; current != nullptr; current = current->GetNext()) {
current->Dump(NewEntryStream());
}
}
private:
+ Format format_;
bool is_empty_;
std::ostringstream sstream_;
};
std::ostream& operator<<(std::ostream& os, const StringList& list) {
- return os << "[" << list.sstream_.str() << "]";
+ if (list.format_ == StringList::kArrayBrackets) {
+ return os << "[" << list.sstream_.str() << "]";
+ } else {
+ DCHECK_EQ(list.format_, StringList::kSetBrackets);
+ return os << "{" << list.sstream_.str() << "}";
+ }
}
/**
StartAttributeStream("liveness") << instruction->GetLifetimePosition();
if (instruction->HasLiveInterval()) {
LiveInterval* interval = instruction->GetLiveInterval();
- StartAttributeStream("ranges") << StringList(interval->GetFirstRange());
+ StartAttributeStream("ranges")
+ << StringList(interval->GetFirstRange(), StringList::kSetBrackets);
StartAttributeStream("uses") << StringList(interval->GetFirstUse());
StartAttributeStream("env_uses") << StringList(interval->GetFirstEnvironmentUse());
StartAttributeStream("is_fixed") << interval->IsFixed();
public class Main {
// CHECK-START: void Main.loop1(boolean) liveness (after)
- // CHECK: ParameterValue liveness:2 ranges:[2-22] uses:[17,22]
+ // CHECK: ParameterValue liveness:2 ranges:{[2,22)} uses:[17,22]
// CHECK: Goto liveness:20
public static void loop1(boolean incoming) {
while (incoming) {}
}
// CHECK-START: void Main.loop2(boolean) liveness (after)
- // CHECK: ParameterValue liveness:2 ranges:[2-42] uses:[33,38,42]
+ // CHECK: ParameterValue liveness:2 ranges:{[2,42)} uses:[33,38,42]
// CHECK: Goto liveness:36
// CHECK: Goto liveness:40
public static void loop2(boolean incoming) {
}
// CHECK-START: void Main.loop3(boolean) liveness (after)
- // CHECK: ParameterValue liveness:2 ranges:[2-60] uses:[56,60]
+ // CHECK: ParameterValue liveness:2 ranges:{[2,60)} uses:[56,60]
// CHECK: Goto liveness:58
// CHECK-START: void Main.loop3(boolean) liveness (after)
}
// CHECK-START: void Main.loop4(boolean) liveness (after)
- // CHECK: ParameterValue liveness:2 ranges:[2-22] uses:[22]
+ // CHECK: ParameterValue liveness:2 ranges:{[2,22)} uses:[22]
// CHECK-START: void Main.loop4(boolean) liveness (after)
// CHECK-NOT: Goto liveness:20
}
// CHECK-START: void Main.loop5(boolean) liveness (after)
- // CHECK: ParameterValue liveness:2 ranges:[2-50] uses:[33,42,46,50]
+ // CHECK: ParameterValue liveness:2 ranges:{[2,50)} uses:[33,42,46,50]
// CHECK: Goto liveness:44
// CHECK: Goto liveness:48
public static void loop5(boolean incoming) {
}
// CHECK-START: void Main.loop6(boolean) liveness (after)
- // CHECK ParameterValue liveness:2 ranges:[2-46] uses:[24,46]
+ // CHECK ParameterValue liveness:2 ranges:{[2,46)} uses:[24,46]
// CHECK: Goto liveness:44
// CHECK-START: void Main.loop6(boolean) liveness (after)
}
// CHECK-START: void Main.loop7(boolean) liveness (after)
- // CHECK: ParameterValue liveness:2 ranges:[2-50] uses:[32,41,46,50]
+ // CHECK: ParameterValue liveness:2 ranges:{[2,50)} uses:[32,41,46,50]
// CHECK: Goto liveness:44
// CHECK: Goto liveness:48
public static void loop7(boolean incoming) {
}
// CHECK-START: void Main.loop8() liveness (after)
- // CHECK: StaticFieldGet liveness:12 ranges:[12-44] uses:[35,40,44]
+ // CHECK: StaticFieldGet liveness:12 ranges:{[12,44)} uses:[35,40,44]
// CHECK: Goto liveness:38
// CHECK: Goto liveness:42
public static void loop8() {
}
// CHECK-START: void Main.loop9() liveness (after)
- // CHECK: StaticFieldGet liveness:22 ranges:[22-36] uses:[31,36]
+ // CHECK: StaticFieldGet liveness:22 ranges:{[22,36)} uses:[31,36]
// CHECK: Goto liveness:38
public static void loop9() {
while (Runtime.getRuntime() != null) {