Skip to content

Commit dfdf1c5

Browse files
committed
Revert "[clang-repl] Extend the C support. (llvm#89804)"
This reverts commit 253c28f. This commit is causing failures on the lldb CI bots, e.g. https://ci.swift.org/view/all/job/llvm.org/view/LLDB/job/as-lldb-cmake/4307/ On my local macOS desktop build, ``` bin/lldb-dotest -p TestImportBuiltinFileID.py Assertion failed: (D->getLexicalDeclContext() == this && "Decl inserted into wrong lexical context"), function addHiddenDecl, file DeclBase.cpp, line 1692. 6 libsystem_c.dylib 0x0000000185f0b8d0 abort + 128 7 libsystem_c.dylib 0x0000000185f0abc8 err + 0 8 liblldb.19.0.0git.dylib 0x00000001311e5800 clang::DeclContext::addHiddenDecl(clang::Decl*) + 120 9 liblldb.19.0.0git.dylib 0x00000001311e5978 clang::DeclContext::addDecl(clang::Decl*) + 32 10 liblldb.19.0.0git.dylib 0x000000012f617b48 clang::Sema::ActOnStartTopLevelStmtDecl(clang::Scope*) + 64 11 liblldb.19.0.0git.dylib 0x000000012eaf76c8 clang::Parser::ParseTopLevelStmtDecl() + 208 12 liblldb.19.0.0git.dylib 0x000000012ec051fc clang::Parser::ParseExternalDeclaration(clang::ParsedAttributes&, clang::ParsedAttributes&, clang::ParsingDeclSpec*) + 3412 13 liblldb.19.0.0git.dylib 0x000000012ec03274 clang::Parser::ParseTopLevelDecl(clang::OpaquePtr<clang::DeclGroupRef>&, clang::Sema::ModuleImportState&) + 2020 14 liblldb.19.0.0git.dylib 0x000000012eaca860 clang::ParseAST(clang::Sema&, bool, bool) + 604 15 liblldb.19.0.0git.dylib 0x000000012e8554c0 clang::ASTFrontendAction::ExecuteAction() + 308 16 liblldb.19.0.0git.dylib 0x000000012e854c78 clang::FrontendAction::Execute() + 124 17 liblldb.19.0.0git.dylib 0x000000012e76dcfc clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) + 984 18 liblldb.19.0.0git.dylib 0x000000012e784500 compileModuleImpl(clang::CompilerInstance&, clang::SourceLocation, llvm::StringRef, clang::FrontendInputFile, llvm::StringRef, llvm::StringRef, llvm::function_ref<void (clang::CompilerInstance&)>, llvm::function_ref<void (clang::CompilerInstance&)>)::$_1::operator()() const + 52 ``` Reverting until Vassil has a chance to look int oit.
1 parent 203232f commit dfdf1c5

File tree

3 files changed

+5
-39
lines changed

3 files changed

+5
-39
lines changed

clang/lib/Interpreter/IncrementalParser.cpp

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -387,7 +387,8 @@ std::unique_ptr<llvm::Module> IncrementalParser::GenModule() {
387387

388388
void IncrementalParser::CleanUpPTU(PartialTranslationUnit &PTU) {
389389
TranslationUnitDecl *MostRecentTU = PTU.TUPart;
390-
if (StoredDeclsMap *Map = MostRecentTU->getPrimaryContext()->getLookupPtr()) {
390+
TranslationUnitDecl *FirstTU = MostRecentTU->getFirstDecl();
391+
if (StoredDeclsMap *Map = FirstTU->getPrimaryContext()->getLookupPtr()) {
391392
for (auto &&[Key, List] : *Map) {
392393
DeclContextLookupResult R = List.getLookupResult();
393394
std::vector<NamedDecl *> NamedDeclsToRemove;
@@ -406,16 +407,6 @@ void IncrementalParser::CleanUpPTU(PartialTranslationUnit &PTU) {
406407
}
407408
}
408409
}
409-
410-
// FIXME: We should de-allocate MostRecentTU
411-
for (Decl *D : MostRecentTU->decls()) {
412-
auto *ND = dyn_cast<NamedDecl>(D);
413-
if (!ND)
414-
continue;
415-
// Check if we need to clean up the IdResolver chain.
416-
if (ND->getDeclName().getFETokenInfo())
417-
getCI()->getSema().IdResolver.RemoveDecl(ND);
418-
}
419410
}
420411

421412
llvm::StringRef IncrementalParser::GetMangledName(GlobalDecl GD) const {

clang/lib/Sema/SemaDecl.cpp

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2282,13 +2282,9 @@ void Sema::ActOnPopScope(SourceLocation Loc, Scope *S) {
22822282
if (LabelDecl *LD = dyn_cast<LabelDecl>(D))
22832283
CheckPoppedLabel(LD, *this, addDiag);
22842284

2285-
// Partial translation units that are created in incremental processing must
2286-
// not clean up the IdResolver because PTUs should take into account the
2287-
// declarations that came from previous PTUs.
2288-
if (!PP.isIncrementalProcessingEnabled())
2289-
IdResolver.RemoveDecl(D);
2290-
2291-
// Warn on it if we are shadowing a declaration.
2285+
// Remove this name from our lexical scope, and warn on it if we haven't
2286+
// already.
2287+
IdResolver.RemoveDecl(D);
22922288
auto ShadowI = ShadowingDecls.find(D);
22932289
if (ShadowI != ShadowingDecls.end()) {
22942290
if (const auto *FD = dyn_cast<FieldDecl>(ShadowI->second)) {

clang/test/Interpreter/execute.c

Lines changed: 0 additions & 21 deletions
This file was deleted.

0 commit comments

Comments
 (0)