[clang-tools-extra] [clangd] Let DefineOutline tweak handle member functions (PR #95235)

Julian Schmidt via cfe-commits cfe-commits at lists.llvm.org
Sat Aug 24 08:54:09 PDT 2024


================
@@ -407,10 +431,21 @@ class DefineOutline : public Tweak {
       return !SameFile;
     }
 
-    // Bail out in templated classes, as it is hard to spell the class name,
-    // i.e if the template parameter is unnamed.
-    if (MD->getParent()->isTemplated())
-      return false;
+    for (const CXXRecordDecl *Parent = MD->getParent(); Parent;
+         Parent =
+             llvm::dyn_cast_or_null<const CXXRecordDecl>(Parent->getParent())) {
+      if (auto Params = Parent->getDescribedTemplateParams()) {
+
+        // Class template member functions must be defined in the
+        // same file.
+        SameFile = true;
+
+        for (NamedDecl *P : *Params) {
+          if (!P->getIdentifier())
+            return false;
----------------
5chmidti wrote:

A comment explaining why we bail out here would be good. FWICT, it is because we can't spell out unnamed params in the outlined definition?

https://github.com/llvm/llvm-project/pull/95235


More information about the cfe-commits mailing list