Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 0 additions & 14 deletions clang/lib/Serialization/ASTReaderDecl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3641,23 +3641,9 @@ template<>
void ASTDeclReader::attachPreviousDeclImpl(ASTReader &Reader,
Redeclarable<VarDecl> *D,
Decl *Previous, Decl *Canon) {
auto *VD = static_cast<VarDecl *>(D);
auto *PrevVD = cast<VarDecl>(Previous);
D->RedeclLink.setPrevious(PrevVD);
D->First = PrevVD->First;

// We should keep at most one definition on the chain.
// FIXME: Cache the definition once we've found it. Building a chain with
// N definitions currently takes O(N^2) time here.
if (VD->isThisDeclarationADefinition() == VarDecl::Definition) {
for (VarDecl *CurD = PrevVD; CurD; CurD = CurD->getPreviousDecl()) {
if (CurD->isThisDeclarationADefinition() == VarDecl::Definition) {
Reader.mergeDefinitionVisibility(CurD, VD);
VD->demoteThisDefinitionToDeclaration();
break;
}
}
}
}

static bool isUndeducedReturnType(QualType T) {
Expand Down
47 changes: 47 additions & 0 deletions clang/test/Modules/pr172241.cppm
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
// RUN: rm -rf %t
// RUN: mkdir -p %t
// RUN: split-file %s %t
//
// RUN: %clang_cc1 -std=c++20 -triple %itanium_abi_triple %t/m.cppm -emit-module-interface -o %t/m.pcm
// RUN: %clang_cc1 -std=c++20 -triple %itanium_abi_triple %t/use.cpp -fmodule-file=m=%t/m.pcm -emit-llvm -o - | FileCheck %t/use.cpp
//
// RUN: %clang_cc1 -std=c++20 -triple %itanium_abi_triple %t/m.cppm -emit-reduced-module-interface -o %t/m.pcm
// RUN: %clang_cc1 -std=c++20 -triple %itanium_abi_triple %t/use.cpp -fmodule-file=m=%t/m.pcm -emit-llvm -o - | FileCheck %t/use.cpp

//--- header.h
#pragma once

template <unsigned T>
class Templ {
public:
void lock() { __set_locked_bit(); }

private:
static constexpr auto __set_locked_bit = [](){};
};

class JT {
public:
~JT() {
Templ<4> state;
state.lock();
}
};

//--- m.cppm
module;
#include "header.h"
export module m;
export struct M {
JT jt;
};
//--- use.cpp
#include "header.h"
import m;

int main() {
M m;
return 0;
}

// CHECK: @_ZN5TemplILj4EE16__set_locked_bitE = {{.*}}linkonce_odr
Loading