<div dir="ltr">I failed to ask what sort of tool you were writing and assumed it was standalone and didn't include any other components that may also call <span style="font-size:12.8px">DiagnosticEngine::</span><wbr style="font-size:12.8px"><span style="font-size:12.8px">getCustomDiagID().  If that's not the case, e.g., plugins or clang-tidy checkers, then you shouldn't rely on your set of id's starting at </span><span style="font-size:12.8px">clang::diag::DIAG_UPPER_LIMIT+1.</span><div><span style="font-size:12.8px"><br></span></div><div><span style="font-size:12.8px">However, if you map them to a string anyway, there's no need to create your own contiguous enum.</span></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Feb 1, 2018 at 2:00 PM, Roman Popov <span dir="ltr"><<a href="mailto:ripopov@gmail.com" target="_blank">ripopov@gmail.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="auto">Thanks, this works for me!</div><div class="HOEnZb"><div class="h5"><div class="gmail_extra"><br><div class="gmail_quote">On Feb 1, 2018 1:58 PM, "Don Hinton" <<a href="mailto:hintonda@gmail.com" target="_blank">hintonda@gmail.com</a>> wrote:<br type="attribution"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Btw, you still need to call <span style="font-size:12.8px">DiagnosticEngine::</span><span style="font-size:12.8px">getCust<wbr>omDiagID(), but you can use your new enum to access the new id.</span><div><span style="font-size:12.8px"><br></span></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Feb 1, 2018 at 1:52 PM, Don Hinton <span dir="ltr"><<a href="mailto:hintonda@gmail.com" target="_blank">hintonda@gmail.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"><div>Are you trying to put the actual numerical value in the documentation?  That won't work since it's based on the enum value that gets computed at compile time -- actually via tablegen -- and changes over time as diagnostics are added/removed.</div><div><br></div><div>Tooling may already do this, but if not, just create your own enum that starts at the first available value, clang::diag::DIAG_UPPER_LIMIT, and go from there.  Then you can publish and use those enum values, e.g., MyTool::Some_Diag.  Take a look at how new id numbers are generated and use the same technique, e.g.:</div><div><br></div><div>  <a href="https://clang.llvm.org/doxygen/DiagnosticIDs_8cpp_source.html#l00291" target="_blank">https://clang.llvm.org/doxygen<wbr>/DiagnosticIDs_8cpp_source.htm<wbr>l#l00291</a>).</div><div><br></div><div>If you need a string you can pass on the command line, you can create your own mapping.</div><div><br></div><div>hth...</div><div>don</div><div><br></div></div><div class="gmail_extra"><br><div class="gmail_quote"><div><div class="m_-2047091224699220247m_2181632611418272025h5">On Thu, Feb 1, 2018 at 1:12 PM, Roman Popov via cfe-dev <span dir="ltr"><<a href="mailto:cfe-dev@lists.llvm.org" target="_blank">cfe-dev@lists.llvm.org</a>></span> wrote:<br></div></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div class="m_-2047091224699220247m_2181632611418272025h5"><div dir="ltr">Looks like DiagnosticEngine does not allow to be instantiated with User-supplied IDs.<div>The problem is that DiagnosticIDs is not an interface to IDs database, but rather a final class not designed for inheritance.</div><div><br></div><div>So I don't find a way how Clang diagnostic library can be reused by 3rd party tool.</div></div><div class="m_-2047091224699220247m_2181632611418272025m_-3770165026682907178HOEnZb"><div class="m_-2047091224699220247m_2181632611418272025m_-3770165026682907178h5"><div class="gmail_extra"><br><div class="gmail_quote">2018-02-01 12:10 GMT-08:00 Roman Popov <span dir="ltr"><<a href="mailto:ripopov@gmail.com" target="_blank">ripopov@gmail.com</a>></span>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Hello,<div>I want to create a fixed sets of IDs for error messages in Clang tool. So I can put them into tool documentation.</div><div><br></div><div>Is it possible to somehow assign a fixed ID for diagnostic? DiagnosticEngine::getCustomDia<wbr>gID() generates ID automatically, so I have no control on IDs.</div><div><br></div><div>Should I probably instantiate my own <span style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:small;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline">DiagnosticEngine instead of using one from AstContext ?</span></div><div><br></div><div>Thanks,</div><div>Roman</div></div>
</blockquote></div><br></div>
</div></div><br></div></div>______________________________<wbr>_________________<br>
cfe-dev mailing list<br>
<a href="mailto:cfe-dev@lists.llvm.org" target="_blank">cfe-dev@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/<wbr>mailman/listinfo/cfe-dev</a><br>
<br></blockquote></div><br></div>
</blockquote></div><br></div>
</blockquote></div></div>
</div></div></blockquote></div><br></div>