[clang] aac4d03 - [C++20] [Modules] Mark exported all declarations as used
Chuanqi Xu via cfe-commits
cfe-commits at lists.llvm.org
Thu Apr 18 18:48:22 PDT 2024
Author: Chuanqi Xu
Date: 2024-04-19T09:46:18+08:00
New Revision: aac4d03423dd6b7bdef0f2eb03c570f3e2ca6630
URL: https://github.com/llvm/llvm-project/commit/aac4d03423dd6b7bdef0f2eb03c570f3e2ca6630
DIFF: https://github.com/llvm/llvm-project/commit/aac4d03423dd6b7bdef0f2eb03c570f3e2ca6630.diff
LOG: [C++20] [Modules] Mark exported all declarations as used
Close https://github.com/llvm/llvm-project/issues/85122
As the title suggested, it looks pretty sensible.
Added:
clang/test/Modules/pr85122.cppm
Modified:
clang/lib/Sema/SemaModule.cpp
Removed:
################################################################################
diff --git a/clang/lib/Sema/SemaModule.cpp b/clang/lib/Sema/SemaModule.cpp
index 67658c93ed3baf..ad118ac90e4aa6 100644
--- a/clang/lib/Sema/SemaModule.cpp
+++ b/clang/lib/Sema/SemaModule.cpp
@@ -1003,6 +1003,10 @@ Decl *Sema::ActOnFinishExportDecl(Scope *S, Decl *D, SourceLocation RBraceLoc) {
}
}
+ // Anything exported from a module should never be considered unused.
+ for (auto *Exported : ED->decls())
+ Exported->markUsed(getASTContext());
+
return D;
}
diff --git a/clang/test/Modules/pr85122.cppm b/clang/test/Modules/pr85122.cppm
new file mode 100644
index 00000000000000..a4c89f13711a36
--- /dev/null
+++ b/clang/test/Modules/pr85122.cppm
@@ -0,0 +1,6 @@
+// RUN: %clang_cc1 -std=c++20 %s -Wall -fsyntax-only -verify
+
+// expected-no-diagnostics
+export module a;
+
+export constexpr auto a = []{};
More information about the cfe-commits
mailing list