[PATCH] D128202: [clangd] Include "final" when printing class declaration

Sam McCall via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Jul 11 03:22:23 PDT 2022


This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG9f57b65a2728: [clangd] Include "final" when printing class declaration (authored by tom-anders, committed by sammccall).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128202

Files:
  clang-tools-extra/clangd/unittests/HoverTests.cpp
  clang/lib/AST/DeclPrinter.cpp


Index: clang/lib/AST/DeclPrinter.cpp
===================================================================
--- clang/lib/AST/DeclPrinter.cpp
+++ clang/lib/AST/DeclPrinter.cpp
@@ -1007,6 +1007,12 @@
     }
   }
 
+  if (auto *Def = D->getDefinition()) {
+      if (D->hasAttr<FinalAttr>()) {
+          Out << " final";
+      }
+  }
+
   if (D->isCompleteDefinition()) {
     // Print the base classes
     if (D->getNumBases()) {
Index: clang-tools-extra/clangd/unittests/HoverTests.cpp
===================================================================
--- clang-tools-extra/clangd/unittests/HoverTests.cpp
+++ clang-tools-extra/clangd/unittests/HoverTests.cpp
@@ -198,7 +198,7 @@
                     typename = char,
                     int = 0,
                     bool Q = false,
-                    class... Ts> class Foo {};
+                    class... Ts> class Foo final {};
           template <template<typename, bool...> class T>
           [[F^oo]]<T> foo;
           )cpp",
@@ -209,7 +209,7 @@
          HI.Definition =
              R"cpp(template <template <typename, bool...> class C, typename = char, int = 0,
           bool Q = false, class... Ts>
-class Foo {})cpp";
+class Foo final {})cpp";
          HI.TemplateParameters = {
              {{"template <typename, bool...> class"},
               std::string("C"),


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D128202.443587.patch
Type: text/x-patch
Size: 1343 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20220711/4a922658/attachment.bin>


More information about the cfe-commits mailing list