================
@@ -319,6 +319,107 @@ ConstantResultStorageKind 
ConstantExpr::getStorageKind(const APValue &Value) {
   }
 }
 
+// Check that V is a valid APValue result of E, i.e. the node type needs to
+// match the APValue kind.
+static void assertAPValueKind(const ConstantExpr *E, const APValue &V) {
+  // FIXME: We shouldn't be creating ConstantExpr nodes for missing APValues in
+  // the first place, but for the time being, accept this for any type.
+  if (V.isAbsent())
+    return;
+
+  if (E->isGLValue()) {
+    // NOTE: The restrictions for lvalue expressions are not 100% clear. We
+    // can't assert(V.isLValue()) because some ConstantExprs are lvalue and
+    // their result is a string literal, so an Array.
----------------
tbaederr wrote:

This exists because for some gcc asm statements, where we use 
`Sema::EvaluateAsString` which gives us an rvalue (i.e. an `APValue` of type 
`Array`), but the subexpression is an lvalue of type `std::string_view`. 
lvlaue-to-rvalue conversion doesn't do anything on record types so that doesn't 
work.

https://github.com/llvm/llvm-project/pull/230388
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to