<div dir="ltr"><br>Thank your reply. Pankaj.<div><br></div><div>Actually, I have done it very similar to yours. But I think for my demand, it is better to implement in Front End. Maybe I will re-implement it later in clang.<br>
<div class="gmail_quote">---------- Forwarded message ----------<br>From: <b class="gmail_sendername">Pankaj Gode [via LLVM]</b> <span dir="ltr"><<a href="mailto:ml-node%2Bs1065342n59345h22@n5.nabble.com">ml-node+s1065342n59345h22@n5.nabble.com</a>></span><br>
Date: Mon, Jul 15, 2013 at 2:35 PM<br>Subject: Re: Regarding scope information for variable declaration.<br>To: "eric.lew" <<a href="mailto:eirc.lew@gmail.com">eirc.lew@gmail.com</a>><br><br><br><div class="im">


        <div style="font-size:10pt;font-family:Courier New,courier,monaco,monospace,sans-serif"><span>
<div><span>Hi Eric,</span></div>
<div style="font-style:normal;font-size:13px;background-color:transparent;font-family:Courier New,courier,monaco,monospace,sans-serif"><span></span> </div><span>
<div>I was considering machine instructions to get scope information. And variable declaration does not correspond to machine instruction, hence the problem i.e. no scope associated with it. </div>
<div>If 'i' is initialized in the 'if-scope' then we get 'variable i' mapped to correct scope as corresponding machine instruction is generated for this. </div>
<div>This is not a problem as we can't expect variable declaration in a machine instruction, I thought.</div>
<div> </div>
<div>S</div></span><span>o instead of using machine instructions to collect scope information, (as used by LexicalScope pass), </span></span></div>
<div><span>I had written code to collect scope information based on LLVM Instructions. </span></div>
<div><span>I did this by iterating over 'Function->BasicBlock' instead of 'MachineFunction->MachineBasicBlock'.</span></div>
<div><span>const Function *F1 =  MF->getFunction();<br>for(Function::const_iterator BB = F1->begin(), E = F1->end();<br>                                BB != E; ++BB)<br>  {<br>     for(BasicBlock::const_iterator ii = BB->begin(), ie = BB->end();<br>
        ii != ie; ++ii)<br>     {<br>        const Instruction *I = ii;  //I->dump();//debug<br>        DebugLoc MIDB = I->getDebugLoc();</span></div>
<div><span>      }</span></div>
<div><span>   }</span></div>
<div><span>
<div><span>Though this is an overhead as scope information exists, </span></div>
<div><span>but I need to <var></var>collect specific information such as 'start line, end line, start column, end column' </span></div>
<div><span>(End line information s<var></var>hould be derived as is not obvious).</span></div></span></div>
<div><span>Collecting information this way allowed me to get correct scope information, </span></div>
<div><span>and hence I was able to map the variable declaration to the scope. It worked for me this way.</span></div>
<div><span></span></div>
<div><span></span> </div>
<div> </div>
<div><span>Regards,</span></div>
<div><span>Pankaj</span><br></div>
<div> </div>
<div> </div>
</div><div style="FONT-SIZE:10pt;FONT-FAMILY:Courier New,courier,monaco,monospace,sans-serif">
<div style="FONT-SIZE:12pt;FONT-FAMILY:times new roman,new york,times,serif">
<div dir="ltr">
<div style="FONT-SIZE:0px;BORDER-TOP:#ccc 1px solid;min-height:0px;BORDER-RIGHT:#ccc 1px solid;BORDER-BOTTOM:#ccc 1px solid;PADDING-BOTTOM:0px;PADDING-TOP:0px;PADDING-LEFT:0px;MARGIN:5px 0px;BORDER-LEFT:#ccc 1px solid;LINE-HEIGHT:0;PADDING-RIGHT:0px" readonly>
</div><font face="Arial"><div class="im"><b><span style="FONT-WEIGHT:bold">From:</span></b> eric.lew <<a href="http://user/SendEmail.jtp?type=node&node=59345&i=0" rel="nofollow" link="external" target="_blank">[hidden email]</a>><br>
<b><span style="FONT-WEIGHT:bold">To:</span></b> <a href="http://user/SendEmail.jtp?type=node&node=59345&i=1" rel="nofollow" link="external" target="_blank">[hidden email]</a> <br></div><div class="im"><b><span style="FONT-WEIGHT:bold">Sent:</span></b> Friday, July 12, 2013 8:30 AM<br>
<b><span style="FONT-WEIGHT:bold">Subject:</span></b> Re: [LLVMdev] Regarding scope information for variable declaration.<br></div></font></div>
<div><div class="im"><br>I have the same demand. Have you resolved this problems? if so, would you<br>share me the solution?<br><br>Best Regards.<br><br>Eric<br><br><br><br>--<br>View this message in context: <a href="http://llvm.1065342.n5.nabble.com/Regarding-scope-information-for-variable-declaration-tp47707p59268.html" rel="nofollow" link="external" target="_blank">http://llvm.1065342.n5.nabble.com/Regarding-scope-information-for-variable-declaration-tp47707p59268.html</a><br>
Sent from the LLVM - Dev mailing list archive at Nabble.com.<br>_______________________________________________<br>LLVM Developers mailing list<br></div><div class="im"><a href="http://user/SendEmail.jtp?type=node&node=59345&i=2" rel="nofollow" link="external" target="_blank">[hidden email]</a>        <a href="http://llvm.cs.uiuc.edu/" rel="nofollow" link="external" target="_blank">http://llvm.cs.uiuc.edu/</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev" rel="nofollow" link="external" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev</a><br><br><br></div></div></div></div><div class="im"><br>_______________________________________________
<br>LLVM Developers mailing list
<br></div><div class="im"><a href="http://user/SendEmail.jtp?type=node&node=59345&i=3" rel="nofollow" link="external" target="_blank">[hidden email]</a>         <a href="http://llvm.cs.uiuc.edu" rel="nofollow" link="external" target="_blank">http://llvm.cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev" rel="nofollow" link="external" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev</a><br>

        
        
        
        <br>
        <br>
        <hr noshade size="1" color="#cccccc">
        </div><div style="color:#444;font:12px tahoma,geneva,helvetica,arial,sans-serif"><div class="im">
                <div style="font-weight:bold">If you reply to this email, your message will be added to the discussion below:</div>
                </div><a href="http://llvm.1065342.n5.nabble.com/Regarding-scope-information-for-variable-declaration-tp47707p59345.html" target="_blank">http://llvm.1065342.n5.nabble.com/Regarding-scope-information-for-variable-declaration-tp47707p59345.html</a>
        </div>
        <div style="color:#666;font:11px tahoma,geneva,helvetica,arial,sans-serif;margin-top:.4em;line-height:1.5em">
                
                To unsubscribe from Regarding scope information for variable declaration., <a href="http://llvm.1065342.n5.nabble.com/template/NamlServlet.jtp?macro=unsubscribe_by_code&node=47707&code=ZWlyYy5sZXdAZ21haWwuY29tfDQ3NzA3fC0xNTU4MjU0MTM4" target="_blank">click here</a>.<br>

                <a href="http://llvm.1065342.n5.nabble.com/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace&breadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml" rel="nofollow" style="font:9px serif" target="_blank">NAML</a>
        </div></div><br></div></div>