r305361 - [ODRHash] Hash Template and TemplateExpansion in TemplateArgument.

Richard Trieu via cfe-commits cfe-commits at lists.llvm.org
Tue Jun 13 20:17:26 PDT 2017


Author: rtrieu
Date: Tue Jun 13 22:17:26 2017
New Revision: 305361

URL: http://llvm.org/viewvc/llvm-project?rev=305361&view=rev
Log:
[ODRHash] Hash Template and TemplateExpansion in TemplateArgument.

Modified:
    cfe/trunk/lib/AST/ODRHash.cpp
    cfe/trunk/test/Modules/odr_hash.cpp

Modified: cfe/trunk/lib/AST/ODRHash.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ODRHash.cpp?rev=305361&r1=305360&r2=305361&view=diff
==============================================================================
--- cfe/trunk/lib/AST/ODRHash.cpp (original)
+++ cfe/trunk/lib/AST/ODRHash.cpp Tue Jun 13 22:17:26 2017
@@ -150,13 +150,16 @@ void ODRHash::AddTemplateArgument(Templa
     case TemplateArgument::Declaration:
     case TemplateArgument::NullPtr:
     case TemplateArgument::Integral:
+      break;
     case TemplateArgument::Template:
     case TemplateArgument::TemplateExpansion:
+      AddTemplateName(TA.getAsTemplateOrTemplatePattern());
       break;
     case TemplateArgument::Expression:
       AddStmt(TA.getAsExpr());
       break;
     case TemplateArgument::Pack:
+      llvm_unreachable("Pack");
       break;
   }
 }

Modified: cfe/trunk/test/Modules/odr_hash.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/odr_hash.cpp?rev=305361&r1=305360&r2=305361&view=diff
==============================================================================
--- cfe/trunk/test/Modules/odr_hash.cpp (original)
+++ cfe/trunk/test/Modules/odr_hash.cpp Tue Jun 13 22:17:26 2017
@@ -1051,6 +1051,24 @@ S3 s3;
 // expected-note at first.h:* {{but in 'FirstModule' found type alias 'T' with different underlying type 'U3<2>'}}
 #endif
 
+#if defined(FIRST)
+template<class> struct T4a {};
+template <template <class> class T> struct U4 {};
+struct S4 {
+  U4<T4a> x;
+};
+#elif defined(SECOND)
+template<class> struct T4b {};
+template <template <class> class T> struct U4 {};
+struct S4 {
+  U4<T4b> x;
+};
+#else
+S4 s4;
+// expected-error at first.h:* {{'TemplateArgument::S4::x' from module 'FirstModule' is not present in definition of 'TemplateArgument::S4' in module 'SecondModule'}}
+// expected-note at second.h:* {{declaration of 'x' does not match}}
+#endif
+
 }
 
 // Interesting cases that should not cause errors.  struct S should not error




More information about the cfe-commits mailing list