[PATCH] D141908: [C++20][Modules] Handle defaulted and deleted functions in header units.

Iain Sandoe via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Jan 18 00:24:04 PST 2023


iains added inline comments.


================
Comment at: clang/lib/Sema/SemaDecl.cpp:15258
+  // units.  Deleted and Defaulted functions are implicitly inline (but the
+  // inline state is not set at this point, so check the BodyKind explicitly).
   if (getLangOpts().CPlusPlusModules && currentModuleIsHeaderUnit() &&
----------------
ChuanqiXu wrote:
> I prefer to add a FIXME here to say that we need to find a better place for the check to eliminate the unnecessary check for `BodyKind `. The current check for `BodyKind` looks a little bit hacky to me.
When the patch was originally done, this was found to be a good place to do the check (i.e. less duplication of testing and to avoid duplication of diagnostics) so I do not think I agree that there is a FIXME to move it.

BodyKind is already used elsewhere in this function for similar purposes - it does not look hacky to me.


================
Comment at: clang/lib/Sema/SemaDecl.cpp:15261
+      FD->getFormalLinkage() == Linkage::ExternalLinkage &&
+      !FD->isInvalidDecl() && BodyKind == FnBodyKind::Other &&
+      !FD->isInlined()) {
----------------
ChuanqiXu wrote:
> It looks like we need to check `FD->isThisDeclarationADefinition()` too.
> 
> And personally, I prefer to check BodyKind explicitly. Otherwise the readers need to checkout the definition of `FnBodyKind` to understand the code. 
> It looks like we need to check `FD->isThisDeclarationADefinition()` too.

This is an unnecessary test, it will always return true at this point.

> And personally, I prefer to check BodyKind explicitly. Otherwise the readers need to checkout the definition of `FnBodyKind` to understand the code. 

You prefer two tests  instead of one?
OK, I guess


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D141908/new/

https://reviews.llvm.org/D141908



More information about the cfe-commits mailing list