<div dir="ltr"><div>I'm updating a project from Clang 3.4 to the latest version of Clang, and am having problems getting it to work. It's a Qt-based project with a RecursiveASTVisitor, running on Windows with MinGW-32. Everything seems to go well until I get to the destructor of the CompilerInstance. The code looks something like:<br>{<br>  CompilerInstance compiler;<br>  DiagnosticOptions &diagOpts = compiler.getDiagnosticOpts();<br>  string verr_string;<br>  raw_string_ostream vErr(verr_string);<br><br>  TextDiagnosticPrinter *pTextDiagnosticPrinter =<br>                         new TextDiagnosticPrinter(vErr, &diagOpts);<br>  compiler.createDiagnostics(pTextDiagnosticPrinter);<br><br>  // Create an invocation that passes any flags to preprocessor<br>  unique_ptr<CompilerInvocation> Invocation(new CompilerInvocation);<br>  CompilerInvocation::CreateFromArgs(*Invocation, argv + 1, argv + argc,<br>                                      compiler.getDiagnostics());<br><br>  Invocation->setLangDefaults(compiler.getLangOpts(),<br>                              clang::IK_CXX,<br>                             options.langStandard);<br><br>  compiler.setInvocation(Invocation.release());<br><br>  // Set default target triple<br>  shared_ptr<TargetOptions> pto( new TargetOptions());<br>  pto->Triple = llvm::sys::getDefaultTargetTriple();<br>  shared_ptr<TargetInfo><br>    pti(TargetInfo::CreateTargetInfo(compiler.getDiagnostics(), pto));<br>  compiler.setTarget(pti.get());<br><br>  compiler.createFileManager();<br>  compiler.createSourceManager(compiler.getFileManager());<br><br>  compiler.createPreprocessor(TU_Module);<br>  compiler.getPreprocessorOpts().UsePredefines = false;<br><br>  compiler.createASTContext();<br><br>  SourceManager &sourceMgr = compiler.getSourceManager();<br><br>  // Initialize rewriter<br>  Rewriter Rewrite;<br>  Rewrite.setSourceMgr(sourceMgr, compiler.getLangOpts());<br><br>  // Get filename<br>  string fileName(argv[argc - 1]);<br><br>  const FileEntry *pFile = compiler.getFileManager().getFile(fileName);<br>  sourceMgr.setMainFileID(sourceMgr.createFileID(pFile, SourceLocation(), SrcMgr::C_User));<br>  if (pFile == NULL)<br>  {<br>      // File not found<br>      return false;<br>  }<br><br>  compiler.getDiagnosticClient().BeginSourceFile(compiler.getLangOpts(),<br>                                           &compiler.getPreprocessor());<br><br>  MyASTConsumer astConsumer(Rewrite);<br><br>  try {<br>    // Parse the AST<br>    ParseAST(compiler.getPreprocessor(),<br>             &astConsumer,<br>             compiler.getASTContext());<br>  } catch(exception &e)<br>  {<br>    return false;<br>  }<br><br>  compiler.getDiagnosticClient().EndSourceFile();<br><br>  return true;  // Return success<br>}<br><br></div>Everything works fine till the return, when it crashes with:<br><div><br>libstdc++-6!_ZNSs4_Rep10_M_destroyERKSaIcE C:\Qt\Qt5.4.1\5.4\mingw491_32\bin\libstdc++-6.dll<br><div>clang::DiagnosticsEngine::~DiagnosticsEngine<br>clang::CompilerInstance::~CompilerInstance<br><br></div><div>Any ideas what I did wrong? This is with:<br>clang version 3.7.0 (trunk 230884)<br>Target: i686-pc-windows-gnu<br>Thread model: posix<br><br></div><div>BTW, why is the current build calling itself 3.7.0? Since 3.6 was just released, it seems it should be called 3.6.0 or something less confusing.<br><br></div><div>Thanks!<br></div><div>Robert<br><br></div><br><br></div></div>