majnemer created this revision.

Using the canonical type instead of the equivalent type can result in
insufficient template instantiations.

This fixes PR31656.


https://reviews.llvm.org/D28788

Files:
  include/clang/AST/Type.h
  test/CodeGenCXX/microsoft-abi-default-cc.cpp


Index: test/CodeGenCXX/microsoft-abi-default-cc.cpp
===================================================================
--- test/CodeGenCXX/microsoft-abi-default-cc.cpp
+++ test/CodeGenCXX/microsoft-abi-default-cc.cpp
@@ -45,3 +45,12 @@
 void static_qux() {}
 // GCABI-LABEL: define void @_Z10static_quxv
 // MSABI: define void @"\01?static_qux@@YAXXZ"
+
+namespace PR31656 {
+template <int I>
+void __cdecl callee(int args[I]);
+// GCABI-LABEL: declare void @_ZN7PR316566calleeILi1EEEvPi(
+// MSABI: declare void @"\01??$callee@$00@PR31656@@YAXQAH@Z"(
+
+void caller() { callee<1>(0); }
+}
Index: include/clang/AST/Type.h
===================================================================
--- include/clang/AST/Type.h
+++ include/clang/AST/Type.h
@@ -3827,13 +3827,13 @@
 
   friend class ASTContext; // creates these
 
-  AttributedType(QualType canon, Kind attrKind,
-                 QualType modified, QualType equivalent)
-    : Type(Attributed, canon, canon->isDependentType(),
-           canon->isInstantiationDependentType(),
-           canon->isVariablyModifiedType(),
-           canon->containsUnexpandedParameterPack()),
-      ModifiedType(modified), EquivalentType(equivalent) {
+  AttributedType(QualType canon, Kind attrKind, QualType modified,
+                 QualType equivalent)
+      : Type(Attributed, canon, equivalent->isDependentType(),
+             equivalent->isInstantiationDependentType(),
+             equivalent->isVariablyModifiedType(),
+             equivalent->containsUnexpandedParameterPack()),
+        ModifiedType(modified), EquivalentType(equivalent) {
     AttributedTypeBits.AttrKind = attrKind;
   }
 


Index: test/CodeGenCXX/microsoft-abi-default-cc.cpp
===================================================================
--- test/CodeGenCXX/microsoft-abi-default-cc.cpp
+++ test/CodeGenCXX/microsoft-abi-default-cc.cpp
@@ -45,3 +45,12 @@
 void static_qux() {}
 // GCABI-LABEL: define void @_Z10static_quxv
 // MSABI: define void @"\01?static_qux@@YAXXZ"
+
+namespace PR31656 {
+template <int I>
+void __cdecl callee(int args[I]);
+// GCABI-LABEL: declare void @_ZN7PR316566calleeILi1EEEvPi(
+// MSABI: declare void @"\01??$callee@$00@PR31656@@YAXQAH@Z"(
+
+void caller() { callee<1>(0); }
+}
Index: include/clang/AST/Type.h
===================================================================
--- include/clang/AST/Type.h
+++ include/clang/AST/Type.h
@@ -3827,13 +3827,13 @@
 
   friend class ASTContext; // creates these
 
-  AttributedType(QualType canon, Kind attrKind,
-                 QualType modified, QualType equivalent)
-    : Type(Attributed, canon, canon->isDependentType(),
-           canon->isInstantiationDependentType(),
-           canon->isVariablyModifiedType(),
-           canon->containsUnexpandedParameterPack()),
-      ModifiedType(modified), EquivalentType(equivalent) {
+  AttributedType(QualType canon, Kind attrKind, QualType modified,
+                 QualType equivalent)
+      : Type(Attributed, canon, equivalent->isDependentType(),
+             equivalent->isInstantiationDependentType(),
+             equivalent->isVariablyModifiedType(),
+             equivalent->containsUnexpandedParameterPack()),
+        ModifiedType(modified), EquivalentType(equivalent) {
     AttributedTypeBits.AttrKind = attrKind;
   }
 
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
  • [PATCH] D28788: [AST] Attri... David Majnemer via Phabricator via cfe-commits

Reply via email to