Skip to content

Commit b1e97d6

Browse files
authored
Unwrap CountAttributed for debug info (#86017)
Fix crash caused by 3eb9ff3
1 parent 362d263 commit b1e97d6

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

clang/lib/CodeGen/CGDebugInfo.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3463,6 +3463,9 @@ static QualType UnwrapTypeForDebugInfo(QualType T, const ASTContext &C) {
34633463
case Type::BTFTagAttributed:
34643464
T = cast<BTFTagAttributedType>(T)->getWrappedType();
34653465
break;
3466+
case Type::CountAttributed:
3467+
T = cast<CountAttributedType>(T)->desugar();
3468+
break;
34663469
case Type::Elaborated:
34673470
T = cast<ElaboratedType>(T)->getNamedType();
34683471
break;
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
// RUN: %clang -emit-llvm -DCOUNTED_BY -S -g %s -o - | FileCheck %s
2+
// RUN: %clang -emit-llvm -S -g %s -o - | FileCheck %s
3+
4+
#ifdef COUNTED_BY
5+
#define __counted_by(member) __attribute__((__counted_by__(member)))
6+
#else
7+
#define __counted_by(member)
8+
#endif
9+
10+
struct {
11+
int num_counters;
12+
long value[] __counted_by(num_counters);
13+
} agent_send_response_port_num;
14+
15+
// CHECK: !DICompositeType(tag: DW_TAG_array_type, baseType: ![[BT:.*]], elements: ![[ELEMENTS:.*]])
16+
// CHECK: ![[BT]] = !DIBasicType(name: "long", size: {{.*}}, encoding: DW_ATE_signed)
17+
// CHECK: ![[ELEMENTS]] = !{![[COUNT:.*]]}
18+
// CHECK: ![[COUNT]] = !DISubrange(count: -1)

0 commit comments

Comments
 (0)