<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Jun 15, 2015 at 6:43 PM, Chandler Carruth <span dir="ltr"><<a href="mailto:chandlerc@google.com" target="_blank">chandlerc@google.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">So, after looking at *doing* this, I'm left with more questions and no good answers. C++ has truly failed me today.<div><br></div><div>This enum is currently designed (and even *documented* as being designed) to allow conversion-to-bool to detect whether any alias is possible (that is, only no-alias becomes false). This makes it *really* easy to write the overwhelming majority of test: if ("do things alias") { bail... }.</div><div><br></div><div>It turns out that it is impossible to do this with C++11 "enum class"es. Despite the fact that they seemed specifically designed to serve these kinds of use cases. They are, IMO, completely useless at this point.</div><div><br></div><div>It also turns out that it is *nearly* impossible to define a normal class and a collection of constants that behave in the way folks generally want a strongly typed enum to behave. It requires class templates, typedefs, constexpr, and like 3x the boilerplate code. Its nuts.[1]</div><div><br></div><div>So the options I see are:</div><div><br></div><div>1) Commit the significant body of code necessary to emulate proper enum classes in C++, and document it as a boilerplate pattern. I might be able to shrink it with some clever macro tricks, but it looks pretty doubtful honestly.</div><div><br></div><div>2) Use "enum class AliasResult { NoAlias, ... }" and update everywhere to say explicitly "... != AliasResult::NoAlias".</div><div><br></div><div>3) Use "enum AliasResult { NoAlias = 0, ... }" and everything Just Works but we pollute the llvm namespace with "NoAlias" and friends.</div><div><br></div><div>4) Use "enum AliasResult { AR_NoAlias = 0, ...}" to get the effect of #2 with some minimal name collision prevention.</div><div><br></div></div></blockquote><div><br></div><div>Or 4.1) make it explicit " ... != AR_NoAlias"</div><div><br></div><div>David</div><div><br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div></div><div>Thoughts?</div><div><br></div><div>-Chandler</div><div><br></div>[1] Here is the completely untested sketch of what seems required: <a href="https://urldefense.proofpoint.com/v2/url?u=https-3A__ghostbin.com_paste_2bso6&d=AwMFaQ&c=8hUWFZcy2Z-Za5rBPlktOQ&r=Mfk2qtn1LTDThVkh6-oGglNfMADXfJdty4_bhmuhMHA&m=tMIE5SQLfEa0hUI9YbH4c71yOy4s_EqRC15W1Nv9ZiI&s=vnRI8GjnUFpxG_ojZFw0FIkbyK_dtUFCixtvV3YnJug&e=" target="_blank">https://ghostbin.com/paste/2bso6</a><div><div class="h5"><br><br><div dir="ltr"><br><div class="gmail_quote"><div dir="ltr">On Mon, Jun 15, 2015 at 6:27 PM Daniel Berlin <<a href="mailto:dberlin@dberlin.org" target="_blank">dberlin@dberlin.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">><br>
> Sad that "alias" is sometimes a noun and sometimes a verb, but if<br>
> it's in the literature, then I guess that's that.<br>
<br>
Yes, you will see both "a may-alias b" and "a is a may-alias of b", etc..<br>
_______________________________________________<br>
LLVM Developers mailing list<br>
<a href="mailto:LLVMdev@cs.uiuc.edu" target="_blank">LLVMdev@cs.uiuc.edu</a> <a href="http://llvm.cs.uiuc.edu" rel="noreferrer" target="_blank">http://llvm.cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev" rel="noreferrer" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev</a><br>
</blockquote></div></div></div></div></div>
<br>_______________________________________________<br>
LLVM Developers mailing list<br>
<a href="mailto:LLVMdev@cs.uiuc.edu">LLVMdev@cs.uiuc.edu</a> <a href="http://llvm.cs.uiuc.edu" rel="noreferrer" target="_blank">http://llvm.cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev" rel="noreferrer" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev</a><br>
<br></blockquote></div><br></div></div>