[clang-tools-extra] 209e30b - [clangd] Don't repeat class template args when printing constructor definitions

Sam McCall via cfe-commits cfe-commits at lists.llvm.org
Fri Nov 15 10:26:03 PST 2019


Author: Sam McCall
Date: 2019-11-15T19:23:20+01:00
New Revision: 209e30b7e0c20796f8f2c941d13e7e4994479c6b

URL: https://github.com/llvm/llvm-project/commit/209e30b7e0c20796f8f2c941d13e7e4994479c6b
DIFF: https://github.com/llvm/llvm-project/commit/209e30b7e0c20796f8f2c941d13e7e4994479c6b.diff

LOG: [clangd] Don't repeat class template args when printing constructor definitions

This fixes part of https://github.com/clangd/clangd/issues/76

Added: 
    

Modified: 
    clang-tools-extra/clangd/XRefs.cpp
    clang-tools-extra/clangd/unittests/XRefsTests.cpp

Removed: 
    


################################################################################
diff  --git a/clang-tools-extra/clangd/XRefs.cpp b/clang-tools-extra/clangd/XRefs.cpp
index 2f4cfc2608e5..2fd147c2d255 100644
--- a/clang-tools-extra/clangd/XRefs.cpp
+++ b/clang-tools-extra/clangd/XRefs.cpp
@@ -456,6 +456,7 @@ static std::string printDefinition(const Decl *D) {
   PrintingPolicy Policy =
       printingPolicyForDecls(D->getASTContext().getPrintingPolicy());
   Policy.IncludeTagDefinition = false;
+  Policy.SuppressTemplateArgsInCXXConstructors = true;
   D->print(OS, Policy);
   OS.flush();
   return Definition;

diff  --git a/clang-tools-extra/clangd/unittests/XRefsTests.cpp b/clang-tools-extra/clangd/unittests/XRefsTests.cpp
index 15f94e986770..cbc81805fd73 100644
--- a/clang-tools-extra/clangd/unittests/XRefsTests.cpp
+++ b/clang-tools-extra/clangd/unittests/XRefsTests.cpp
@@ -920,7 +920,7 @@ void foo())cpp";
          HI.Kind = SymbolKind::Constructor;
          HI.Type = "void ()";          // FIXME: Should be None
          HI.ReturnType = "void";       // FIXME: Should be None or X<T*>
-         HI.Definition = "X<type - parameter - 0 - 0 *>()"; // FIXME: --> X()
+         HI.Definition = "X()";
          HI.Parameters.emplace();
        }},
 


        


More information about the cfe-commits mailing list