Confusion about Alias Analysis Results -print-no-aliases&&-print-alias-sets

Need help about Alias Analysis.
I try to detect use-after-free debug in source code. And my analysis is based on LLVM IR.
I use the following code as a small example. I want to get the result p&&q are alias.
//uaf.cpp

#include
using namespace std;
class A
{
public:
void virtual foo(){};
};
class B:public A
{
public:
void virtual foo(){};
};
int main()
{
B *p=new B();
B *q=p;
p->foo();
delete (p);
q->foo();
return 0;
}

Hi 奋翮求飞,

Need help about Alias Analysis.
I try to detect use-after-free debug in source code. And my analysis is based on
LLVM IR.
I use the following code as a small example. I want to get the result p&&q are
alias.
//uaf.cpp
#include<iostream>
using namespace std;
class A
{
public:
     void virtual foo(){};
};
class B:public A
{
public:
     void virtual foo(){};
};
int main()
{
     B *p=new B();
     B *q=p;
     p->foo();
     delete (p);
     q->foo();
     return 0;
}
--------------------------------------------
$clang++ -emit-llvm -S uaf.cpp -o uaf.ll
$opt -globalsmodref-aa -basicaa -scev-aa -print-alias-sets uaf.ll

you need to run some optimizations if you want alias analysis to be effective
(instead of producing correct but useless results). Try adding -O2 to the
clang command line.

Best wishes, Duncan.