<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body text="#000000" bgcolor="#FFFFFF">
<div class="moz-cite-prefix">On 12/8/17 9:14 PM, Richard Trieu
wrote:<br>
</div>
<blockquote type="cite"
cite="mid:CAPUYKWnATz8HHgvka_f9nPP5ed2OR0jy6AwJWPcU60OUKo2zAA@mail.gmail.com">
<div dir="ltr">Vassil,
<div><br>
</div>
<div>It depends on which parts of the AST you want to be
stable. The ODRHashing is stable across TU's, but it may
depend on information that you don't want to be part of the
hash. For instance, if you have "using F = float;" in you
code, then the hash of TemplateArgument for "float" and for
"F" would be different. If the template specializations you
are dealing with are canonicalized, then the TemplateArgument
hashes should be the same. Otherwise, ODRHash would need to
be changed to suit your requirements.</div>
</div>
</blockquote>
Thanks for the prompt reply! Luckily the decls I will be working
with should be canonicalized. I will give it a try and I will ping
you if I have more questions ;)<br>
<blockquote type="cite"
cite="mid:CAPUYKWnATz8HHgvka_f9nPP5ed2OR0jy6AwJWPcU60OUKo2zAA@mail.gmail.com">
<div class="gmail_extra"><br>
<div class="gmail_quote">On Fri, Dec 8, 2017 at 8:16 AM, Vassil
Vassilev <span dir="ltr"><<a
href="mailto:v.g.vassilev@gmail.com" target="_blank"
moz-do-not-send="true">v.g.vassilev@gmail.com</a>></span>
wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0
.8ex;border-left:1px #ccc solid;padding-left:1ex">Hi
Richard,<br>
<br>
Is there a way to get an ODRHashing which is stable across
translation units? I'd like to use the TemplateArgument
ODRHash to lookup template specializations and deserialize
them only if they are required.<br>
<br>
Many thanks!<span class="HOEnZb"><font color="#888888"><br>
Vassil</font></span>
<div class="HOEnZb">
<div class="h5"><br>
On 6/9/17 11:00 PM, Richard Trieu via cfe-commits wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0
.8ex;border-left:1px #ccc solid;padding-left:1ex">
Author: rtrieu<br>
Date: Fri Jun 9 16:00:10 2017<br>
New Revision: 305110<br>
<br>
URL: <a
href="http://llvm.org/viewvc/llvm-project?rev=305110&view=rev"
rel="noreferrer" target="_blank"
moz-do-not-send="true">http://llvm.org/viewvc/llvm-pr<wbr>oject?rev=305110&view=rev</a><br>
Log:<br>
[ODRHash] Add support for TemplateArgument types.<br>
<br>
Recommit r304592 that was reverted in r304618.
r305104 should have fixed the<br>
issue.<br>
<br>
Modified:<br>
cfe/trunk/lib/AST/ODRHash.cpp<br>
cfe/trunk/test/Modules/odr_ha<wbr>sh.cpp<br>
<br>
Modified: cfe/trunk/lib/AST/ODRHash.cpp<br>
URL: <a
href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ODRHash.cpp?rev=305110&r1=305109&r2=305110&view=diff"
rel="noreferrer" target="_blank"
moz-do-not-send="true">http://llvm.org/viewvc/llvm-pr<wbr>oject/cfe/trunk/lib/AST/ODRHas<wbr>h.cpp?rev=305110&r1=305109&r2=<wbr>305110&view=diff</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- cfe/trunk/lib/AST/ODRHash.cpp (original)<br>
+++ cfe/trunk/lib/AST/ODRHash.cpp Fri Jun 9 16:00:10
2017<br>
@@ -140,7 +140,25 @@ void
ODRHash::AddTemplateName(Templ<wbr>ateNa<br>
}<br>
}<br>
-void ODRHash::AddTemplateArgument(T<wbr>emplateArgument
TA) {}<br>
+void ODRHash::AddTemplateArgument(T<wbr>emplateArgument
TA) {<br>
+ auto Kind = TA.getKind();<br>
+ ID.AddInteger(Kind);<br>
+<br>
+ switch (Kind) {<br>
+ case TemplateArgument::Null:<br>
+ case TemplateArgument::Declaration:<br>
+ case TemplateArgument::NullPtr:<br>
+ case TemplateArgument::Integral:<br>
+ case TemplateArgument::Template:<br>
+ case TemplateArgument::TemplateExpa<wbr>nsion:<br>
+ case TemplateArgument::Expression:<br>
+ case TemplateArgument::Pack:<br>
+ break;<br>
+ case TemplateArgument::Type:<br>
+ AddQualType(TA.getAsType());<br>
+ break;<br>
+ }<br>
+}<br>
void ODRHash::AddTemplateParameterL<wbr>ist(const
TemplateParameterList *TPL) {}<br>
void ODRHash::clear() {<br>
<br>
Modified: cfe/trunk/test/Modules/odr_has<wbr>h.cpp<br>
URL: <a
href="http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/odr_hash.cpp?rev=305110&r1=305109&r2=305110&view=diff"
rel="noreferrer" target="_blank"
moz-do-not-send="true">http://llvm.org/viewvc/llvm-pr<wbr>oject/cfe/trunk/test/Modules/<wbr>odr_hash.cpp?rev=305110&r1=<wbr>305109&r2=305110&view=diff</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- cfe/trunk/test/Modules/odr_has<wbr>h.cpp
(original)<br>
+++ cfe/trunk/test/Modules/odr_has<wbr>h.cpp Fri Jun
9 16:00:10 2017<br>
@@ -900,6 +900,24 @@ S2 s2;<br>
#endif<br>
}<br>
+namespace TemplateArgument {<br>
+#if defined(FIRST)<br>
+template<typename> struct U1 {};<br>
+struct S1 {<br>
+ U1<int> u;<br>
+};<br>
+#elif defined(SECOND)<br>
+template<typename> struct U1 {};<br>
+struct S1 {<br>
+ U1<double> u;<br>
+};<br>
+#else<br>
+S1 s1;<br>
+// <a class="moz-txt-link-abbreviated" href="mailto:expected-error@first.h:*">expected-error@first.h:*</a>
{{'TemplateArgument::S1::u' from module 'FirstModule'
is not present in definition of 'TemplateArgument::S1'
in module 'SecondModule'}}<br>
+// <a class="moz-txt-link-abbreviated" href="mailto:expected-note@second.h:*">expected-note@second.h:*</a> {{declaration of 'u' does
not match}}<br>
+#endif<br>
+}<br>
+<br>
// Interesting cases that should not cause errors.
struct S should not error<br>
// while struct T should error at the access
specifier mismatch at the end.<br>
namespace AllDecls {<br>
<br>
<br>
______________________________<wbr>_________________<br>
cfe-commits mailing list<br>
<a href="mailto:cfe-commits@lists.llvm.org"
target="_blank" moz-do-not-send="true">cfe-commits@lists.llvm.org</a><br>
<a
href="http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits"
rel="noreferrer" target="_blank"
moz-do-not-send="true">http://lists.llvm.org/cgi-bin/<wbr>mailman/listinfo/cfe-commits</a><br>
</blockquote>
<br>
<br>
</div>
</div>
</blockquote>
</div>
<br>
</div>
</blockquote>
<p><br>
</p>
</body>
</html>