[clang] [Clang] Make -fcomplete-member-pointers the same as using the Microsoft C++ ABI (PR #98010)
via cfe-commits
cfe-commits at lists.llvm.org
Mon Jul 8 04:07:40 PDT 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 f50f7a7aa0b897ef91361d7dc159f3262d142bdc 0de7bd39af61eb47ee33ff991e6de18f83e005dd -- clang/include/clang/Basic/TargetCXXABI.h clang/include/clang/Sema/Sema.h clang/lib/AST/Type.cpp clang/lib/Driver/ToolChains/Clang.cpp clang/lib/Frontend/CompilerInvocation.cpp clang/lib/Sema/SemaCast.cpp clang/lib/Sema/SemaExpr.cpp clang/lib/Sema/SemaExprCXX.cpp clang/lib/Sema/SemaOverload.cpp clang/lib/Sema/SemaType.cpp clang/test/Misc/warning-wall.c clang/test/SemaCXX/complete-member-pointers.cpp
``````````
</details>
<details>
<summary>
View the diff from clang-format here.
</summary>
``````````diff
diff --git a/clang/include/clang/Sema/Sema.h b/clang/include/clang/Sema/Sema.h
index c6e2cb9f8b..58d6bdf705 100644
--- a/clang/include/clang/Sema/Sema.h
+++ b/clang/include/clang/Sema/Sema.h
@@ -14932,11 +14932,14 @@ public:
}
private:
- void AssignInheritanceModelToBase(SourceLocation Loc, const MemberPointerType *T);
+ void AssignInheritanceModelToBase(SourceLocation Loc,
+ const MemberPointerType *T);
+
public:
/// Called when the Microsoft ABI would require the base type of a member
/// pointer to have its inheritance model calculated.
- void microsoftCompleteMemberPointer(SourceLocation Loc, const MemberPointerType *T) {
+ void microsoftCompleteMemberPointer(SourceLocation Loc,
+ const MemberPointerType *T) {
if (getLangOpts().CompleteMemberPointers)
AssignInheritanceModelToBase(Loc, T);
}
diff --git a/clang/lib/Driver/ToolChains/Clang.cpp b/clang/lib/Driver/ToolChains/Clang.cpp
index 58225fa207..a05b83b9f4 100644
--- a/clang/lib/Driver/ToolChains/Clang.cpp
+++ b/clang/lib/Driver/ToolChains/Clang.cpp
@@ -7146,7 +7146,8 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA,
CmdArgs.push_back("-fdelayed-template-parsing");
}
- if (Args.hasFlag(options::OPT_fcomplete_member_pointers, options::OPT_fno_complete_member_pointers, false)) {
+ if (Args.hasFlag(options::OPT_fcomplete_member_pointers,
+ options::OPT_fno_complete_member_pointers, false)) {
CmdArgs.push_back("-fcomplete-member-pointers");
CmdArgs.push_back("-Werror=microsoft-incomplete-member-pointer");
}
diff --git a/clang/lib/Sema/SemaType.cpp b/clang/lib/Sema/SemaType.cpp
index 3f00c7b77e..e3e81b8597 100644
--- a/clang/lib/Sema/SemaType.cpp
+++ b/clang/lib/Sema/SemaType.cpp
@@ -8969,14 +8969,18 @@ bool Sema::hasReachableDefinition(NamedDecl *D, NamedDecl **Suggested,
OnlyNeedComplete);
}
-void Sema::AssignInheritanceModelToBase(SourceLocation Loc, const MemberPointerType *T) {
- if (!T || T->getClass()->isDependentType()) return;
+void Sema::AssignInheritanceModelToBase(SourceLocation Loc,
+ const MemberPointerType *T) {
+ if (!T || T->getClass()->isDependentType())
+ return;
- assert(getLangOpts().CompleteMemberPointers && "Should not need assign the inheritance model in this case");
+ assert(getLangOpts().CompleteMemberPointers &&
+ "Should not need assign the inheritance model in this case");
QualType Base = QualType(T->getClass(), 0);
(void)isCompleteType(Loc, Base);
- CXXRecordDecl *RD = T->getClass()->getAsCXXRecordDecl()->getMostRecentNonInjectedDecl();
+ CXXRecordDecl *RD =
+ T->getClass()->getAsCXXRecordDecl()->getMostRecentNonInjectedDecl();
if (RD->hasAttr<MSInheritanceAttr>())
return;
@@ -8999,13 +9003,14 @@ void Sema::AssignInheritanceModelToBase(SourceLocation Loc, const MemberPointerT
}
SourceRange AttrLoc = ImplicitMSInheritanceAttrLoc.isValid()
- ? ImplicitMSInheritanceAttrLoc
- : RD->getSourceRange();
+ ? ImplicitMSInheritanceAttrLoc
+ : RD->getSourceRange();
RD->addAttr(MSInheritanceAttr::CreateImplicit(
Context, BestCase, AttrLoc, MSInheritanceAttr::Spelling(IM)));
Consumer.AssignInheritanceModel(RD);
- // Don't warn if the inheritance model is explicitly unspecified because of a pragma
+ // Don't warn if the inheritance model is explicitly unspecified because of a
+ // pragma
if (IM != MSInheritanceModel::Unspecified || !BestCase)
return;
@@ -9013,8 +9018,12 @@ void Sema::AssignInheritanceModelToBase(SourceLocation Loc, const MemberPointerT
if (!RD->hasDefinition())
Diag(RD->getLocation(), diag::note_forward_declaration) << Base;
else if (RD->isParsingBaseSpecifiers())
- Diag(RD->getDefinition()->getLocation(), diag::note_memptr_incomplete_until_bases);
- Diag(RD->getLocation(), diag::note_memptr_incomplete_specify_inheritance) << FixItHint::CreateInsertion(RD->getLocation(), "__single_inheritance|__multiple_inheritance|__virtual_inheritance");
+ Diag(RD->getDefinition()->getLocation(),
+ diag::note_memptr_incomplete_until_bases);
+ Diag(RD->getLocation(), diag::note_memptr_incomplete_specify_inheritance)
+ << FixItHint::CreateInsertion(RD->getLocation(),
+ "__single_inheritance|__multiple_"
+ "inheritance|__virtual_inheritance");
}
bool Sema::RequireCompleteTypeImpl(SourceLocation Loc, QualType T,
``````````
</details>
https://github.com/llvm/llvm-project/pull/98010
More information about the cfe-commits
mailing list