File tree Expand file tree Collapse file tree 2 files changed +9
-8
lines changed Expand file tree Collapse file tree 2 files changed +9
-8
lines changed Original file line number Diff line number Diff line change @@ -206,12 +206,14 @@ llvm::MDNode *CodeGenTBAA::getTypeInfoHelper(const Type *Ty) {
206
206
if (!CodeGenOpts.PointerTBAA )
207
207
return AnyPtr;
208
208
// Compute the depth of the pointer and generate a tag of the form "p<depth>
209
- // <base type tag>".
209
+ // <base type tag>". Look through pointer and array types to determine the
210
+ // base type.
210
211
unsigned PtrDepth = 0 ;
211
212
do {
212
213
PtrDepth++;
213
- Ty = Ty->getPointeeType ().getTypePtr ();
214
- } while (Ty->isPointerType ());
214
+ Ty = Ty->isPointerType () ? Ty->getPointeeType ().getTypePtr ()
215
+ : Ty->getArrayElementTypeNoTypeQual ();
216
+ } while (Ty->isPointerType () || Ty->isArrayType ());
215
217
Ty = Context.getBaseElementType (QualType (Ty, 0 )).getTypePtr ();
216
218
assert (!isa<VariableArrayType>(Ty));
217
219
// When the underlying type is a builtin type, we compute the pointee type
@@ -230,10 +232,9 @@ llvm::MDNode *CodeGenTBAA::getTypeInfoHelper(const Type *Ty) {
230
232
->getString ();
231
233
TyName = Name;
232
234
} else {
233
- // Be conservative if the type isn't a record type. Handling other types
234
- // may require stripping const-qualifiers inside the type, e.g.
235
- // MemberPointerType.
236
- if (!Ty->isRecordType ())
235
+ // Be conservative if the type a MemberPointerType. Those would require
236
+ // stripping const-qualifiers inside the type.
237
+ if (Ty->isMemberPointerType ())
237
238
return AnyPtr;
238
239
239
240
// For non-builtin types use the mangled name of the canonical type.
Original file line number Diff line number Diff line change @@ -39,4 +39,4 @@ const int * h(const int * (*p)[10], int *(*q)[9]) {
39
39
}
40
40
41
41
// POINTER-TBAA: [[PTRARRAY_TBAA]] = !{[[PTRARRAY_TY:!.+]], [[PTRARRAY_TY]], i64 0}
42
- // POINTER-TBAA: [[PTRARRAY_TY:!.+ ]] = !{!"p1 _ZTSPi ", !4, i64 0}
42
+ // POINTER-TBAA: [[PTRARRAY_TY]] = !{!"p3 int ", !4, i64 0}
You can’t perform that action at this time.
0 commit comments