Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions clang/lib/AST/InferAlloc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,10 @@ typeContainsPointer(QualType T,
for (QualType CurrentT = T; const auto *TT = CurrentT->getAs<TypedefType>();
CurrentT = TT->getDecl()->getUnderlyingType()) {
const IdentifierInfo *II = TT->getDecl()->getIdentifier();
// Special Case: Syntactically uintptr_t is not a pointer; semantically,
// however, very likely used as such. Therefore, classify uintptr_t as a
// pointer, too.
if (II && II->isStr("uintptr_t"))
// Special Case: Syntactically intptr and uintptr_t are not pointers;
// semantically, however, very likely used as such. Therefore, classify
// intptr_t and uintptr_t as pointers, too.
if (II && (II->isStr("intptr_t") || II->isStr("uintptr_t")))
return true;
}

Expand Down
9 changes: 9 additions & 0 deletions clang/test/CodeGenCXX/alloc-token-pointer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

#include "../Analysis/Inputs/system-header-simulator-cxx.h"

typedef __INTPTR_TYPE__ intptr_t;
typedef __UINTPTR_TYPE__ uintptr_t;

extern "C" {
Expand Down Expand Up @@ -187,6 +188,13 @@ uptr *test_uintptr_isptr2() {
return new uptr;
}

using iptr = intptr_t;
// CHECK-LABEL: define dso_local noundef ptr @_Z17test_intptr_isptrv(
// CHECK: call noalias noundef nonnull ptr @_Znwm(i64 noundef 8){{.*}} !alloc_token [[META_INTPTRT:![0-9]+]]
iptr *test_intptr_isptr() {
return new iptr;
}

// CHECK: [[META_INT]] = !{!"int", i1 false}
// CHECK: [[META_INTPTR]] = !{!"int *", i1 true}
// CHECK: [[META_ULONG]] = !{!"unsigned long", i1 false}
Expand All @@ -195,3 +203,4 @@ uptr *test_uintptr_isptr2() {
// CHECK: [[META_VIRTUALTESTCLASS]] = !{!"VirtualTestClass", i1 true}
// CHECK: [[META_MYSTRUCTUINTPTR]] = !{!"MyStructUintptr", i1 true}
// CHECK: [[META_UINTPTR]] = !{!"unsigned long", i1 true}
// CHECK: [[META_INTPTRT]] = !{!"long", i1 true}