Skip to content

Commit

Permalink
Revert "[clang-repl] Extend the C support. (llvm#89804)"
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
jasonmolenda committed May 22, 2024
1 parent 203232f commit dfdf1c5
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 39 deletions.
13 changes: 2 additions & 11 deletions clang/lib/Interpreter/IncrementalParser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -387,7 +387,8 @@ std::unique_ptr<llvm::Module> IncrementalParser::GenModule() {

void IncrementalParser::CleanUpPTU(PartialTranslationUnit &PTU) {
TranslationUnitDecl *MostRecentTU = PTU.TUPart;
if (StoredDeclsMap *Map = MostRecentTU->getPrimaryContext()->getLookupPtr()) {
TranslationUnitDecl *FirstTU = MostRecentTU->getFirstDecl();
if (StoredDeclsMap *Map = FirstTU->getPrimaryContext()->getLookupPtr()) {
for (auto &&[Key, List] : *Map) {
DeclContextLookupResult R = List.getLookupResult();
std::vector<NamedDecl *> NamedDeclsToRemove;
Expand All @@ -406,16 +407,6 @@ void IncrementalParser::CleanUpPTU(PartialTranslationUnit &PTU) {
}
}
}

// FIXME: We should de-allocate MostRecentTU
for (Decl *D : MostRecentTU->decls()) {
auto *ND = dyn_cast<NamedDecl>(D);
if (!ND)
continue;
// Check if we need to clean up the IdResolver chain.
if (ND->getDeclName().getFETokenInfo())
getCI()->getSema().IdResolver.RemoveDecl(ND);
}
}

llvm::StringRef IncrementalParser::GetMangledName(GlobalDecl GD) const {
Expand Down
10 changes: 3 additions & 7 deletions clang/lib/Sema/SemaDecl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2282,13 +2282,9 @@ void Sema::ActOnPopScope(SourceLocation Loc, Scope *S) {
if (LabelDecl *LD = dyn_cast<LabelDecl>(D))
CheckPoppedLabel(LD, *this, addDiag);

// Partial translation units that are created in incremental processing must
// not clean up the IdResolver because PTUs should take into account the
// declarations that came from previous PTUs.
if (!PP.isIncrementalProcessingEnabled())
IdResolver.RemoveDecl(D);

// Warn on it if we are shadowing a declaration.
// Remove this name from our lexical scope, and warn on it if we haven't
// already.
IdResolver.RemoveDecl(D);
auto ShadowI = ShadowingDecls.find(D);
if (ShadowI != ShadowingDecls.end()) {
if (const auto *FD = dyn_cast<FieldDecl>(ShadowI->second)) {
Expand Down
21 changes: 0 additions & 21 deletions clang/test/Interpreter/execute.c

This file was deleted.

0 comments on commit dfdf1c5

Please sign in to comment.