[PATCH] D154324: [C++20] [Modules] [ODRHash] Use CanonicalType for base classes

Chuanqi Xu via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Jul 11 00:59:50 PDT 2023


This revision was not accepted when it landed; it landed in state "Changes Planned".
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGf82df0b285ac: [C++20] [Modules] Use CanonicalType for base classes (authored by ChuanqiXu).
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D154324

Files:
  clang/lib/AST/ODRHash.cpp
  clang/test/Modules/pr63595.cppm


Index: clang/test/Modules/pr63595.cppm
===================================================================
--- /dev/null
+++ clang/test/Modules/pr63595.cppm
@@ -0,0 +1,44 @@
+// RUN: rm -rf %t
+// RUN: mkdir %t
+// RUN: split-file %s %t
+//
+// RUN: %clang_cc1 -std=c++20 -emit-module-interface -I%t %t/module1.cppm -o %t/module1.pcm
+// RUN: %clang_cc1 -std=c++20 -emit-module-interface -I%t %t/module2.cppm -o %t/module2.pcm
+// RUN: %clang_cc1 -std=c++20 -fprebuilt-module-path=%t %t/merge.cpp -verify -fsyntax-only
+
+//--- header.h
+namespace NS {
+template <int I>
+class A {
+};
+
+template <template <int I_> class T>
+class B {
+};
+}
+
+//--- module1.cppm
+// inside NS, using C = B<A>
+module;
+export module module1;
+#include "header.h"
+namespace NS {
+using C = B<A>;
+}
+export struct D : NS::C {};
+
+//--- module2.cppm
+// inside NS, using C = B<NS::A>
+module;
+export module module2;
+#include "header.h"
+namespace NS {
+using C = B<NS::A>;
+}
+export struct D : NS::C {};
+
+//--- merge.cpp
+// expected-no-diagnostics
+import module1;
+import module2;
+D d;
Index: clang/lib/AST/ODRHash.cpp
===================================================================
--- clang/lib/AST/ODRHash.cpp
+++ clang/lib/AST/ODRHash.cpp
@@ -593,7 +593,7 @@
   ID.AddInteger(Record->getNumBases());
   auto Bases = Record->bases();
   for (const auto &Base : Bases) {
-    AddQualType(Base.getType());
+    AddQualType(Base.getType().getCanonicalType());
     ID.AddInteger(Base.isVirtual());
     ID.AddInteger(Base.getAccessSpecifierAsWritten());
   }


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D154324.538945.patch
Type: text/x-patch
Size: 1558 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20230711/edc8c40f/attachment.bin>


More information about the cfe-commits mailing list