<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
</head>
<body text="#000000" 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="moz-cite-prefix">On 6/21/19 5:42 PM, Torry Chen via
cfe-dev wrote:<br>
</div>
<blockquote type="cite"
cite="mid:CADmWND9ssJQmRkTFwmOXVCj2P0gLPC3CVqQZchzXSyiKPRFExQ@mail.gmail.com">
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<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="mimeAttachmentHeader"></fieldset>
<pre class="moz-quote-pre" wrap="">_______________________________________________
cfe-dev mailing list
<a class="moz-txt-link-abbreviated" href="mailto:cfe-dev@lists.llvm.org">cfe-dev@lists.llvm.org</a>
<a class="moz-txt-link-freetext" href="https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev">https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev</a>
</pre>
</blockquote>
<br>
</body>
</html>