[clang] [C++20] [Modules] [Itanium ABI] Generate the vtable in the module unit of dynamic classes (PR #75912)
via cfe-commits
cfe-commits at lists.llvm.org
Thu Jan 25 00:50:48 PST 2024
github-actions[bot] wrote:
<!--LLVM CODE FORMAT COMMENT: {clang-format}-->
:warning: C/C++ code formatter, clang-format found issues in your code. :warning:
<details>
<summary>
You can test this locally with the following command:
</summary>
``````````bash
git-clang-format --diff 7a3b0cbb143d02b70b2bfae5cd40e9867c124748 630e59738990c3dd570065b8b7a050d822d68df0 -- clang/test/CodeGenCXX/pr70585.cppm clang/lib/CodeGen/CGVTables.cpp clang/lib/CodeGen/CodeGenModule.cpp clang/lib/CodeGen/ItaniumCXXABI.cpp clang/lib/Sema/SemaDecl.cpp clang/lib/Sema/SemaDeclCXX.cpp clang/lib/Serialization/ASTReaderDecl.cpp clang/lib/Serialization/ASTWriterDecl.cpp clang/test/CodeGenCXX/modules-vtable.cppm
``````````
</details>
<details>
<summary>
View the diff from clang-format here.
</summary>
``````````diff
diff --git a/clang/lib/CodeGen/CodeGenModule.cpp b/clang/lib/CodeGen/CodeGenModule.cpp
index b133695d90..4863f7348e 100644
--- a/clang/lib/CodeGen/CodeGenModule.cpp
+++ b/clang/lib/CodeGen/CodeGenModule.cpp
@@ -6738,9 +6738,11 @@ void CodeGenModule::EmitTopLevelDecl(Decl *D) {
if (ES->hasExternalDefinitions(D) == ExternalASTSource::EK_Never)
DI->completeUnusedClass(*CRD);
}
- // If we're emitting a dynamic class from the importable module we're emitting,
- // we always need to emit the virtual table according to the ABI requirement.
- if (CRD->getOwningModule() && CRD->getOwningModule()->isInterfaceOrPartition() &&
+ // If we're emitting a dynamic class from the importable module we're
+ // emitting, we always need to emit the virtual table according to the ABI
+ // requirement.
+ if (CRD->getOwningModule() &&
+ CRD->getOwningModule()->isInterfaceOrPartition() &&
CRD->getDefinition() && CRD->isDynamicClass() &&
CRD->getOwningModule() == getContext().getCurrentNamedModule())
EmitVTable(CRD);
diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp
index aaf4a3d0ba..646b94f670 100644
--- a/clang/lib/Sema/SemaDecl.cpp
+++ b/clang/lib/Sema/SemaDecl.cpp
@@ -18132,9 +18132,9 @@ void Sema::ActOnTagFinishDefinition(Scope *S, Decl *TagD,
// need to produce the vtable for it even if the vtable is not used in the
// current TU.
//
- // The case that the current class is not dynamic is handled in MarkVTableUsed.
- if (getCurrentModule() &&
- getCurrentModule()->isInterfaceOrPartition())
+ // The case that the current class is not dynamic is handled in
+ // MarkVTableUsed.
+ if (getCurrentModule() && getCurrentModule()->isInterfaceOrPartition())
MarkVTableUsed(RD->getLocation(), RD, /*DefinitionRequired=*/true);
}
diff --git a/clang/lib/Serialization/ASTReaderDecl.cpp b/clang/lib/Serialization/ASTReaderDecl.cpp
index f5ff9115aa..e6b3f4a1b4 100644
--- a/clang/lib/Serialization/ASTReaderDecl.cpp
+++ b/clang/lib/Serialization/ASTReaderDecl.cpp
@@ -2255,7 +2255,7 @@ ASTDeclReader::VisitCXXRecordDeclImpl(CXXRecordDecl *D) {
// compute it.
//
// The key function in named module is meaningless.
- if (WasDefinition && (!D->getOwningModule() ||
+ if (WasDefinition && (!D->getOwningModule() ||
!D->getOwningModule()->isInterfaceOrPartition())) {
DeclID KeyFn = readDeclID();
if (KeyFn && D->isCompleteDefinition())
@@ -3210,7 +3210,7 @@ static bool isConsumerInterestedIn(ASTContext &Ctx, Decl *D, bool HasBody) {
OMPDeclareTargetDeclAttr::isDeclareTargetDeclaration(Var));
if (const auto *Func = dyn_cast<FunctionDecl>(D))
return Func->doesThisDeclarationHaveABody() || HasBody;
-
+
if (auto *ES = D->getASTContext().getExternalSource())
if (ES->hasExternalDefinitions(D) == ExternalASTSource::EK_Never)
return true;
diff --git a/clang/lib/Serialization/ASTWriterDecl.cpp b/clang/lib/Serialization/ASTWriterDecl.cpp
index 33b2c1d392..b971dd0251 100644
--- a/clang/lib/Serialization/ASTWriterDecl.cpp
+++ b/clang/lib/Serialization/ASTWriterDecl.cpp
@@ -1482,7 +1482,7 @@ void ASTDeclWriter::VisitCXXRecordDecl(CXXRecordDecl *D) {
Record.push_back(D->isThisDeclarationADefinition());
if (D->isThisDeclarationADefinition())
Record.AddCXXDefinitionData(D);
-
+
if (D->isCompleteDefinition()) {
if (D->getOwningModule() && D->getOwningModule()->isInterfaceOrPartition())
Writer.ModularCodegenDecls.push_back(Writer.GetDeclRef(D));
``````````
</details>
https://github.com/llvm/llvm-project/pull/75912
More information about the cfe-commits
mailing list