From: Richard Trieu Date: Tue, 13 Jun 2017 22:21:18 +0000 (+0000) Subject: [ODRHash] Add TemplateArgument kind to hash. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=4249ebf5fb8ab864ce53ff86c1e22f72ff4ad566;p=clang [ODRHash] Add TemplateArgument kind to hash. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@305328 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/AST/ODRHash.cpp b/lib/AST/ODRHash.cpp index 08593da89b..0a4898c94d 100644 --- a/lib/AST/ODRHash.cpp +++ b/lib/AST/ODRHash.cpp @@ -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() { diff --git a/test/Modules/odr_hash.cpp b/test/Modules/odr_hash.cpp index cc953d0c05..b38a0f8f45 100644 --- a/test/Modules/odr_hash.cpp +++ b/test/Modules/odr_hash.cpp @@ -1002,6 +1002,24 @@ S2 s2; #endif } +namespace TemplateArgument { +#if defined(FIRST) +template struct U1{}; +struct S1 { + U1 x; +}; +#elif defined(SECOND) +template 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 {