[LLVMdev] Fwd: Regarding scope information for variable declaration.

Eric Lu eirc.lew at gmail.com
Mon Jul 15 02:40:56 PDT 2013


Thank your reply. Pankaj.

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.
---------- Forwarded message ----------
From: Pankaj Gode [via LLVM] <ml-node+s1065342n59345h22 at n5.nabble.com>
Date: Mon, Jul 15, 2013 at 2:35 PM
Subject: Re: Regarding scope information for variable declaration.
To: "eric.lew" <eirc.lew at gmail.com>


 Hi Eric,

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.
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.
This is not a problem as we can't expect variable declaration in a machine
instruction, I thought.

S
o instead of using machine instructions to collect scope information, (as
used by LexicalScope pass),
I had written code to collect scope information based on LLVM Instructions.
I did this by iterating over 'Function->BasicBlock' instead
of 'MachineFunction->MachineBasicBlock'.
const Function *F1 =  MF->getFunction();
for(Function::const_iterator BB = F1->begin(), E = F1->end();
                                BB != E; ++BB)
  {
     for(BasicBlock::const_iterator ii = BB->begin(), ie = BB->end();
        ii != ie; ++ii)
     {
        const Instruction *I = ii;  //I->dump();//debug
        DebugLoc MIDB = I->getDebugLoc();
      }
   }
 Though this is an overhead as scope information exists,
but I need to collect specific information such as 'start line, end line,
start column, end column'
(End line information should be derived as is not obvious).
Collecting information this way allowed me to get correct scope
information,
and hence I was able to map the variable declaration to the scope. It
worked for me this way.


Regards,
Pankaj


  *From:* eric.lew <[hidden
email]<http://user/SendEmail.jtp?type=node&node=59345&i=0>
>
*To:* [hidden email] <http://user/SendEmail.jtp?type=node&node=59345&i=1>
*Sent:* Friday, July 12, 2013 8:30 AM
*Subject:* Re: [LLVMdev] Regarding scope information for variable
declaration.

I have the same demand. Have you resolved this problems? if so, would you
share me the solution?

Best Regards.

Eric



--
View this message in context:
http://llvm.1065342.n5.nabble.com/Regarding-scope-information-for-variable-declaration-tp47707p59268.html
Sent from the LLVM - Dev mailing list archive at Nabble.com.
_______________________________________________
LLVM Developers mailing list
[hidden email] <http://user/SendEmail.jtp?type=node&node=59345&i=2>
http://llvm.cs.uiuc.edu/
http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev



_______________________________________________
LLVM Developers mailing list
[hidden email] <http://user/SendEmail.jtp?type=node&node=59345&i=3>
http://llvm.cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev


------------------------------
 If you reply to this email, your message will be added to the discussion
below:
http://llvm.1065342.n5.nabble.com/Regarding-scope-information-for-variable-declaration-tp47707p59345.html
 To unsubscribe from Regarding scope information for variable
declaration., click
here<http://llvm.1065342.n5.nabble.com/template/NamlServlet.jtp?macro=unsubscribe_by_code&node=47707&code=ZWlyYy5sZXdAZ21haWwuY29tfDQ3NzA3fC0xNTU4MjU0MTM4>
.
NAML<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>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20130715/0b353f4c/attachment.html>


More information about the llvm-dev mailing list