<div dir="ltr">LLVM IR switch instructions always have a default: <a href="https://llvm.org/docs/LangRef.html#switch-instruction">https://llvm.org/docs/LangRef.html#switch-instruction</a> - that jumps over the body of the switch. (when lowering C code to LLVM IR the default would be put after the loop, and the breaks from any case statements would jump over that default block)</div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Fri, Jul 16, 2021 at 12:34 PM Bella V via cfe-users <<a href="mailto:cfe-users@lists.llvm.org">cfe-users@lists.llvm.org</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 dir="ltr"><p class="MsoNormal" style="margin:0cm;font-size:12pt;font-family:Calibri,sans-serif"><span style="font-size:10.5pt;font-family:"Segoe UI",sans-serif;color:rgb(36,41,46)">Hello All,</span></p><p class="MsoNormal" style="margin:0cm;font-size:12pt;font-family:Calibri,sans-serif"><span style="font-size:10.5pt;font-family:"Segoe UI",sans-serif;color:rgb(36,41,46)"> </span></p><p class="MsoNormal" style="margin:0cm;font-size:12pt;font-family:Calibri,sans-serif"><span style="font-size:10.5pt;font-family:"Segoe UI",sans-serif;color:rgb(36,41,46)">I'm trying to find whether SwitchInst has a default statement. I'm
able to iterate through the case values using case_begin
and case_end. If I try to detect default using case_default
which returns an iterator which points to the default case. </span></p><p class="MsoNormal" style="margin:0cm;font-size:12pt;font-family:Calibri,sans-serif"><span style="font-size:10.5pt;font-family:"Segoe UI",sans-serif;color:rgb(36,41,46)">Code Example:</span></p><p class="MsoNormal" style="margin:0cm;font-size:12pt;font-family:Calibri,sans-serif"><span style="font-size:10.5pt;font-family:"Segoe UI",sans-serif;color:rgb(36,41,46)">case_default()->getCaseIndex() or case_default()->getSuccessorIndex() returns the same values for both default and non-default switch C code.</span></p><p class="MsoNormal" style="margin:0cm;font-size:12pt;font-family:Calibri,sans-serif"><span style="font-size:10.5pt;font-family:"Segoe UI",sans-serif;color:rgb(36,41,46)"><br></span></p><p class="MsoNormal" style="margin:0cm;font-size:12pt;font-family:Calibri,sans-serif"><span style="font-size:10.5pt;font-family:"Segoe UI",sans-serif;color:rgb(36,41,46)">Any suggestions to solve this problem?</span></p><p class="MsoNormal" style="margin:0cm;font-size:12pt;font-family:Calibri,sans-serif">
</p><p class="MsoNormal" style="margin:0cm;font-size:12pt;font-family:Calibri,sans-serif"><span style="font-size:10.5pt;font-family:"Segoe UI",sans-serif;color:rgb(36,41,46)"><br></span></p><p class="MsoNormal" style="margin:0cm;font-size:12pt;font-family:Calibri,sans-serif"><span style="font-size:10.5pt;font-family:"Segoe UI",sans-serif;color:rgb(36,41,46)">Regards.</span></p></div>
_______________________________________________<br>
cfe-users mailing list<br>
<a href="mailto:cfe-users@lists.llvm.org" target="_blank">cfe-users@lists.llvm.org</a><br>
<a href="https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-users" rel="noreferrer" target="_blank">https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-users</a><br>
</blockquote></div>