diff options
author | Richard Trieu <rtrieu@google.com> | 2017-06-14 01:28:00 +0000 |
---|---|---|
committer | Richard Trieu <rtrieu@google.com> | 2017-06-14 01:28:00 +0000 |
commit | 1dcb405ca1e7963ffb63e42ca4c67795dc7ff411 (patch) | |
tree | 7c8f3c7915fd02bd0d6c335a0b0e6b0f0ed5f385 /clang | |
parent | b78a68db7bce478394224051517ae401033695cd (diff) | |
download | bcm5719-llvm-1dcb405ca1e7963ffb63e42ca4c67795dc7ff411.tar.gz bcm5719-llvm-1dcb405ca1e7963ffb63e42ca4c67795dc7ff411.zip |
[ODRHash] Hash Expr for TemplateArgument::Expression
llvm-svn: 305360
Diffstat (limited to 'clang')
-rw-r--r-- | clang/lib/AST/ODRHash.cpp | 16 | ||||
-rw-r--r-- | clang/test/Modules/odr_hash.cpp | 33 |
2 files changed, 49 insertions, 0 deletions
diff --git a/clang/lib/AST/ODRHash.cpp b/clang/lib/AST/ODRHash.cpp index 0a4898c94df..83355270c59 100644 --- a/clang/lib/AST/ODRHash.cpp +++ b/clang/lib/AST/ODRHash.cpp @@ -143,6 +143,22 @@ void ODRHash::AddTemplateName(TemplateName Name) { void ODRHash::AddTemplateArgument(TemplateArgument TA) { const auto Kind = TA.getKind(); ID.AddInteger(Kind); + + switch (Kind) { + case TemplateArgument::Null: + case TemplateArgument::Type: + case TemplateArgument::Declaration: + case TemplateArgument::NullPtr: + case TemplateArgument::Integral: + case TemplateArgument::Template: + case TemplateArgument::TemplateExpansion: + break; + case TemplateArgument::Expression: + AddStmt(TA.getAsExpr()); + break; + case TemplateArgument::Pack: + break; + } } void ODRHash::AddTemplateParameterList(const TemplateParameterList *TPL) {} diff --git a/clang/test/Modules/odr_hash.cpp b/clang/test/Modules/odr_hash.cpp index b38a0f8f45c..36f2e4bea00 100644 --- a/clang/test/Modules/odr_hash.cpp +++ b/clang/test/Modules/odr_hash.cpp @@ -1018,6 +1018,39 @@ 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 + +#if defined(FIRST) +template <int> struct U2{}; +struct S2 { + using T = U2<2>; +}; +#elif defined(SECOND) +template <int> struct U2{}; +struct S2 { + using T = U2<(2)>; +}; +#else +S2 s2; +// expected-error@second.h:* {{'TemplateArgument::S2' has different definitions in different modules; first difference is definition in module 'SecondModule' found type alias 'T' with underlying type 'U2<(2)>'}} +// expected-note@first.h:* {{but in 'FirstModule' found type alias 'T' with different underlying type 'U2<2>'}} +#endif + +#if defined(FIRST) +template <int> struct U3{}; +struct S3 { + using T = U3<2>; +}; +#elif defined(SECOND) +template <int> struct U3{}; +struct S3 { + using T = U3<1 + 1>; +}; +#else +S3 s3; +// expected-error@second.h:* {{'TemplateArgument::S3' has different definitions in different modules; first difference is definition in module 'SecondModule' found type alias 'T' with underlying type 'U3<1 + 1>'}} +// expected-note@first.h:* {{but in 'FirstModule' found type alias 'T' with different underlying type 'U3<2>'}} +#endif + } // Interesting cases that should not cause errors. struct S should not error |