Repository navigation
[clang][Modules] Complete the implementation of P2615: Meaningful exports #194201
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
b8f38d5
b2e7ab4
fc4e1c3
012415d
a6d6b28
c8bee39
95c6d00
ac5f826
8270a02
a4c37e4
376bad9
8464a81
b94cd84
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1913,3 +1913,19 @@ SourceRange ExplicitInstantiationDecl::getSourceRange() const { | |
| SourceLocation Begin = ExternLoc.isValid() ? ExternLoc : getLocation(); | ||
| return SourceRange(Begin, getEndLoc()); | ||
| } | ||
|
|
||
| TemplateSpecializationKind clang::getTemplateSpecializationKind(const Decl *D) { | ||
| if (!D) | ||
| return TSK_Undeclared; | ||
|
|
||
| if (const auto *Record = dyn_cast<CXXRecordDecl>(D)) | ||
| return Record->getTemplateSpecializationKind(); | ||
| if (const auto *Function = dyn_cast<FunctionDecl>(D)) | ||
| return Function->getTemplateSpecializationKind(); | ||
| if (const auto *Var = dyn_cast<VarDecl>(D)) | ||
| return Var->getTemplateSpecializationKind(); | ||
| if (const auto *EID = dyn_cast<ExplicitInstantiationDecl>(D)) | ||
| return EID->getTemplateSpecializationKind(); | ||
|
|
||
| return TSK_Undeclared; | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: Slightly odd to return TSK_Undeclared for declaration unrelated to templates.
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Agreed, but it's consistent with all the node-specific |
||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,66 @@ | ||
| // RUN: %clang_cc1 -std=c++20 -fexceptions -fcxx-exceptions -pedantic-errors %s -verify -verify-directives | ||
| // RUN: %clang_cc1 -std=c++23 -fexceptions -fcxx-exceptions -pedantic-errors %s -verify -verify-directives | ||
| // RUN: %clang_cc1 -std=c++2c -fexceptions -fcxx-exceptions -pedantic-errors %s -verify -verify-directives | ||
|
|
||
| export module foo; | ||
|
|
||
| namespace cwg2443 { // cwg2443: 23 | ||
|
|
||
| export template <typename T> class s1 {}; | ||
| export template <typename T> class s1<T *> {}; | ||
| // expected-warning@-1 {{a specialization cannot be marked 'export'}} | ||
| // expected-note@-2 {{it is exported if the primary template is exported}} | ||
| export template <> class s1<int> {}; | ||
| // expected-warning@-1 {{a specialization cannot be marked 'export'}} | ||
| // expected-note@-2 {{it is exported if the primary template is exported}} | ||
| export template class s1<char>; | ||
| // expected-warning@-1 {{an explicit instantiation cannot be marked 'export'}} | ||
| // expected-note@-2 {{it is exported if the primary template is exported}} | ||
| export extern template class s1<void>; | ||
| // expected-warning@-1 {{an explicit instantiation cannot be marked 'export'}} | ||
| // expected-note@-2 {{it is exported if the primary template is exported}} | ||
|
|
||
| export template <typename T> int v1 = 0; | ||
| export template <typename T> int v1<T *> = 0; | ||
| // expected-warning@-1 {{a specialization cannot be marked 'export'}} | ||
| // expected-note@-2 {{it is exported if the primary template is exported}} | ||
| export template <> int v1<int> = 0; | ||
| // expected-warning@-1 {{a specialization cannot be marked 'export'}} | ||
| // expected-note@-2 {{it is exported if the primary template is exported}} | ||
| export template int v1<char>; | ||
| // expected-warning@-1 {{an explicit instantiation cannot be marked 'export'}} | ||
| // expected-note@-2 {{it is exported if the primary template is exported}} | ||
| export extern template int v1<void>; | ||
| // expected-warning@-1 {{an explicit instantiation cannot be marked 'export'}} | ||
| // expected-note@-2 {{it is exported if the primary template is exported}} | ||
|
|
||
| export template <typename T> void f1() {} | ||
| export template <> void f1<int>() {} | ||
| // expected-warning@-1 {{a specialization cannot be marked 'export'}} | ||
| // expected-note@-2 {{it is exported if the primary template is exported}} | ||
| export template void f1<char>(); | ||
| // expected-warning@-1 {{an explicit instantiation cannot be marked 'export'}} | ||
| // expected-note@-2 {{it is exported if the primary template is exported}} | ||
| export extern template void f1<void>(); | ||
| // expected-warning@-1 {{an explicit instantiation cannot be marked 'export'}} | ||
| // expected-note@-2 {{it is exported if the primary template is exported}} | ||
|
|
||
|
|
||
| export { template <typename T> class s2 {}; } | ||
| export { template <typename T> class s2<T *> {}; } | ||
| export { template <> class s2<int> {}; } | ||
| export { template class s2<char>; } | ||
| export { extern template class s2<void>; } | ||
|
|
||
| export { template <typename T> int v2 = 0; } | ||
| export { template <typename T> int v2<T *> = 0; } | ||
| export { template <> int v2<int> = 0; } | ||
| export { template int v2<char>; } | ||
| export { extern template int v2<void>; } | ||
|
|
||
| export { template <typename T> void f2() {} } | ||
| export { template <> void f2<int>() {} } | ||
| export { template void f2<char>(); } | ||
| export { extern template void f2<void>(); } | ||
|
|
||
| } // namespace cwg2443 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think we need these logics in this patch...