[PATCH] D108482: [Clang] Fix instantiation of OpaqueValueExprs (Bug #45964)

Aaron Ballman via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Aug 25 05:44:06 PDT 2021


aaron.ballman added a reviewer: rsmith.
aaron.ballman added inline comments.


================
Comment at: clang/lib/Sema/SemaInit.cpp:8646
       Expr *Cur = CurInit.get();
-      Expr *BaseExpr = new (S.Context)
-          OpaqueValueExpr(Cur->getExprLoc(), Cur->getType(),
-                          Cur->getValueKind(), Cur->getObjectKind(), Cur);
+      // prevent nested OpaqueValueExprs
+      Expr *BaseExpr = dyn_cast<OpaqueValueExpr>(Cur);
----------------



================
Comment at: clang/lib/Sema/TreeTransform.h:10515
+
+  // Note that SourceExpr can be nullptr
+  ExprResult SourceExpr = TransformExpr(E->getSourceExpr());
----------------



================
Comment at: clang/lib/Sema/TreeTransform.h:10519-10521
+  if (SourceExpr.get() == E->getSourceExpr() && !getDerived().AlwaysRebuild()) {
+    return E;
+  }
----------------



================
Comment at: clang/test/SemaCXX/pr45964-nested-ove.cpp:1
+// RUN: %clang_cc1 -std=c++17 -emit-codegen-only -verify %s
+// Don't crash (Bugzilla - Bug 45964).
----------------
I think this test should live in CodeGenCXX rather than SemaCXX as it's testing codegen stuff (and rather than discarding the output, I'd recommend checking the output with `FileCheck` to verify that it looks valid).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D108482



More information about the cfe-commits mailing list