<div dir="ltr"><div><div>ping - Any ideas? Searching around I found a similar problem (I think on stackoverflow), but no responses...<br><br>I'm updating a project from Clang 3.4 to the latest version of Clang, and<br>
am having problems getting it to work. It's a project with a<br>
RecursiveASTVisitor, running on Windows with MinGW-32. Everything seems to<br>
go well until I get to the destructor of the CompilerInstance. The code<br>
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(),<br>
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>
Everything works fine till the return, when it crashes with:<br>
<br>
libstdc++-6!_ZNSs4_Rep10_M_destroyERKSaIcE
C:\Qt\Qt5.4.1\5.4\mingw491_32\bin\libstdc++-6.dll<br>
clang::DiagnosticsEngine::~DiagnosticsEngine<br>
clang::CompilerInstance::~CompilerInstance<br>
<br>
Any ideas what I did wrong? Something with using the TextDiagnosticPrinter? This is with:<br>
clang version 3.7.0 (trunk 230884)<br>
Target: i686-pc-windows-gnu<br>
Thread model: posix<br><br></div>Thanks!<br></div>Robert<br></div>