r305360 - [ODRHash] Hash Expr for TemplateArgument::Expression
Richard Trieu via cfe-commits
cfe-commits at lists.llvm.org
Tue Jun 13 18:28:00 PDT 2017
Author: rtrieu
Date: Tue Jun 13 20:28:00 2017
New Revision: 305360
URL: http://llvm.org/viewvc/llvm-project?rev=305360&view=rev
Log:
[ODRHash] Hash Expr for TemplateArgument::Expression
Modified:
cfe/trunk/lib/AST/ODRHash.cpp
cfe/trunk/test/Modules/odr_hash.cpp
Modified: cfe/trunk/lib/AST/ODRHash.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ODRHash.cpp?rev=305360&r1=305359&r2=305360&view=diff
==============================================================================
--- cfe/trunk/lib/AST/ODRHash.cpp (original)
+++ cfe/trunk/lib/AST/ODRHash.cpp Tue Jun 13 20:28:00 2017
@@ -143,6 +143,22 @@ void ODRHash::AddTemplateName(TemplateNa
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) {}
Modified: cfe/trunk/test/Modules/odr_hash.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/odr_hash.cpp?rev=305360&r1=305359&r2=305360&view=diff
==============================================================================
--- cfe/trunk/test/Modules/odr_hash.cpp (original)
+++ cfe/trunk/test/Modules/odr_hash.cpp Tue Jun 13 20:28:00 2017
@@ -1018,6 +1018,39 @@ S1 s1;
// expected-error at first.h:* {{'TemplateArgument::S1::x' from module 'FirstModule' is not present in definition of 'TemplateArgument::S1' in module 'SecondModule'}}
// expected-note at 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 at 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 at 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 at 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 at 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
More information about the cfe-commits
mailing list