From: Richard Trieu Date: Fri, 30 Jun 2017 22:40:33 +0000 (+0000) Subject: [ODRHash] Support Type TemplateArgument X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=5739844a09581298d1108c9aa91f2d74cd4962e5;p=clang [ODRHash] Support Type TemplateArgument git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@306904 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/AST/ODRHash.cpp b/lib/AST/ODRHash.cpp index 5c8d151e08..0e44a12257 100644 --- a/lib/AST/ODRHash.cpp +++ b/lib/AST/ODRHash.cpp @@ -146,7 +146,10 @@ void ODRHash::AddTemplateArgument(TemplateArgument TA) { switch (Kind) { case TemplateArgument::Null: + llvm_unreachable("Expected valid TemplateArgument"); case TemplateArgument::Type: + AddQualType(TA.getAsType()); + break; case TemplateArgument::Declaration: case TemplateArgument::NullPtr: case TemplateArgument::Integral: diff --git a/test/Modules/odr_hash.cpp b/test/Modules/odr_hash.cpp index f01c4e836a..3b21397169 100644 --- a/test/Modules/odr_hash.cpp +++ b/test/Modules/odr_hash.cpp @@ -1070,6 +1070,40 @@ S4 s4; // expected-error@first.h:* {{'TemplateArgument::S4::x' from module 'FirstModule' is not present in definition of 'TemplateArgument::S4' in module 'SecondModule'}} // expected-note@second.h:* {{declaration of 'x' does not match}} #endif + +#if defined(FIRST) +template struct U5 {}; +struct S5 { + U5 x; +}; +#elif defined(SECOND) +template struct U5 {}; +struct S5 { + U5 x; +}; +#else +S5 s5; +// expected-error@first.h:* {{'TemplateArgument::S5::x' from module 'FirstModule' is not present in definition of 'TemplateArgument::S5' in module 'SecondModule'}} +// expected-note@second.h:* {{declaration of 'x' does not match}} +#endif + +#if defined(FIRST) +template struct U6 {}; +struct S6 { + U6 x; + U6 y; +}; +#elif defined(SECOND) +template struct U6 {}; +struct S6 { + U6 y; + U6 x; +}; +#else +S6 s6; +// expected-error@second.h:* {{'TemplateArgument::S6' has different definitions in different modules; first difference is definition in module 'SecondModule' found field 'y'}} +// expected-note@first.h:* {{but in 'FirstModule' found field 'x'}} +#endif } namespace TemplateTypeParmType {