Error/crash in transaction/declaration rollback

Running the following code:

#include <map> std::map<int,std::string> p; #include <string>

Will cause this error/crash:
Assertion failed: (Pos != Map->end() && “no lookup entry for decl”), function removeDecl, file tools/clang/lib/AST/DeclBase.cpp, line 1162.

Seems the transaction rollback from #include is undeclaring things multiple times.
Exchanging the assert and wrapping the subsequent lines with an if will alleviate the crash, but I’m uncertain if the fix is optimal/correct.

    if (Pos != Map->end()) {
      StoredDeclsList::DeclsTy* Vec = Pos->second.getAsVector();
      if ((Vec && std::find(Vec->begin(), Vec->end(), ND) != Vec->end())
          || Pos->second.getAsDecl() == ND)


Thanks for reporting, that’s a bug. It’s now


Fixed in master + 6.04! Thanks for your report!