=?utf-8?q?Balázs_Kéri?= <balazs.k...@ericsson.com>,
=?utf-8?q?Balázs_Kéri?= <balazs.k...@ericsson.com>
Message-ID:
In-Reply-To: <llvm.org/llvm/llvm-project/pull/74...@github.com>


================
@@ -5919,15 +5919,26 @@ ExpectedDecl 
ASTNodeImporter::VisitClassTemplateDecl(ClassTemplateDecl *D) {
   if (ToD)
     return ToD;
 
-  bool IsFriendTemplate = D->getFriendObjectKind() != Decl::FOK_None;
-  bool IsDependentContext = DC != LexicalDC ? LexicalDC->isDependentContext()
-                                            : DC->isDependentContext();
-  bool DependentFriend = IsFriendTemplate && IsDependentContext;
+  // Should check if a declaration is friend in a dependent context.
+  // Such templates are not linked together in a declaration chain.
+  // The ASTImporter strategy is to map existing forward declarations to
+  // imported ones only if strictly necessary, otherwise import these as new
+  // forward declarations. In case of the "dependent friend" declarations, new
+  // declarations are created, but not linked in a declaration chain.
+  auto IsDependentFriend = [](ClassTemplateDecl *TD) {
+    bool IsFriendTemplate = TD->getFriendObjectKind() != Decl::FOK_None;
+    DeclContext *DC = TD->getDeclContext();
+    DeclContext *LexicalDC = TD->getLexicalDeclContext();
+    bool IsDependentContext = DC != LexicalDC ? LexicalDC->isDependentContext()
+                                              : DC->isDependentContext();
----------------
NagyDonat wrote:

```suggestion
    bool IsDependentContext = TD->getLexicalDeclContext()->isDependentContext();
```
The ternary operator (that you inherited from old code) is superfluous, because 
if `DC != LexicalDC` is false, then the two branches are identical.

(By the way, is the logic correct? Perhaps the original author intended to have 
a difference between the branches...)

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

Reply via email to