r305328 - [ODRHash] Add TemplateArgument kind to hash.

Richard Trieu via cfe-commits cfe-commits at lists.llvm.org
Tue Jun 13 15:21:18 PDT 2017


Author: rtrieu
Date: Tue Jun 13 17:21:18 2017
New Revision: 305328

URL: http://llvm.org/viewvc/llvm-project?rev=305328&view=rev
Log:
[ODRHash] Add TemplateArgument kind to hash.

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=305328&r1=305327&r2=305328&view=diff
==============================================================================
--- cfe/trunk/lib/AST/ODRHash.cpp (original)
+++ cfe/trunk/lib/AST/ODRHash.cpp Tue Jun 13 17:21:18 2017
@@ -140,7 +140,11 @@ void ODRHash::AddTemplateName(TemplateNa
   }
 }
 
-void ODRHash::AddTemplateArgument(TemplateArgument TA) {}
+void ODRHash::AddTemplateArgument(TemplateArgument TA) {
+  const auto Kind = TA.getKind();
+  ID.AddInteger(Kind);
+}
+
 void ODRHash::AddTemplateParameterList(const TemplateParameterList *TPL) {}
 
 void ODRHash::clear() {

Modified: cfe/trunk/test/Modules/odr_hash.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/odr_hash.cpp?rev=305328&r1=305327&r2=305328&view=diff
==============================================================================
--- cfe/trunk/test/Modules/odr_hash.cpp (original)
+++ cfe/trunk/test/Modules/odr_hash.cpp Tue Jun 13 17:21:18 2017
@@ -1002,6 +1002,24 @@ S2 s2;
 #endif
 }
 
+namespace TemplateArgument {
+#if defined(FIRST)
+template <class> struct U1{};
+struct S1 {
+  U1<int> x;
+};
+#elif defined(SECOND)
+template <int> struct U1{};
+struct S1 {
+  U1<1> x;
+};
+#else
+S1 s1;
+// expected-error at first.h:* {{'TemplateArgument::S1::x' from module 'FirstModule' is not present in definition of 'TemplateArgument::S1' 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
 // while struct T should error at the access specifier mismatch at the end.
 namespace AllDecls {




More information about the cfe-commits mailing list