Diagnostics in plugins fail with assert

Passing -an-error to the example plugin
(trunk/examples/PrintFunctionNames/PrintFunctionNames.cpp) results in a failed assert at include/clang/Basic/Diagnostic.h:1037:

1035 inline DiagnosticBuilder DiagnosticsEngine::Report(SourceLocation Loc,
1036 unsigned DiagID){
1037 assert(CurDiagID == ~0U && "Multiple diagnostics in flight at once!");
1038 CurDiagLoc = Loc;
1039 CurDiagID = DiagID;
1040 return DiagnosticBuilder(this);
1041 }

#4 0x00007ffff7d70cc9 in Report (DiagID=4620, Loc=..., this=0x4481100)
     at /opt/llvm-3.2/include/clang/Basic/Diagnostic.h:1037
#5 Report (DiagID=4620, this=0x4481100) at /opt/llvm-3.2/include/clang/Basic/Diagnostic.h:1043
#6 (anonymous namespace)::PrintFunctionNamesAction::ParseArgs (this=<optimized out>, CI=..., args=...)
     at plugin.cpp:53
#7 0x0000000000bf2487 in clang::FrontendAction::CreateWrappedASTConsumer (this=0x447fec0, CI=..., InFile=...)
     at /home/fweimer/src/ext/llvm/trunk/tools/clang/lib/Frontend/FrontendAction.cpp:149
#8 0x0000000000bf2bd5 in clang::FrontendAction::BeginSourceFile (this=0x447fec0, CI=..., Input=...)
     at /home/fweimer/src/ext/llvm/trunk/tools/clang/lib/Frontend/FrontendAction.cpp:245
#9 0x0000000000bca4f3 in clang::CompilerInstance::ExecuteAction (this=0x447cd30, Act=...)
     at /home/fweimer/src/ext/llvm/trunk/tools/clang/lib/Frontend/CompilerInstance.cpp:671
#10 0x0000000000b9b648 in clang::ExecuteCompilerInvocation (Clang=0x447cd30)
     at /home/fweimer/src/ext/llvm/trunk/tools/clang/lib/FrontendTool/ExecuteCompilerInvocation.cpp:189
#11 0x0000000000b893e2 in cc1_main (ArgBegin=0x7fffffffd058, ArgEnd=0x7fffffffd208,
     Argv0=0x447b668 "/opt/llvm-3.2/bin/clang", MainAddr=0xb94ec8)
     at /home/fweimer/src/ext/llvm/trunk/tools/clang/tools/driver/cc1_main.cpp:165
#12 0x0000000000b96707 in main (argc_=56, argv_=0x7fffffffdc68)
     at /home/fweimer/src/ext/llvm/trunk/tools/clang/tools/driver/driver.cpp:358

This seems to affect all error reporting from plugins. Is some initialization step missing from the example plugin?

This happens with clang trunk (r163897) compiled on Fedora 17 (x86_64), in Release and Debug+Asserts builds.

Apart from the missing ability for error reporting, plug-ins seem to run just fine.

It turns out that this was caused by compiling the plugin in C++11 mode. It's quite well-known that the libstdc++ ABI changes when switching to C++11 mode, but I mistakenly assumed that this would lead to more obvious failures. (I had to look at disassembly before I realized what was going on.)