[PATCH] D142704: [C++20][Modules] Handle template declarations in header units.

Iain Sandoe via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Jan 31 03:12:20 PST 2023


iains added inline comments.


================
Comment at: clang/lib/Sema/SemaDecl.cpp:15265
       FD->getFormalLinkage() == Linkage::ExternalLinkage &&
-      !FD->isInvalidDecl() && BodyKind != FnBodyKind::Delete &&
+      !FD->isInvalidDecl() && !IsFnTemplate && BodyKind != FnBodyKind::Delete &&
       BodyKind != FnBodyKind::Default && !FD->isInlined()) {
----------------
ChuanqiXu wrote:
> iains wrote:
> > iains wrote:
> > > ChuanqiXu wrote:
> > > > iains wrote:
> > > > > rsmith wrote:
> > > > > > Would it make sense to use `!isa<FunctionTemplateDecl>(D)` here instead of adding `IsFnTemplate`?
> > > > > > Would it make sense to use `!isa<FunctionTemplateDecl>(D)` here instead of adding `IsFnTemplate`?
> > > > > 
> > > > > I have changed this to use FD->isTemplated() to match the changes for VarDecls - where the template decl is not available.  Would it be better to use the isa<>() ?
> > > > > 
> > > > It looks not bad to me to use `isTemplated ()`. And it looks like `!FD->isTemplateInstantiation()` is not tested? And it looks a little bit odd since the instantiated template should be implicitly inline.
> > > > It looks not bad to me to use `isTemplated ()`. 
> > > 
> > > Hmm. now I am not sure what you prefer; in a previous review there was an objection to not using the provided function in the decl class.  
> > > 
> > > What would be your suggestion here?
> > > 
> > > (we cannot use isa<VarTemplateDecl> when testing the variables case because the caller pulls out the templated decl before we get to test it) - so it is more consistent (IMO) to use the same interface in both tests.
> > > 
> > > >And it looks like `!FD->isTemplateInstantiation()` is not tested?
> > > 
> > > Please could you expand a bit on what you mean here?
> > >  (the test is clearly required, in practice)
> > > 
> > > > And it looks a little bit odd since the instantiated template should be implicitly inline.
> > > 
> > > Did you see @dlaikie's comment on this topic above?
> > > 
> > > 
> > 
> > > Did you see @dlaikie's comment on this topic above?
> > 
> > sorry @dblaikie 's comment is in the PR (https://github.com/llvm/llvm-project/issues/60079#issuecomment-1406856501)
> > What would be your suggestion here?
> 
> I prefer `isTemplated ()` here. If I get things correct,  `isTemplated ()` will cover the case that a non-template function decl inside a function template. And `isa<FunctionTemplateDecl>(D)` wouldn't handle the case. According to my understanding problem, we should avoid all the dependent cases.
> 
> > Please could you expand a bit on what you mean here?
> 
> I mean I didn't find function template instantiation in tests of this revision page.
> 
> > sorry @dblaikie 's comment is in the PR (https://github.com/llvm/llvm-project/issues/60079#issuecomment-1406856501)
> 
> oh, this is because the inconsistent use of `inline` in different places.. this may be the price we need to pay.

> > Please could you expand a bit on what you mean here?
> 
> I mean I didn't find function template instantiation in tests of this revision page.

added.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D142704



More information about the cfe-commits mailing list