<div dir="ltr">Thank you! I move on with multiple simple-value traits for now.</div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Fri, 21 Jun 2019 at 20:13, Artem Dergachev <<a href="mailto:noqnoqneo@gmail.com">noqnoqneo@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<div bgcolor="#FFFFFF">
Mmm, yep, looks annoying. Defining ProgramStatePartialTrait for your
structure isn't hard (there are a lot of examples in
ProgramStateTrait.h) but it essentially requires your structure to
be representable as a void*. Which means that you anyway have to
make a manager/factory object to allocate your structures on the
heap and manage memory. And at this point you no longer need to
specialize ProgramStatePartialTrait because you might as well put a
raw pointer into the trait.<br>
<br>
This whole facility was designed in order to encapsulate the
knowledge about what does the trait actually mean within the
checker. Ironically, these days we believe that such encapsulation
is more harmful than useful, but we didn't get rid of it yet.<br>
<br>
Also you can make multiple traits: one for each field of your
structure. This isn't very object-oriented, but will do the trick as
long as all you need to do is to store a multiple items. You can
also make a getter/setter function to assemble your structure from
multiple traits and disassemble it back into traits.<br>
<br>
<br>
<div class="gmail-m_3062363639923325681moz-cite-prefix">On 6/21/19 5:42 PM, Torry Chen via
cfe-dev wrote:<br>
</div>
<blockquote type="cite">
<div dir="ltr">I'm writing a checker and would like to associate
program states with a custom data structure, e.g. "struct MyData
{...}". When trying REGISTER_TRAIT_WITH_PROGRAMSTATE it doesn't
seem to support custom data types. It's a single value so I
don't want to use LIST or SET.<br>
<br>
Are there other simple ways to register a single compound value
with program state?<br>
</div>
<br>
<fieldset class="gmail-m_3062363639923325681mimeAttachmentHeader"></fieldset>
<pre class="gmail-m_3062363639923325681moz-quote-pre">_______________________________________________
cfe-dev mailing list
<a class="gmail-m_3062363639923325681moz-txt-link-abbreviated" href="mailto:cfe-dev@lists.llvm.org" target="_blank">cfe-dev@lists.llvm.org</a>
<a class="gmail-m_3062363639923325681moz-txt-link-freetext" href="https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev" target="_blank">https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev</a>
</pre>
</blockquote>
<br>
</div>
</blockquote></div>