[PATCH] D150955: [clang][AST] Propagate the value-dependent bit for VAArgExpr.

Haojian Wu via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri May 19 14:44:00 PDT 2023


This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGd4e935240f02: [clang][AST] Propagate the value-dependent bit for VAArgExpr. (authored by hokein).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D150955/new/

https://reviews.llvm.org/D150955

Files:
  clang/docs/ReleaseNotes.rst
  clang/lib/AST/ComputeDependence.cpp
  clang/test/AST/ast-dump-recovery.c


Index: clang/test/AST/ast-dump-recovery.c
===================================================================
--- clang/test/AST/ast-dump-recovery.c
+++ clang/test/AST/ast-dump-recovery.c
@@ -109,3 +109,11 @@
     b,
   };
 }
+
+// Verify no crash
+void test5_GH62711() {
+  // CHECK:      VAArgExpr {{.*}} 'int' contains-errors
+  // CHECK-NEXT: | `-ImplicitCastExpr {{.*}} '<dependent type>' contains-errors
+  // CHECK-NEXT: |   `-RecoveryExpr {{.*}} '<dependent type>' contains-errors
+  if (__builtin_va_arg(undef, int) << 1);
+}
Index: clang/lib/AST/ComputeDependence.cpp
===================================================================
--- clang/lib/AST/ComputeDependence.cpp
+++ clang/lib/AST/ComputeDependence.cpp
@@ -227,7 +227,7 @@
   auto D = toExprDependenceAsWritten(
                E->getWrittenTypeInfo()->getType()->getDependence()) |
            (E->getSubExpr()->getDependence() & ~ExprDependence::Type);
-  return D & ~ExprDependence::Value;
+  return D;
 }
 
 ExprDependence clang::computeDependence(NoInitExpr *E) {
Index: clang/docs/ReleaseNotes.rst
===================================================================
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -413,6 +413,9 @@
 - Fix a crash when an enum constant has a dependent-type recovery expression for
   C.
   (`#62446 <https://github.com/llvm/llvm-project/issues/62446>`_).
+- Propagate the value-dependent bit for VAArgExpr. Fixes a crash where a
+  __builtin_va_arg call has invalid arguments.
+  (`#62711 <https://github.com/llvm/llvm-project/issues/62711>`_).
 
 Bug Fixes to Compiler Builtins
 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D150955.523943.patch
Type: text/x-patch
Size: 1641 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20230519/ce5dbbb1/attachment.bin>


More information about the cfe-commits mailing list