<html><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><div>Solution:</div><div>I was using ASTParser.cpp, which allocated an ASTContext on the stack:</div><div><br></div><div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 10px/normal Monaco; color: rgb(38, 71, 75); "><span style="color: #000000">  </span><span style="color: #3f6e74">ASTContext</span><span style="color: #000000"> </span><span style="color: #3f6e74">Context</span><span style="color: #000000">(</span><span style="color: #3f6e74">PP</span><span style="color: #000000">.</span>getSourceManager<span style="color: #000000">(), </span><span style="color: #3f6e74">PP</span><span style="color: #000000">.</span>getTargetInfo<span style="color: #000000">(),</span></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 10px/normal Monaco; color: rgb(38, 71, 75); "><span style="color: #000000">                     </span><span style="color: #3f6e74">PP</span><span style="color: #000000">.</span>getIdentifierTable<span style="color: #000000">(), </span><span style="color: #3f6e74">PP</span><span style="color: #000000">.</span>getSelectorTable<span style="color: #000000">());</span></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 10px/normal Monaco; color: rgb(38, 71, 75); "><font class="Apple-style-span" color="#000000"><br></font></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 10px/normal Monaco; color: rgb(38, 71, 75); "><font class="Apple-style-span" color="#000000" face="Helvetica" size="3"><span class="Apple-style-span" style="font-size: 12px;">When I returned from the method, the ASTContext gets destroyed, after which I wasn't getting valid types.  Changed the line in ASTParser to allocate the ASTContext on the heap:</span></font></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 10px/normal Monaco; color: rgb(38, 71, 75); "><font class="Apple-style-span" color="#000000" face="Helvetica" size="3"><span class="Apple-style-span" style="font-size: 12px;"><br></span></font></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 10px/normal Monaco; color: rgb(38, 71, 75); "><font class="Apple-style-span" color="#000000" face="Helvetica" size="3"><span class="Apple-style-span" style="font-size: 12px;"><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 10px/normal Monaco; color: rgb(63, 110, 116); "><span style="color: #000000">  </span>ASTContext<span style="color: #000000">* </span>Context<span style="color: #000000"> = </span><span style="color: #aa0d91">new</span><span style="color: #000000"> </span>ASTContext<span style="color: #000000">(</span>PP<span style="color: #000000">.</span><span style="color: #26474b">getSourceManager</span><span style="color: #000000">(), </span>PP<span style="color: #000000">.</span><span style="color: #26474b">getTargetInfo</span><span style="color: #000000">(),</span></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 10px/normal Monaco; color: rgb(38, 71, 75); "><span style="color: #000000">                     </span><span style="color: #3f6e74">PP</span><span style="color: #000000">.</span>getIdentifierTable<span style="color: #000000">(), </span><span style="color: #3f6e74">PP</span><span style="color: #000000">.</span>getSelectorTable<span style="color: #000000">());</span></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 10px/normal Monaco; color: rgb(38, 71, 75); "><font class="Apple-style-span" color="#000000"><br></font></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 10px/normal Monaco; color: rgb(38, 71, 75); "><font class="Apple-style-span" color="#000000" face="Helvetica" size="3"><span class="Apple-style-span" style="font-size: 12px;">And <span class="Apple-style-span" style="color: rgb(46, 13, 110); font-family: Monaco; font-size: 10px; ">isObjCInterfaceType<span class="Apple-style-span" style="color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; "> works as expected. Thanks to Ted, Chris, and Steve for helping me out with this.  </span></span></span></font></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 10px/normal Monaco; color: rgb(38, 71, 75); "><font class="Apple-style-span" color="#000000" face="Helvetica" size="3"><span class="Apple-style-span" style="font-size: 12px;"><br></span></font></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 10px/normal Monaco; color: rgb(38, 71, 75); "><font class="Apple-style-span" color="#000000" face="Helvetica" size="3"><span class="Apple-style-span" style="font-size: 12px;">-e</span></font></div></span></font></div></div><br><div><html>On Apr 18, 2008, at 10:55 AM, Chris Lattner wrote:</html><br class="Apple-interchange-newline"><blockquote type="cite"><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><br><div><div>On Apr 18, 2008, at 10:52 AM, Emerson Murphy-Hill wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; ">Ahoy!<div><br></div><div>I'm trying to determine the SourceLocation of an Objective-C instance variable's type, if there is one.  This seemed like a reasonable way to start:</div><div><br></div><div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 10px/normal Monaco; ">    <span style="color: #3f6e74">clang</span>::<span style="color: #5c2699">ObjCIvarDecl</span>* iVar = ... //your ivar here...</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 10px/normal Monaco; ">    <span style="color: #3f6e74">clang</span>::<span style="color: #3f6e74">Type</span>* t = iVar-><span style="color: #2e0d6e">getType</span>().<span style="color: #2e0d6e">getTypePtr</span>();</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 10px/normal Monaco; color: rgb(46, 13, 110); "><span style="color: #000000">    t-></span>isObjCInterfaceType<span style="color: #000000">();</span></div><div><font class="Apple-style-span" face="Monaco" size="2"><span class="Apple-style-span" style="font-size: 10px;"><br></span></font></div><div>Unfortunately, I get an EXC_BAD_ACCESS on the final line.  For the test case I'm working on, I would have expected it to simply return false, since my ivar is an int.</div><div><br></div></div></div></blockquote>What does <span class="Apple-style-span" style="font-family: Monaco; font-size: 10px; ">iVar-><span style="color: rgb(46, 13, 110); ">getType</span>().dump()  print?</span></div><div><font class="Apple-style-span" face="Monaco" size="2"><span class="Apple-style-span" style="font-size: 10px;"><br class="webkit-block-placeholder"></span></font></div><div><font class="Apple-style-span" face="Monaco" size="2"><span class="Apple-style-span" style="font-size: 10px;">Does 'iVar-><span style="color: rgb(46, 13, 110); ">getType</span>()<span class="Apple-style-span" style="color: rgb(46, 13, 110); "><span style="color: rgb(0, 0, 0); ">-></span>isObjCInterfaceType<span style="color: rgb(0, 0, 0); ">()' work?</span></span></span></font></div><div><font class="Apple-style-span" face="Monaco" size="2"><span class="Apple-style-span" style="font-size: 10px;"><br class="webkit-block-placeholder"></span></font></div><div><font class="Apple-style-span" face="Monaco" size="2"><span class="Apple-style-span" style="font-size: 10px;">-Chris</span></font></div></div></blockquote></div><br></body></html>