]> granicus.if.org Git - clang/commitdiff
[ODRHash] Add TemplateArgument kind to hash.
authorRichard Trieu <rtrieu@google.com>
Tue, 13 Jun 2017 22:21:18 +0000 (22:21 +0000)
committerRichard Trieu <rtrieu@google.com>
Tue, 13 Jun 2017 22:21:18 +0000 (22:21 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@305328 91177308-0d34-0410-b5e6-96231b3b80d8

lib/AST/ODRHash.cpp
test/Modules/odr_hash.cpp

index 08593da89bbd8236a33785c4e01b16c5cde0f22a..0a4898c94df5b20b51039f4806d6deec26032056 100644 (file)
@@ -140,7 +140,11 @@ void ODRHash::AddTemplateName(TemplateName Name) {
   }
 }
 
-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() {
index cc953d0c05466c5b799bb300ff4c89206164ea00..b38a0f8f45c02cd17bf116f24d53865b1d9e4e49 100644 (file)
@@ -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@first.h:* {{'TemplateArgument::S1::x' from module 'FirstModule' is not present in definition of 'TemplateArgument::S1' in module 'SecondModule'}}
+// expected-note@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 {