Skip to content

Commit a57fe84

Browse files
authored
[clang] Implement dump() for AddrLabelDiff APValues (#169505)
1 parent a7f9a4d commit a57fe84

File tree

2 files changed

+26
-1
lines changed

2 files changed

+26
-1
lines changed

clang/lib/AST/TextNodeDumper.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -850,7 +850,10 @@ void TextNodeDumper::Visit(const APValue &Value, QualType Ty) {
850850
return;
851851
}
852852
case APValue::AddrLabelDiff:
853-
OS << "AddrLabelDiff <todo>";
853+
OS << "AddrLabelDiff ";
854+
OS << "&&" << Value.getAddrLabelDiffLHS()->getLabel()->getName();
855+
OS << " - ";
856+
OS << "&&" << Value.getAddrLabelDiffRHS()->getLabel()->getName();
854857
return;
855858
}
856859
llvm_unreachable("Unknown APValue kind!");
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
// Test without serialization:
2+
// RUN: %clang_cc1 -std=c23 -ast-dump %s -ast-dump-filter Test \
3+
// RUN: | FileCheck --strict-whitespace --match-full-lines %s
4+
//
5+
// Test with serialization:
6+
// RUN: %clang_cc1 -triple x86_64-unknown-unknown -Wno-unused-value -std=c23 -emit-pch -o %t %s
7+
// RUN: %clang_cc1 -x c -triple x86_64-unknown-unknown -Wno-unused-value -std=c23 \
8+
// RUN: -include-pch %t -ast-dump-all -ast-dump-filter Test /dev/null \
9+
// RUN: | sed -e "s/ <undeserialized declarations>//" -e "s/ imported//" \
10+
// RUN: | FileCheck --strict-whitespace --match-full-lines %s
11+
12+
13+
// CHECK: | |-value: AddrLabelDiff &&l2 - &&l1
14+
int Test(void) {
15+
constexpr char ar = &&l2 - &&l1;
16+
l1:
17+
return 10;
18+
l2:
19+
return 11;
20+
}
21+
22+

0 commit comments

Comments
 (0)