Skip to content

Commit

Permalink
[clang-repl] Do not assert if we have weak references left.
Browse files Browse the repository at this point in the history
Non-incremental Clang can also exit with the WeakRefReferences not empty upon
such example. This patch makes clang-repl consistent to what Clang does.

Differential revision: https://reviews.llvm.org/D148435
  • Loading branch information
vgvassilev committed May 8, 2023
1 parent 26ee894 commit 743ff9c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
1 change: 0 additions & 1 deletion clang/lib/CodeGen/CodeGenModule.cpp
Expand Up @@ -7230,7 +7230,6 @@ void CodeGenModule::moveLazyEmissionStates(CodeGenModule *NewBuilder) {
"Newly created module should not have manglings");
NewBuilder->Manglings = std::move(Manglings);

assert(WeakRefReferences.empty() && "Not all WeakRefRefs have been applied");
NewBuilder->WeakRefReferences = std::move(WeakRefReferences);

NewBuilder->TBAA = std::move(TBAA);
Expand Down
6 changes: 6 additions & 0 deletions clang/test/Interpreter/execute-weak.cpp
Expand Up @@ -2,11 +2,17 @@
// RUN: clang-repl "int i = 10;" 'extern "C" int printf(const char*,...);' \
// RUN: 'auto r1 = printf("i = %d\n", i);' | FileCheck --check-prefix=CHECK-DRIVER %s
// CHECK-DRIVER: i = 10
//
// UNSUPPORTED: system-aix, system-windows
// RUN: cat %s | clang-repl | FileCheck %s

extern "C" int printf(const char *, ...);
int __attribute__((weak)) bar() { return 42; }
auto r4 = printf("bar() = %d\n", bar());
// CHECK: bar() = 42

int a = 12;
static __typeof(a) b __attribute__((__weakref__("a")));
int c = b;

%quit

0 comments on commit 743ff9c

Please sign in to comment.