<html><head><meta http-equiv="Content-Type" content="text/html charset=iso-8859-1"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><div><div>On Aug 14, 2012, at 2:32 PM, Richard Trieu <<a href="mailto:rtrieu@google.com">rtrieu@google.com</a>> wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><blockquote class="gmail_quote" style="font-family: Helvetica; font-size: medium; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: -webkit-auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; margin: 0px 0px 0px 0.8ex; border-left-width: 1px; border-left-color: rgb(204, 204, 204); border-left-style: solid; padding-left: 1ex; "><div style="word-wrap: break-word; "><br class="Apple-interchange-newline">At a high level, I honestly find this logic to be more complicated than I would have expected.  The sorting seems unnecessary, and will report diagnostics in an unnatural order (first based on enum constant value, then on declaration order).  A straight linear pass seems more naturally to me, and DenseMap is very efficient.</div></blockquote><div style="font-family: Helvetica; font-size: medium; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: -webkit-auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; ">Is there a comparison between the different containers in LLVM and the STL containers?  Also, will the DenseMap fix the unnatural order of the diagnostics?</div><div style="font-family: Helvetica; font-size: medium; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: -webkit-auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; "> </div></blockquote></div><br><div>With respect to the order of diagnostics, my thought is the container that you use to determine if there are duplicates does not impact the order to issue diagnostics.</div><div><br></div><div>Here's one possible algorithm:</div><div><br></div><div>(1) Iterate through each EnumConstantDecl in *declaration order*.</div><div><br></div><div>For each EnumConstantDecl, consult the DenseMap to count occurrences.  When an occurrence exceeds 1, change the DenseMap data value to instead be an index into another data structure that is *lazily* constructed.  That data structure contains the first EnumConstantDecl we encountered for that constant value, and a sequence of all the other EnumConstantDecls that had the same value.</div><div><br></div><div>(2) Iterate over the second data structure, and print out the warnings.</div><div><br></div><div><br></div><div>This leads to a linear time algorithm where the diagnostics are printed in the order that EnumConstantDecls appear in the source code.</div></body></html>