<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">Richard,<div class=""><br class=""></div><div class="">thanks for getting back to me!  The fix you proposed resolved the bug for me – and removing the code you said was redundant also worked fine.</div><div class=""><br class=""></div><div class="">Sean</div><div class=""><br class=""></div><div class=""><div><blockquote type="cite" class=""><div class="">On Jul 29, 2015, at 5:36 PM, Richard Smith <<a href="mailto:richard@metafoo.co.uk" class="">richard@metafoo.co.uk</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div dir="ltr" class=""><div class="gmail_extra"><div class="gmail_quote">On Wed, Jul 29, 2015 at 5:35 PM, Richard Smith <span dir="ltr" class=""><<a href="mailto:richard@metafoo.co.uk" target="_blank" class="">richard@metafoo.co.uk</a>></span> wrote:<br class=""><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr" class=""><div class="gmail_extra"><div class="gmail_quote"><span class="">On Wed, Jul 29, 2015 at 10:43 AM, Sean Callanan <span dir="ltr" class=""><<a href="mailto:scallanan@apple.com" target="_blank" class="">scallanan@apple.com</a>></span> wrote:<br class=""><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word" class="">LLDB’s module support (implemented here: <a href="https://urldefense.proofpoint.com/v2/url?u=http-3A__llvm.org_svn_llvm-2Dproject_lldb_trunk_source_Expression_ClangModulesDeclVendor.cpp&d=AwMFaQ&c=8hUWFZcy2Z-Za5rBPlktOQ&r=CnzuN65ENJ1H9py9XLiRvC_UQz6u3oG6GUNn7_wosSM&m=qJ7PzNcXqcUiCKOoFs9S4BDpb3TOf64WitZDB3JoLdM&s=WSvUUkZckMbgeN5UAaJKYWcqxxQzarzUBnC0_xfDRZ4&e=" target="_blank" class="">http://llvm.org/svn/llvm-project/lldb/trunk/source/Expression/ClangModulesDeclVendor.cpp</a>) sets up its own CompilerInstance and then loads modules into it.<div class=""><br class=""></div><div class="">The way we import macros from modules into expressions is by textual inclusion – we iterate across the macros like this:</div><div class=""><br class=""></div><div class="">–</div><div class=""><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo" class=""><div style="color:rgb(49,89,93);margin:0px;line-height:normal" class=""><span style="color:#bb2ca2" class="">if</span><span style="" class=""> (</span><span style="color:#4f8187" class="">m_compiler_instance</span><span style="" class="">-></span>getPreprocessor<span style="" class="">().</span>getExternalSource<span style="" class="">())</span></div><div style="color:rgb(79,129,135);margin:0px;line-height:normal" class=""><span style="" class="">{</span></div><div style="margin:0px;line-height:normal" class="">  <span style="color:rgb(79,129,135)" class="">m_compiler_instance</span><span style="" class="">-></span><font color="#31595d" class="">getPreprocessor</font><span style="" class="">().</span><font color="#31595d" class="">getExternalSource</font><span style="" class="">()-></span><font color="#31595d" class="">ReadDefinedMacros</font><span style="" class="">();</span></div></div></div></div></blockquote></span></div></div></div></blockquote><div class=""><br class=""></div><div class="">FYI, this is redundant; macro_begin does this for you.</div><div class=""> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr" class=""><div class="gmail_extra"><div class="gmail_quote"><span class=""><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word" class=""><div class=""><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo" class=""><div style="color:rgb(79,129,135);margin:0px;line-height:normal" class=""><span style="" class="">}</span></div><div style="color:rgb(79,129,135)" class=""><br class=""></div></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(79,129,135)" class=""><span style="color:#bb2ca2" class=""><br class=""></span></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(79,129,135)" class=""><span style="color:#bb2ca2" class="">for</span><span style="" class=""> (</span>clang<span style="" class="">::</span>Preprocessor<span style="" class="">::</span>macro_iterator<span style="" class=""> mi = </span>m_compiler_instance<span style="" class="">-></span><span style="color:#31595d" class="">getPreprocessor</span><span style="" class="">().</span><span style="color:#31595d" class="">macro_begin</span><span style="" class="">(),</span></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo" class="">                                         me = <span style="color:#4f8187" class="">m_compiler_instance</span>-><span style="color:#31595d" class="">getPreprocessor</span>().<span style="color:#31595d" class="">macro_end</span>();</div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo" class="">     mi != me; ++mi)</div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(79,129,135)" class=""><span style="" class="">{</span></div></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo" class=""><span style="color:rgb(79,129,135)" class="">  </span><span style="color:rgb(0,132,0)" class="">// ...</span></div><div class=""><span style="font-family:Menlo;font-size:11px" class="">  </span><span style="font-family:Menlo;font-size:11px;color:rgb(79,129,135)" class="">clang</span><span style="font-family:Menlo;font-size:11px" class="">::</span><span style="font-family:Menlo;font-size:11px;color:rgb(79,129,135)" class="">MacroInfo</span><span style="font-family:Menlo;font-size:11px" class=""> *macro_info = </span><span style="font-family:Menlo;font-size:11px;color:rgb(187,44,162)" class="">nullptr</span><span style="font-family:Menlo;font-size:11px" class="">;</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; min-height: 13px;" class="">        <br class=""></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo" class="">  <span style="color:#bb2ca2" class="">for</span> (<span style="color:#4f8187" class="">clang</span>::<span style="color:#4f8187" class="">ModuleMacro</span> *module_macro : <span style="color:#4f8187" class="">m_compiler_instance</span>-><span style="color:#31595d" class="">getPreprocessor</span>().<span style="color:#31595d" class="">getLeafModuleMacros</span>(ii))</div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo" class="">  {</div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo" class="">    <span style="color:rgb(0,132,0)" class="">// pick the macro_info from the module we care most about; that might be NULL</span></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo" class="">  }</div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; min-height: 13px;" class="">        <br class=""></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo" class="">  <span style="color:#bb2ca2" class="">if</span> (macro_info)</div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo" class="">  {</div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo" class="">    <span style="color:rgb(0,132,0)" class="">// make a string from the macro</span></div><div class=""><span style="font-family:Menlo;font-size:11px" class="">  }</span></div><div class=""><font face="Menlo" class=""><span style="font-size:11px" class="">}</span></font></div><div class="">–</div><div class=""><br class=""></div><div class="">What Im noticing is that a macro (say, “MAX”) doesn’t appear in the <span style="font-family:Menlo;font-size:11px;color:rgb(49,89,93)" class="">macro_begin</span><span style="font-family:Menlo;font-size:11px" class="">()</span> list at all.  Only later, after I’ve done a name lookup for “MAX" (on the assumption that it might be a variable, see <span style="color:rgb(79,129,135);font-family:Menlo;font-size:11px" class="">ClangModulesDeclVendorImpl</span><span style="font-family:Menlo;font-size:11px" class="">::FindDecls</span><span style="font-family:Menlo;font-size:11px" class="">()</span>), does it appear in the list.</div><div class=""><br class=""></div><div class="">Is there something else I need to tickle here, or is this a bug in the API?</div></div></blockquote><div class=""><br class=""></div></span><div class="">Does this help:</div><div class=""><br class=""></div><div class=""><div class="">Index: lib/Serialization/ASTReader.cpp</div><div class="">===================================================================</div><div class="">--- lib/Serialization/ASTReader.cpp     (revision 243368)</div><div class="">+++ lib/Serialization/ASTReader.cpp     (working copy)</div><div class="">@@ -1623,7 +1623,7 @@</div><div class=""><br class=""></div><div class="">         case PP_MACRO_OBJECT_LIKE:</div><div class="">         case PP_MACRO_FUNCTION_LIKE:</div><div class="">-          getLocalIdentifier(**I, Record[0]);</div><div class="">+          updateOutOfDateIdentifier(*getLocalIdentifier(**I, Record[0]));</div><div class="">           break;</div><div class=""><br class=""></div><div class="">         case PP_TOKEN:</div></div><div class=""><br class=""></div></div></div></div>
</blockquote></div><br class=""></div></div>
</div></blockquote></div><br class=""></div></body></html>