Segfault calling clang::parseAST on file with syntax error.
I'm working on a program to compile C++ code into llvm::Modules at the moment and am having trouble handling files with errors. I'm following along with the incremental processing unit test. The method in there works fine, unless the file its asked to parse contains an error in which case it segfaults. The problem seems to extend to clang::parseAST as well and I can reproduce it pretty easily. I attached a program to do that at the end of the email.
According to gdb, the segfault is happening in clang::DiagnosticRenderer::emitDiagnostic, but the stack trace other than that looks pretty good. The clang::Sema calls clang::Sema::DiagnoseUnknownTypeName which seems like the right idea.
Does anyone have any ideas why this might be happening or how to fix this? I'm also open to other ideas on how best to approach compiling C++ code into llvm::Modules from inside C++ land. Ultimately, I'd like to be able to JIT the resulting code with LLVM's JIT.