<html><body><div style="color:#000; background-color:#fff; font-family:Courier New, courier, monaco, monospace, sans-serif;font-size:10pt"><SPAN style="RIGHT: auto">
<DIV id=yiv2471811945yui_3_7_2_18_1373866234488_43><SPAN id=yiv2471811945yui_3_7_2_18_1373866234488_50>Hi Eric,</SPAN></DIV>
<DIV id=yiv2471811945yui_3_7_2_18_1373866234488_244 style="FONT-SIZE: 13px; FONT-FAMILY: Courier New, courier, monaco, monospace, sans-serif; COLOR: rgb(0,0,0); FONT-STYLE: normal; BACKGROUND-COLOR: transparent"><SPAN id=yiv2471811945yui_3_7_2_18_1373866234488_110></SPAN> </DIV><SPAN id=yiv2471811945yui_3_7_2_18_1373866234488_155 style="RIGHT: auto">
<DIV id=yiv2471811945yui_3_7_2_18_1373866234488_1069 style="RIGHT: auto">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 style="RIGHT: auto">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 style="RIGHT: auto">This is not a problem as we can't expect variable declaration in a machine instruction, I thought.</DIV>
<DIV id=yiv2471811945yui_3_7_2_18_1373866234488_2102 style="RIGHT: auto"> </DIV>
<DIV id=yiv2471811945yui_3_7_2_18_1373866234488_2740 style="RIGHT: auto">S</SPAN><SPAN id=yiv2471811945yui_3_7_2_18_1373866234488_245 style="RIGHT: auto">o instead of using machine instructions to collect scope information, (as used by LexicalScope pass), </SPAN></DIV>
<DIV style="RIGHT: auto"><SPAN style="RIGHT: auto">I had written code to collect scope information based on LLVM Instructions. </SPAN></DIV>
<DIV style="RIGHT: auto"><SPAN style="RIGHT: auto">I did this by iterating over 'Function->BasicBlock' instead of 'MachineFunction->MachineBasicBlock'.</SPAN></DIV>
<DIV id=yiv2471811945yui_3_7_2_18_1373866234488_6386 style="RIGHT: auto"><SPAN id=yiv2471811945yui_3_7_2_18_1373866234488_6385 style="RIGHT: auto">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 id=yiv2471811945yui_3_7_2_18_1373866234488_5312>      }</SPAN></DIV>
<DIV><SPAN id=yiv2471811945yui_3_7_2_18_1373866234488_5327>   }</SPAN></DIV>
<DIV style="RIGHT: auto"><SPAN style="RIGHT: auto">
<DIV style="RIGHT: auto"><SPAN id=yiv2471811945yui_3_7_2_18_1373866234488_5302 style="RIGHT: auto">Though this is an overhead as scope information exists, </SPAN></DIV>
<DIV style="RIGHT: auto"><SPAN style="RIGHT: auto">but I need to <VAR id=yui-ie-cursor></VAR>collect specific information such as 'start line, end line, start column, end column' </SPAN></DIV>
<DIV style="RIGHT: auto"><SPAN style="RIGHT: auto">(End line information s<VAR id=yiv2471811945yui-ie-cursor></VAR>hould be derived as is not obvious).</SPAN></DIV></SPAN></DIV>
<DIV style="RIGHT: auto"><SPAN id=yiv2471811945yui_3_7_2_18_1373866234488_5340 style="RIGHT: auto">Collecting information this way allowed me to get correct scope information, </SPAN></DIV>
<DIV style="RIGHT: auto"><SPAN style="RIGHT: auto">and hence I was able to map the variable declaration to the scope. It worked for me this way.</SPAN></DIV>
<DIV><SPAN></DIV>
<DIV id=yiv2471811945yui_3_7_2_18_1373866234488_2042></SPAN><SPAN id=yiv2471811945yui_3_7_2_18_1373866234488_153></SPAN> </DIV>
<DIV> </DIV>
<DIV id=yiv2471811945yui_3_7_2_18_1373866234488_5169 style="RIGHT: auto"><SPAN id=yiv2471811945yui_3_7_2_18_1373866234488_111>Regards,</SPAN></DIV>
<DIV id=yiv2471811945yui_3_7_2_18_1373866234488_154 style="RIGHT: auto"><SPAN id=yiv2471811945yui_3_7_2_18_1373866234488_139 style="RIGHT: auto">Pankaj</SPAN><BR class=yui-cursor style="RIGHT: auto"></SPAN></DIV>
<div style="RIGHT: auto"> </div>
<div style="RIGHT: auto"> </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 class=hr contentEditable=false style="FONT-SIZE: 0px; BORDER-TOP: #ccc 1px solid; 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="true"></DIV><FONT size=2 face=Arial><B><SPAN style="FONT-WEIGHT: bold">From:</SPAN></B> eric.lew <eirc.lew@gmail.com><BR><B><SPAN style="FONT-WEIGHT: bold">To:</SPAN></B> llvmdev@cs.uiuc.edu <BR><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></FONT></DIV>
<DIV class=y_msg_container><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" 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><A href="mailto:LLVMdev@cs.uiuc.edu" ymailto="mailto:LLVMdev@cs.uiuc.edu">LLVMdev@cs.uiuc.edu</A>        <A href="http://llvm.cs.uiuc.edu/" target=_blank>http://llvm.cs.uiuc.edu/</A><BR><A href="http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev"
 target=_blank>http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev</A><BR><BR><BR></DIV></DIV></DIV></div></body></html>