<html>
  <head>
    <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
  </head>
  <body bgcolor="#FFFFFF" text="#000000">
    <div class="moz-cite-prefix">On 7/4/2014 7:14 AM, Reed Mangino
      wrote:<br>
    </div>
    <blockquote cite="mid:etPan.53b69aa7.17a620c5.cd23@Reeds-rMBP.local"
      type="cite">
      <style>body{font-family:Helvetica,Arial;font-size:13px}</style>
      <div id="bloop_customfont" style="margin: 0px;">
        <div id="bloop_customfont" style="margin: 0px;">Hi,</div>
        <div id="bloop_customfont" style="margin: 0px;"> </div>
        <div id="bloop_customfont" style="margin: 0px;">I know how to
          write a function pass in LLVM to iterate over function decls.
          I'd like to do something similiar using Clang for C/C++/ObjC
          macros (#define foo).</div>
        <div id="bloop_customfont" style="margin: 0px;"> </div>
        <div id="bloop_customfont" style="margin: 0px;">I haven't been
          able to find anything in the docs which describes how to hook
          into Clang's preprocessing phase. Did I just miss it? Are
          there any samples which demonstrate this?</div>
      </div>
    </blockquote>
    <a class="moz-txt-link-rfc2396E" href="https://github.com/mozilla/dxr/blob/master/dxr/plugins/clang/dxr-index.cpp#L956"><https://github.com/mozilla/dxr/blob/master/dxr/plugins/clang/dxr-index.cpp#L956></a>
    and onwards (until about 1087 or so) is the code in DXR that handles
    preprocessor callbacks. There's a bit of nastiness to account for
    trying to support multiple versions of Clang via preprocessor
    declarations, and I use a thunk class to take into account the fact
    that I'm trying to use the same class as both an ASTConsumer and a
    PPCallbacks, which causes issue with double deletes if I don't use a
    thunk (it's also useful for glossing over API differences). The
    thunk is defined here:
    <a class="moz-txt-link-rfc2396E" href="https://github.com/mozilla/dxr/blob/master/dxr/plugins/clang/dxr-index.cpp#L87"><https://github.com/mozilla/dxr/blob/master/dxr/plugins/clang/dxr-index.cpp#L87></a>
    and used here:
<a class="moz-txt-link-rfc2396E" href="https://github.com/mozilla/dxr/blob/master/dxr/plugins/clang/dxr-index.cpp#L161"><https://github.com/mozilla/dxr/blob/master/dxr/plugins/clang/dxr-index.cpp#L161></a>.<br>
    <pre class="moz-signature" cols="72">-- 
Joshua Cranmer
Thunderbird and DXR developer
Source code archæologist</pre>
  </body>
</html>