<html>
  <head>
    <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
  </head>
  <body text="#000000" bgcolor="#FFFFFF">
    <div class="moz-cite-prefix">Thanks It works!<br>
      <br>
      <br>
      On 03/04/2015 18:42, David Blaikie wrote:<br>
    </div>
    <blockquote
cite="mid:CAENS6EtEPq0DWPynQy27amTYOO+gPWQrFht4Vqvx4vj7e8UoGw@mail.gmail.com"
      type="cite">
      <div dir="ltr"><br>
        <div class="gmail_extra"><br>
          <div class="gmail_quote">On Fri, Apr 3, 2015 at 9:31 AM,
            cedlemo <span dir="ltr"><<a moz-do-not-send="true"
                href="mailto:cedlemo@gmx.com" target="_blank">cedlemo@gmx.com</a>></span>
            wrote:<br>
            <blockquote class="gmail_quote" style="margin:0 0 0
              .8ex;border-left:1px #ccc solid;padding-left:1ex">
              <div text="#000000" bgcolor="#FFFFFF"> Hi,<br>
                <br>
                with clang 3.5, when I wanted to parse a source file, I
                created a compiler instance and a new class that inherit
                from the class ASTConsumer like this :<br>
                <br>
                ci = new clang::CompilerInstance()<br>
                ci.createDiagnostics();<br>
                ci.createFileManager();<br>
                ci.createSourceManager(ci.getFileManager());<br>
                std::shared_ptr<clang::TargetOptions> pto =
                std::make_shared<clang::TargetOptions>();<br>
                pto->Triple = llvm::sys::getDefaultTargetTriple();<br>
                clang::TargetInfo *pti =
                clang::TargetInfo::CreateTargetInfo(m_ci.getDiagnostics(),
                pto);<br>
                ci.setTarget(pti);<br>
                ci.createPreprocessor(clang::TU_Complete);<br>
                ...     <br>
                //add source file and the headers paths<br>
                ...<br>
                MyASTConsumer * myASTConsumerClassInstance = new
                MyASTConsumer;<br>
                ci.setASTConsumer(myASTConsumerClassInstance);<br>
              </div>
            </blockquote>
            <div><br>
              ci.setASTConsumer(llvm::make_unique<MyASTConsumer>());
              is the simplest way.<br>
               </div>
            <blockquote class="gmail_quote" style="margin:0 0 0
              .8ex;border-left:1px #ccc solid;padding-left:1ex">
              <div text="#000000" bgcolor="#FFFFFF"> ...<br>
                //parse the header file<br>
                <br>
                with the ASTConsumer :<br>
                <br>
                class MyASTConsumer : public clang::ASTConsumer<br>
                {<br>
                    MyASTConsumer()<br>
                    ~MyASTConsumer() {};<br>
                    virtual bool HandleTopLevelDecl( clang::DeclGroupRef
                d);<br>
                    virtual void HandleTagDeclDefinition( clang::TagDecl
                * d);<br>
                    private:<br>
                    std::vector<clang::TagDecl *> m_my_tags;<br>
                }<br>
                <br>
                Now with clang 3.6, the CompilerInstance::setASTConsumer
                methods asks for a std::unique_ptr<ASTConsumer> as
                argument. How to adapt my previous code with the new
                api.<br>
                <br>
                Thanks<br>
              </div>
              <br>
              _______________________________________________<br>
              cfe-dev mailing list<br>
              <a moz-do-not-send="true"
                href="mailto:cfe-dev@cs.uiuc.edu">cfe-dev@cs.uiuc.edu</a><br>
              <a moz-do-not-send="true"
                href="http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev"
                target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev</a><br>
              <br>
            </blockquote>
          </div>
          <br>
        </div>
      </div>
    </blockquote>
    <br>
  </body>
</html>