[clang] Rework the printing of attributes (PR #87281)

Kim Gräsman via cfe-commits cfe-commits at lists.llvm.org
Thu Apr 11 23:21:59 PDT 2024


kimgr wrote:

I can confirm that the double space comes from this PR;
```diff
diff --git a/clang/unittests/AST/DeclPrinterTest.cpp b/clang/unittests/AST/DeclPrinterTest.cpp
index c24e442621c9..c2d02e74a62c 100644
--- a/clang/unittests/AST/DeclPrinterTest.cpp
+++ b/clang/unittests/AST/DeclPrinterTest.cpp
@@ -1555,3 +1555,11 @@ TEST(DeclPrinter, VarDeclWithInitializer) {
       PrintedDeclCXX17Matches("void foo() {int arr[42]; for(int a : arr);}",
                               namedDecl(hasName("a")).bind("id"), "int a"));
 }
+
+TEST(DeclPrinter, TestTemplateFinal) {
+  ASSERT_TRUE(PrintedDeclCXX11Matches(
+      "template<typename T>\n"
+      "class FinalTemplate final {};",
+      classTemplateDecl(hasName("FinalTemplate")).bind("id"),
+      "template <typename T> class final FinalTemplate final {}"));
+}
```
fails with:
```
.../llvm-project/clang/unittests/AST/DeclPrinterTest.cpp:1560: [...]
  Expected "template <typename T> class final FinalTemplate final {}"
  got           "template <typename T> class  final FinalTemplate final {}")
```
(edited so it's easier to see the diff).

It passes after I revert the `Rework attributes` commits:

* 9391ff8c86007562d40c240ea082b7c0cbf35947
* 62e92573d28d62ab7e6438ac34d513b07c51ce09
* a30662fc2acdd73ca1a9217716299a4676999fb4

Again, from my point of view, this "bug" is fine on mainline, we can work around it. But it would be nice if this patch was not backported to 18 as it breaks our corresponding release.

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


More information about the cfe-commits mailing list