[clang] [Clang] Generate the GEP instead of adding AST nodes (PR #73730)
Aaron Ballman via cfe-commits
cfe-commits at lists.llvm.org
Wed Nov 29 11:00:01 PST 2023
================
@@ -956,42 +956,72 @@ static llvm::Value *getArrayIndexingBound(CodeGenFunction &CGF,
return nullptr;
}
-const Expr *
+namespace {
+
+struct MemberExprBaseVisitor
+ : public StmtVisitor<MemberExprBaseVisitor, Expr *> {
+ MemberExprBaseVisitor() = default;
+
+ //===--------------------------------------------------------------------===//
+ // Visitor Methods
+ //===--------------------------------------------------------------------===//
+
+ Expr *Visit(Expr *E) {
+ return StmtVisitor<MemberExprBaseVisitor, Expr *>::Visit(E);
+ }
+
+ Expr *VisitArraySubscriptExpr(ArraySubscriptExpr *E) {
+ return Visit(E->getBase());
+ }
+ Expr *VisitCastExpr(CastExpr *E) { return Visit(E->getSubExpr()); }
+ Expr *VisitDeclRefExpr(DeclRefExpr *E) { return E; }
+ Expr *VisitMemberExpr(MemberExpr *E) { return Visit(E->getBase()); }
+ Expr *VisitParenExpr(ParenExpr *E) { return Visit(E->getSubExpr()); }
+ Expr *VisitUnaryOperator(UnaryOperator *E) { return Visit(E->getSubExpr()); }
----------------
AaronBallman wrote:
I was thinking of something along the lines of:
```
struct S {
int x, y;
int blah[] __counted_by(x);
} s;
int main() {
int (S::*IHatePMDs)[] = &S::blah;
(s.*IHatePMDs)[0] = 12;
}
```
https://godbolt.org/z/PfzbGd34e
You know... normal everyday code that normal, well-adjusted people think of! Err... ;-)
https://github.com/llvm/llvm-project/pull/73730
More information about the cfe-commits
mailing list