This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG303f20a2cab4: [C++20] [Modules] [Serialization] Deserialize 
(authored by ChuanqiXu).
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Changed prior to commit:
  https://reviews.llvm.org/D139406?vs=480401&id=480735#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D139406

Files:
  clang/include/clang/AST/APValue.h
  clang/include/clang/AST/AbstractBasicReader.h
  clang/lib/AST/APValue.cpp
  clang/test/Modules/pr58716.cppm

Index: clang/test/Modules/pr58716.cppm
===================================================================
--- /dev/null
+++ clang/test/Modules/pr58716.cppm
@@ -0,0 +1,46 @@
+// Tests that the compiler won't crash due to the consteval constructor.
+//
+// REQUIRES: x86-registered-target
+//
+// RUN: rm -rf %t
+// RUN: mkdir -p %t
+// RUN: split-file %s %t
+//
+// RUN: %clang_cc1 -triple=x86_64-linux-gnu -std=c++20 -emit-module-interface %t/m.cppm -o %t/m.pcm
+// RUN: %clang_cc1 -triple=x86_64-linux-gnu -std=c++20 %t/m.pcm -S -emit-llvm -o - | FileCheck %t/m.cppm
+//
+//--- m.cppm
+module;
+#include "fail.h"
+export module mymodule;
+
+// CHECK: @.str = {{.*}}"{}\00"
+// CHECK: store{{.*}}ptr @.str
+
+//--- fail.h
+namespace std { 
+
+template<class _CharT>
+class basic_string_view {
+public:
+    constexpr basic_string_view(const _CharT* __s)
+        : __data_(__s) {}
+
+private:
+    const   _CharT* __data_;
+};
+
+template <class _CharT>
+struct basic_format_string {
+  template <class _Tp>
+  consteval basic_format_string(const _Tp& __str) : __str_{__str} {
+  }
+
+private:
+  basic_string_view<_CharT> __str_;
+};
+}
+
+auto this_fails() -> void {
+    std::basic_format_string<char> __fmt("{}");
+}
Index: clang/lib/AST/APValue.cpp
===================================================================
--- clang/lib/AST/APValue.cpp
+++ clang/lib/AST/APValue.cpp
@@ -156,10 +156,10 @@
 
 APValue::LValuePathSerializationHelper::LValuePathSerializationHelper(
     ArrayRef<LValuePathEntry> Path, QualType ElemTy)
-    : ElemTy((const void *)ElemTy.getTypePtrOrNull()), Path(Path) {}
+    : Ty((const void *)ElemTy.getTypePtrOrNull()), Path(Path) {}
 
 QualType APValue::LValuePathSerializationHelper::getType() {
-  return QualType::getFromOpaquePtr(ElemTy);
+  return QualType::getFromOpaquePtr(Ty);
 }
 
 namespace {
Index: clang/include/clang/AST/AbstractBasicReader.h
===================================================================
--- clang/include/clang/AST/AbstractBasicReader.h
+++ clang/include/clang/AST/AbstractBasicReader.h
@@ -190,7 +190,8 @@
 
   APValue::LValuePathSerializationHelper readLValuePathSerializationHelper(
       SmallVectorImpl<APValue::LValuePathEntry> &path) {
-    auto elemTy = asImpl().readQualType();
+    auto origTy = asImpl().readQualType();
+    auto elemTy = origTy;
     unsigned pathLength = asImpl().readUInt32();
     for (unsigned i = 0; i < pathLength; ++i) {
       if (elemTy->template getAs<RecordType>()) {
@@ -208,7 +209,7 @@
             APValue::LValuePathEntry::ArrayIndex(asImpl().readUInt32()));
       }
     }
-    return APValue::LValuePathSerializationHelper(path, elemTy);
+    return APValue::LValuePathSerializationHelper(path, origTy);
   }
 
   Qualifiers readQualifiers() {
Index: clang/include/clang/AST/APValue.h
===================================================================
--- clang/include/clang/AST/APValue.h
+++ clang/include/clang/AST/APValue.h
@@ -238,7 +238,7 @@
     }
   };
   class LValuePathSerializationHelper {
-    const void *ElemTy;
+    const void *Ty;
 
   public:
     ArrayRef<LValuePathEntry> Path;
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to