From 4249ebf5fb8ab864ce53ff86c1e22f72ff4ad566 Mon Sep 17 00:00:00 2001 From: Richard Trieu <rtrieu@google.com> Date: Tue, 13 Jun 2017 22:21:18 +0000 Subject: [PATCH] [ODRHash] Add TemplateArgument kind to hash. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@305328 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/AST/ODRHash.cpp | 6 +++++- test/Modules/odr_hash.cpp | 18 ++++++++++++++++++ 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/lib/AST/ODRHash.cpp b/lib/AST/ODRHash.cpp index 08593da89bb..0a4898c94df 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 cc953d0c054..b38a0f8f45c 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 <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 { -- GitLab