[clang] 1da3169 - [clang][bytecode] Reject void ArraySubscriptExprs (#179619)
via cfe-commits
cfe-commits at lists.llvm.org
Wed Feb 4 05:24:31 PST 2026
Author: Timm Baeder
Date: 2026-02-04T13:24:26Z
New Revision: 1da316985cd1148954f1afce6db7535e9b3eb892
URL: https://github.com/llvm/llvm-project/commit/1da316985cd1148954f1afce6db7535e9b3eb892
DIFF: https://github.com/llvm/llvm-project/commit/1da316985cd1148954f1afce6db7535e9b3eb892.diff
LOG: [clang][bytecode] Reject void ArraySubscriptExprs (#179619)
This happens in C when we subscript an expression of type void*, but
there's nothing for us to do here. Just reject it early.
Fixes https://github.com/llvm/llvm-project/issues/177758
Added:
Modified:
clang/lib/AST/ByteCode/Compiler.cpp
clang/test/AST/ByteCode/builtin-object-size-codegen.c
Removed:
################################################################################
diff --git a/clang/lib/AST/ByteCode/Compiler.cpp b/clang/lib/AST/ByteCode/Compiler.cpp
index db6d562836feb..3bc69716e8ef9 100644
--- a/clang/lib/AST/ByteCode/Compiler.cpp
+++ b/clang/lib/AST/ByteCode/Compiler.cpp
@@ -1780,6 +1780,9 @@ bool Compiler<Emitter>::VisitImplicitValueInitExpr(
template <class Emitter>
bool Compiler<Emitter>::VisitArraySubscriptExpr(const ArraySubscriptExpr *E) {
+ if (E->getType()->isVoidType())
+ return false;
+
const Expr *LHS = E->getLHS();
const Expr *RHS = E->getRHS();
const Expr *Index = E->getIdx();
diff --git a/clang/test/AST/ByteCode/builtin-object-size-codegen.c b/clang/test/AST/ByteCode/builtin-object-size-codegen.c
index c290385935ba4..6aa0485bd65ad 100644
--- a/clang/test/AST/ByteCode/builtin-object-size-codegen.c
+++ b/clang/test/AST/ByteCode/builtin-object-size-codegen.c
@@ -35,3 +35,7 @@
// gi = ObjectSize2(&t[1].t[1]);
}
+/// Used to crash due to the void-typed ArraySubscriptExpr.
+void foo(void *p) {
+ int i = __builtin_object_size(&p[2], 3);
+}
More information about the cfe-commits
mailing list