================
@@ -184,13 +199,24 @@ llvm::MDNode *CodeGenTBAA::getTypeInfoHelper(const Type
*Ty) {
return getChar();
// Handle pointers and references.
- // TODO: Implement C++'s type "similarity" and consider dis-"similar"
- // pointers distinct.
- if (Ty->isPointerType() || Ty->isReferenceType())
- return createScalarTypeNode("any pointer", getChar(), Size);
+ // Pointer types never alias if their pointee type is distinct.
+ if ((Ty->isPointerType() || Ty->isReferenceType())) {
+ llvm::MDNode *AnyPtr = createScalarTypeNode("any pointer", getChar(),
Size);
+ if (!CodeGenOpts.PointerTBAA)
+ return AnyPtr;
+ unsigned PtrDepth = 0;
+ do {
+ PtrDepth++;
+ Ty = Ty->getPointeeType().getTypePtr();
+ } while (!Ty->getPointeeType().isNull());
----------------
dybv-sc wrote:
Actually I want to look for member pointers. In [conv.qual] of C++ standard
mentioned:
> each Pi is “pointer to” (9.3.4.2), “pointer to member of
> class Ci of type” (9.3.4.4), “array of Ni”, or “array of unknown bound of”
> (9.3.4.5
Where Pi is i-th inderection in qualification decomposition. I want to consider
all those types of indirection.
I think, all I do if I get rid of getPointeeType() is just move most of it's
checks outside.
https://github.com/llvm/llvm-project/pull/75177
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits