================
@@ -359,6 +359,31 @@ namespace clang {
           Params, Importer.getToContext().getTranslationUnitDecl());
     }
 
+    template <typename TemplateParmDeclT>
+    void tryUpdateTemplateParmDeclInheritedFrom(NamedDecl *RecentParm,
+                                                NamedDecl *NewParm) {
+      if (auto *ParmT = dyn_cast<TemplateParmDeclT>(RecentParm)) {
+        if (ParmT->hasDefaultArgument()) {
+          auto *P = cast<TemplateParmDeclT>(NewParm);
+          P->removeDefaultArgument();
+          P->setInheritedDefaultArgument(Importer.ToContext, ParmT);
+        }
+      }
+    }
+
+    void updateTemplateParametersInheritedFrom(
----------------
NagyDonat wrote:

```suggestion
  /// Update the parameter list `NewParams` of a template declaration by
  /// "inheriting" default argument values from `RecentParams`, which is
  /// the parameter list of an earlier declaration of the same template.
  /// (Note that "inheriting" default argument values this way is
  /// completely unrelated to the usual object-oriented "inheritance"
  /// relationship between classes.)
  ///
  /// Note that the standard specifies that the same parameter cannot be
  /// given default arguments twice in the same scope; but in our case
  /// the parameter list `NewParams` is freshly imported from a
  /// different TU, so it's possible that both `RecentParams` and
  /// `NewParams` specify a default argument for the same parameter.
  /// In this case, the code will use the default argument taken from
  /// `RecentParams`.
  /// FIXME: Report an error if the two default arguments are different.
    void updateTemplateParametersInheritedFrom(
```
I felt that it is important to explain that the "Inherited" within the name of 
this function is unrelated to the usual object-oriented "inheritance" between 
classes; and as I started to write this comment, I also ended up documenting 
the goals of this function. (I hope that I was correct -- please fix this 
comment block if I misunderstood something!) 

https://github.com/llvm/llvm-project/pull/100100
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to