================ @@ -5696,8 +5696,11 @@ Parser::DeclGroupPtrTy Parser::ParseTopLevelStmtDecl() { TopLevelStmtDecl *TLSD = Actions.ActOnStartTopLevelStmtDecl(getCurScope()); StmtResult R = ParseStatementOrDeclaration(Stmts, SubStmtCtx); Actions.ActOnFinishTopLevelStmtDecl(TLSD, R.get()); - if (!R.isUsable()) + if (!R.isUsable()) { + if (DeclContext *DC = TLSD->getDeclContext()) + DC->removeDecl(TLSD); // unlink from TU ---------------- vgvassilev wrote:
Clang does not have the notion of removing the declarations on error. If we do it in the Parser that would be inconsistent to the rest of the logic in clang. I'd prefer to have all of this happen in a single place eg. `CleanUpPTU`. https://github.com/llvm/llvm-project/pull/153945 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits