[clang] 62b5e55 - Revert "[Serialization] Don't try to complete the redeclaration chain in"
Chuanqi Xu via cfe-commits
cfe-commits at lists.llvm.org
Sun May 14 20:19:30 PDT 2023
Author: Chuanqi Xu
Date: 2023-05-15T11:19:17+08:00
New Revision: 62b5e55512d57b083ac07d40b41242c7116a3d20
URL: https://github.com/llvm/llvm-project/commit/62b5e55512d57b083ac07d40b41242c7116a3d20
DIFF: https://github.com/llvm/llvm-project/commit/62b5e55512d57b083ac07d40b41242c7116a3d20.diff
LOG: Revert "[Serialization] Don't try to complete the redeclaration chain in"
Close https://github.com/llvm/llvm-project/issues/62705
This reverts commit cf47e9fe86aa65b74b0476a5ad4d036dd7463bfb. This
introduces a breaking change in
https://github.com/llvm/llvm-project/issues/62705. Revert this one to
fix it quickly.
Added:
clang/test/Modules/pr62705.cppm
Modified:
clang/include/clang/Serialization/ASTReader.h
clang/lib/Serialization/ASTReader.cpp
clang/test/Modules/polluted-operator.cppm
Removed:
################################################################################
diff --git a/clang/include/clang/Serialization/ASTReader.h b/clang/include/clang/Serialization/ASTReader.h
index af01bacbfdc42..1360ee1877c1a 100644
--- a/clang/include/clang/Serialization/ASTReader.h
+++ b/clang/include/clang/Serialization/ASTReader.h
@@ -988,9 +988,6 @@ class ASTReader
///Whether we are currently processing update records.
bool ProcessingUpdateRecords = false;
- /// Whether we are going to write modules.
- bool FinalizedForWriting = false;
-
using SwitchCaseMapTy = llvm::DenseMap<unsigned, SwitchCase *>;
/// Mapping from switch-case IDs in the chain to switch-case statements
diff --git a/clang/lib/Serialization/ASTReader.cpp b/clang/lib/Serialization/ASTReader.cpp
index 93409df3d4fc4..bdf476cf128a3 100644
--- a/clang/lib/Serialization/ASTReader.cpp
+++ b/clang/lib/Serialization/ASTReader.cpp
@@ -5089,8 +5089,7 @@ void ASTReader::InitializeContext() {
}
void ASTReader::finalizeForWriting() {
- assert(!NumCurrentElementsDeserializing && "deserializing when reading");
- FinalizedForWriting = true;
+ // Nothing to do for now.
}
/// Reads and return the signature record from \p PCH's control block, or
@@ -7329,12 +7328,6 @@ Decl *ASTReader::GetExternalDecl(uint32_t ID) {
}
void ASTReader::CompleteRedeclChain(const Decl *D) {
- // We don't need to complete declaration chain after we start writing.
- // We loses more chances to find ODR violation in the writing place and
- // we get more efficient writing process.
- if (FinalizedForWriting)
- return;
-
if (NumCurrentElementsDeserializing) {
// We arrange to not care about the complete redeclaration chain while we're
// deserializing. Just remember that the AST has marked this one as complete
diff --git a/clang/test/Modules/polluted-operator.cppm b/clang/test/Modules/polluted-operator.cppm
index 9b45734432db9..b24464aa6ad21 100644
--- a/clang/test/Modules/polluted-operator.cppm
+++ b/clang/test/Modules/polluted-operator.cppm
@@ -51,20 +51,7 @@ module;
export module b;
import a;
-void b() {
- std::variant<int, double> v;
-}
-
// expected-error@* {{has
diff erent definitions in
diff erent modules; first
diff erence is defined here found data member '_S_copy_ctor' with an initializer}}
// expected-note@* {{but in 'a.<global>' found data member '_S_copy_ctor' with a
diff erent initializer}}
// expected-error@* {{from module 'a.<global>' is not present in definition of 'variant<_Types...>' provided earlier}}
// expected-note@* {{declaration of 'swap' does not match}}
-
-//--- c.cppm
-module;
-#include "bar.h"
-export module c;
-import a;
-
-// expected-error@* {{has
diff erent definitions in
diff erent modules; first
diff erence is defined here found data member '_S_copy_ctor' with an initializer}}
-// expected-note@* {{but in 'a.<global>' found data member '_S_copy_ctor' with a
diff erent initializer}}
diff --git a/clang/test/Modules/pr62705.cppm b/clang/test/Modules/pr62705.cppm
new file mode 100644
index 0000000000000..a09bdf2563e84
--- /dev/null
+++ b/clang/test/Modules/pr62705.cppm
@@ -0,0 +1,48 @@
+// RUN: rm -rf %t
+// RUN: mkdir -p %t
+// RUN: split-file %s %t
+//
+// RUN: %clang_cc1 %t/a.cppm -std=c++20 -triple %itanium_abi_triple \
+// RUN: -emit-module-interface -o %t/a.pcm
+// RUN: %clang_cc1 %t/b.cppm -std=c++20 -triple %itanium_abi_triple \
+// RUN: -emit-module-interface -o %t/b.pcm \
+// RUN: -fmodule-file=a=%t/a.pcm
+// RUN: %clang_cc1 %t/b.pcm -std=c++20 -triple %itanium_abi_triple \
+// RUN: -emit-llvm -o - | FileCheck %t/b.cppm
+
+//--- foo.h
+namespace n {
+
+template<typename>
+struct s0 {
+ static int m;
+};
+
+template<typename T>
+struct s1 {
+ using type = s0<T>;
+};
+
+}
+
+template<typename T>
+void require(n::s1<T>) {
+}
+
+//--- a.cppm
+module;
+
+#include "foo.h"
+
+export module a;
+
+//--- b.cppm
+module;
+
+#include "foo.h"
+
+export module b;
+import a;
+
+// Check the LLVM IR of module 'b' get generated correctly.
+// CHECK: define{{.*}}@_ZGIW1b
More information about the cfe-commits
mailing list