================
@@ -17928,43 +17928,70 @@ std::optional<std::string> 
Expr::tryEvaluateString(ASTContext &Ctx) const {
   return {};
 }
 
-bool Expr::EvaluateCharRangeAsString(std::string &Result,
-                                     const Expr *SizeExpression,
-                                     const Expr *PtrExpression, ASTContext 
&Ctx,
-                                     EvalResult &Status) const {
-  LValue String;
-  EvalInfo Info(Ctx, Status, EvalInfo::EM_ConstantExpression);
-  Info.InConstantContext = true;
+template <typename T>
+static bool EvaluateCharRangeAsStringImpl(const Expr*, T& Result,
+                                          const Expr *SizeExpression,
+                                          const Expr *PtrExpression, 
ASTContext &Ctx,
+                                          Expr::EvalResult &Status) {
+    LValue String;
+    EvalInfo Info(Ctx, Status, EvalInfo::EM_ConstantExpression);
+    Info.InConstantContext = true;
 
-  FullExpressionRAII Scope(Info);
-  APSInt SizeValue;
-  if (!::EvaluateInteger(SizeExpression, SizeValue, Info))
-    return false;
+    FullExpressionRAII Scope(Info);
+    APSInt SizeValue;
+    if (!::EvaluateInteger(SizeExpression, SizeValue, Info))
+      return false;
 
-  uint64_t Size = SizeValue.getZExtValue();
+    uint64_t Size = SizeValue.getZExtValue();
 
-  if (!::EvaluatePointer(PtrExpression, String, Info))
-    return false;
+    if constexpr(std::is_same_v<APValue, T>)
+        Result = APValue(APValue::UninitArray{}, Size, Size);
+    //else
----------------
erichkeane wrote:

Eh?

https://github.com/llvm/llvm-project/pull/131003
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to