<html dir="ltr">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style id="owaParaStyle">P {
        MARGIN-TOP: 0px; MARGIN-BOTTOM: 0px
}
</style>
</head>
<body fPStyle="1" ocsi="0">
<div style="direction: ltr;font-family: Tahoma;color: #000000;font-size: 10pt;">
<p>You should probably think of the DIFooBar constructors like reinterpret-casts, not</p>
<p>"go find the thing I actually want" functions.  If you hand DICompileUnit() a node</p>
<p>that is not a compile-unit metadata node, it's not going to tell you that you goofed.</p>
<p> </p>
<p>If you _did_ have a CU metadata node, then DICompileUnit's getDirectory() would</p>
<p>work just fine. But you don't.</p>
<p>--paulr</p>
<p> </p>
<div style="FONT-FAMILY: Times New Roman; COLOR: #000000; FONT-SIZE: 16px">
<hr tabindex="-1">
<div style="DIRECTION: ltr" id="divRpF659137"><font color="#000000" size="2" face="Tahoma"><b>From:</b> llvmdev-bounces@cs.uiuc.edu [llvmdev-bounces@cs.uiuc.edu] on behalf of George Baah [georgebaah@gmail.com]<br>
<b>Sent:</b> Thursday, October 04, 2012 7:19 PM<br>
<b>To:</b> Eric Christopher<br>
<b>Cc:</b> LLVM Developers Mailing List<br>
<b>Subject:</b> Re: [LLVMdev] question<br>
</font><br>
</div>
<div></div>
<div>Hmmm, but it has a getDirectory function.
<div><br>
</div>
<div>-G<br>
<br>
<div class="gmail_quote">On Thu, Oct 4, 2012 at 3:50 PM, Eric Christopher <span dir="ltr">
<<a href="mailto:echristo@gmail.com" target="_blank">echristo@gmail.com</a>></span> wrote:<br>
<blockquote style="BORDER-LEFT: #ccc 1px solid; MARGIN: 0px 0px 0px 0.8ex; PADDING-LEFT: 1ex" class="gmail_quote">
That's because instructions have a location associated with them, not<br>
a compile unit.<br>
<span class="HOEnZb"><font color="#888888"><br>
-eric<br>
</font></span>
<div class="HOEnZb">
<div class="h5"><br>
On Thu, Oct 4, 2012 at 12:46 PM, George Baah <<a href="mailto:georgebaah@gmail.com" target="_blank">georgebaah@gmail.com</a>> wrote:<br>
> I used DILocation instead of DICompileUnit and it works. Hmmm, interesting.<br>
><br>
> George<br>
><br>
> On Thu, Oct 4, 2012 at 1:33 AM, George Baah <<a href="mailto:georgebaah@gmail.com" target="_blank">georgebaah@gmail.com</a>> wrote:<br>
>><br>
>> Here is the code. I am running on llvm 3.1 on Lion (Mac 10.7.4)<br>
>><br>
>> string getFileDirectory(const Instruction &I){<br>
>><br>
>>   MDNode *MD = I.getMetadata("dbg");<br>
>><br>
>>   DICompileUnit compileUnit(MD);<br>
>><br>
>>   return compileUnit.getDirectory().str();<br>
>><br>
>> }<br>
>><br>
>><br>
>> George<br>
>><br>
>> On Wed, Oct 3, 2012 at 12:40 PM, Eric Christopher <<a href="mailto:echristo@gmail.com" target="_blank">echristo@gmail.com</a>><br>
>> wrote:<br>
>>><br>
>>> Without knowing the code that you've written and the IR that you're<br>
>>> running on I'm<br>
>>> not sure what I can do to help you.<br>
>>><br>
>>> -eric<br>
>>><br>
>>> On Wed, Oct 3, 2012 at 9:32 AM, George Baah <<a href="mailto:georgebaah@gmail.com" target="_blank">georgebaah@gmail.com</a>> wrote:<br>
>>> > Yeah, It looks like I am doing exactly what's in Dwarf*.cpp files, yet<br>
>>> > I am<br>
>>> > getting blanks.<br>
>>> ><br>
>>> > George<br>
>>> ><br>
>>> > On Tue, Oct 2, 2012 at 2:10 PM, Eric Christopher <<a href="mailto:echristo@gmail.com" target="_blank">echristo@gmail.com</a>><br>
>>> > wrote:<br>
>>> >><br>
>>> >> On Tue, Oct 2, 2012 at 11:00 AM, George Baah <<a href="mailto:georgebaah@gmail.com" target="_blank">georgebaah@gmail.com</a>><br>
>>> >> wrote:<br>
>>> >> > Hi Guys,<br>
>>> >> >   How does one get the directory of the compilation unit in llvm?<br>
>>> >> > I am using DICompileUnit but for some reason I am getting blanks<br>
>>> >> > for the directory name. Here is my code ...<br>
>>> >> ><br>
>>> >> > MDNode *MD = I.getMetadata("dbg");<br>
>>> >> ><br>
>>> >> > DICompileUnit compileUnit(MD);<br>
>>> >> ><br>
>>> >> > return compileUnit.getDirectory().str();<br>
>>> >> ><br>
>>> >><br>
>>> >> In general for these questions it's easier to look at how it's done in<br>
>>> >> DwarfDebug.cpp and DwarfCompileUnit.cpp.<br>
>>> >><br>
>>> >> -eric<br>
>>> ><br>
>>> ><br>
>><br>
>><br>
><br>
</div>
</div>
</blockquote>
</div>
<br>
</div>
</div>
</div>
</div>
</body>
</html>