[clang] [PAC] Add support for __ptrauth type qualifier (PR #100830)
Daniil Kovalev via cfe-commits
cfe-commits at lists.llvm.org
Fri Aug 2 01:12:54 PDT 2024
================
@@ -2196,6 +2196,58 @@ Value *ScalarExprEmitter::VisitInitListExpr(InitListExpr *E) {
return V;
}
+static bool isDeclRefKnownNonNull(CodeGenFunction &CGF, const ValueDecl *D) {
+ return !D->isWeak();
+}
+
+static bool isLValueKnownNonNull(CodeGenFunction &CGF, const Expr *E) {
+ E = E->IgnoreParens();
+
+ if (auto *UO = dyn_cast<UnaryOperator>(E)) {
+ if (UO->getOpcode() == UO_Deref) {
+ return CGF.isPointerKnownNonNull(UO->getSubExpr());
+ }
+ }
+
+ if (auto *DRE = dyn_cast<DeclRefExpr>(E)) {
+ return isDeclRefKnownNonNull(CGF, DRE->getDecl());
+ } else if (auto *ME = dyn_cast<MemberExpr>(E)) {
+ if (isa<FieldDecl>(ME->getMemberDecl()))
+ return true;
+ return isDeclRefKnownNonNull(CGF, ME->getMemberDecl());
+ }
+
+ // Array subscripts? Anything else?
+
+ return false;
+}
+
+bool CodeGenFunction::isPointerKnownNonNull(const Expr *E) {
+ assert(E->getType()->isSignableType());
+
+ E = E->IgnoreParens();
+
+ if (isa<CXXThisExpr>(E))
+ return true;
+
+ if (auto *UO = dyn_cast<UnaryOperator>(E)) {
----------------
kovdan01 wrote:
Nit
```suggestion
if (const auto *UO = dyn_cast<UnaryOperator>(E))
```
https://github.com/llvm/llvm-project/pull/100830
More information about the cfe-commits
mailing list