Skip to content

Fix calls to PrintedDeclCXX98Matches. #86741

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Mar 29, 2024
Merged

Conversation

zahiraam
Copy link
Contributor

@zahiraam zahiraam commented Mar 26, 2024

Fix the calls to PrintedDeclCXX98Matches to take the lambda function as the last argument.

@zahiraam zahiraam marked this pull request as ready for review March 26, 2024 21:24
@llvmbot llvmbot added the clang Clang issues not falling into any other category label Mar 26, 2024
@llvmbot
Copy link
Member

llvmbot commented Mar 26, 2024

@llvm/pr-subscribers-clang

Author: Zahira Ammarguellat (zahiraam)

Changes

https://lab.llvm.org/buildbot/#/builders/36/builds/43998/steps/12/logs/stdio


Full diff: https://github.com/llvm/llvm-project/pull/86741.diff

1 Files Affected:

  • (modified) clang/unittests/AST/DeclPrinterTest.cpp (+29-25)
diff --git a/clang/unittests/AST/DeclPrinterTest.cpp b/clang/unittests/AST/DeclPrinterTest.cpp
index 07fa02bd96e25d..f2b027a25621ce 100644
--- a/clang/unittests/AST/DeclPrinterTest.cpp
+++ b/clang/unittests/AST/DeclPrinterTest.cpp
@@ -1387,34 +1387,38 @@ TEST(DeclPrinter, TestTemplateArgumentList16) {
 }
 
 TEST(DeclPrinter, TestCXXRecordDecl17) {
-  ASSERT_TRUE(PrintedDeclCXX98Matches("template<typename T> struct Z {};"
-                                      "struct X {};"
-                                      "Z<X> A;",
-                                      "A", "Z<X> A"));
-  [](PrintingPolicy &Policy) { Policy.SuppressTagKeyword = false; };
+  ASSERT_TRUE(PrintedDeclCXX98Matches(
+      "template<typename T> struct Z {};"
+      "struct X {};"
+      "Z<X> A;",
+      "A", "Z<X> A",
+      [](PrintingPolicy &Policy) { Policy.SuppressTagKeyword = false; }));
 }
 
 TEST(DeclPrinter, TestCXXRecordDecl18) {
-  ASSERT_TRUE(PrintedDeclCXX98Matches("template<typename T> struct Z {};"
-                                      "struct X {};"
-                                      "Z<X> A;"
-                                      "template <typename T1, int>"
-                                      "struct Y{};"
-                                      "Y<Z<X>, 2> B;",
-                                      "B", "Y<Z<X>, 2> B"));
-  [](PrintingPolicy &Policy) { Policy.SuppressTagKeyword = false; };
+  ASSERT_TRUE(PrintedDeclCXX98Matches(
+      "template<typename T> struct Z {};"
+      "struct X {};"
+      "Z<X> A;"
+      "template <typename T1, int>"
+      "struct Y{};"
+      "Y<Z<X>, 2> B;",
+      "B", "Y<Z<X>, 2> B",
+      [](PrintingPolicy &Policy) { Policy.SuppressTagKeyword = false; }));
 }
 
 TEST(DeclPrinter, TestCXXRecordDecl19) {
-  ASSERT_TRUE(PrintedDeclCXX98Matches("template<typename T> struct Z {};"
-                                      "struct X {};"
-                                      "Z<X> A;"
-                                      "template <typename T1, int>"
-                                      "struct Y{};"
-                                      "Y<Z<X>, 2> B;",
-                                      "B", "Y<Z<X>, 2> B"));
-  [](PrintingPolicy &Policy) { Policy.SuppressTagKeyword = true; };
+  ASSERT_TRUE(PrintedDeclCXX98Matches(
+      "template<typename T> struct Z {};"
+      "struct X {};"
+      "Z<X> A;"
+      "template <typename T1, int>"
+      "struct Y{};"
+      "Y<Z<X>, 2> B;",
+      "B", "Y<Z<X>, 2> B",
+      [](PrintingPolicy &Policy) { Policy.SuppressTagKeyword = true; }));
 }
+
 TEST(DeclPrinter, TestCXXRecordDecl20) {
   ASSERT_TRUE(PrintedDeclCXX98Matches(
       "template <typename T, int N> class Inner;"
@@ -1431,8 +1435,8 @@ TEST(DeclPrinter, TestCXXRecordDecl20) {
       "};"
       "Outer<Inner<int, 10>, 5>::NestedStruct nestedInstance(100);",
       "nestedInstance",
-      "Outer<Inner<int, 10>, 5>::NestedStruct nestedInstance(100)"));
-  [](PrintingPolicy &Policy) { Policy.SuppressTagKeyword = false; };
+      "Outer<Inner<int, 10>, 5>::NestedStruct nestedInstance(100)",
+      [](PrintingPolicy &Policy) { Policy.SuppressTagKeyword = false; }));
 }
 
 TEST(DeclPrinter, TestCXXRecordDecl21) {
@@ -1451,8 +1455,8 @@ TEST(DeclPrinter, TestCXXRecordDecl21) {
       "};"
       "Outer<Inner<int, 10>, 5>::NestedStruct nestedInstance(100);",
       "nestedInstance",
-      "Outer<Inner<int, 10>, 5>::NestedStruct nestedInstance(100)"));
-  [](PrintingPolicy &Policy) { Policy.SuppressTagKeyword = true; };
+      "Outer<Inner<int, 10>, 5>::NestedStruct nestedInstance(100)",
+      [](PrintingPolicy &Policy) { Policy.SuppressTagKeyword = true; }));
 }
 
 TEST(DeclPrinter, TestFunctionParamUglified) {

@zahiraam
Copy link
Contributor Author

Tagging @amy-kwan and @kazutakahirata . Hopefully this will fix the issue.

Copy link
Contributor

@kazutakahirata kazutakahirata left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Thanks!

@kazutakahirata
Copy link
Contributor

Would you mind merging this PR into the LLVM source tree if nothing is blocking you?

If something is blocking you, I am happy to revert your original patch on your behalf (along with the (void) fix).

@zahiraam
Copy link
Contributor Author

Would you mind merging this PR into the LLVM source tree if nothing is blocking you?

If something is blocking you, I am happy to revert your original patch on your behalf (along with the (void) fix).

I thought the issue was fixed with the (void) addition! If not, I will merge this PR immediately.

@kazutakahirata
Copy link
Contributor

I thought the issue was fixed with the (void) addition! If not, I will merge this PR immediately.

Sorry, I misunderstood. The void fix (577e0ef) fixes the build error.

Meanwhile, I am guessing that you have added lambda functions to control the behavior of PrintedDeclCXX98Matches. If that's the case, you should merge this PR. But then again, there is no urgency as the build has been restored.

@zahiraam
Copy link
Contributor Author

I thought the issue was fixed with the (void) addition! If not, I will merge this PR immediately.

Sorry, I misunderstood. The void fix (577e0ef) fixes the build error.

Meanwhile, I am guessing that you have added lambda functions to control the behavior of PrintedDeclCXX98Matches. If that's the case, you should merge this PR. But then again, there is no urgency as the build has been restored.

OK. I have edited the description since this is not for fixing the build as much as fixing the call PrintedDeclCXX98Matches.

@zahiraam
Copy link
Contributor Author

I thought the issue was fixed with the (void) addition! If not, I will merge this PR immediately.

Sorry, I misunderstood. The void fix (577e0ef) fixes the build error.
Meanwhile, I am guessing that you have added lambda functions to control the behavior of PrintedDeclCXX98Matches. If that's the case, you should merge this PR. But then again, there is no urgency as the build has been restored.

OK. I have edited the description since this is not for fixing the build as much as fixing the call PrintedDeclCXX98Matches.

Now I wonder if the fix should be with the (void) or without. Have you tried it locally to see if you get the same build error?

@kazutakahirata
Copy link
Contributor

Now I wonder if the fix should be with the (void) or without. Have you tried it locally to see if you get the same build error?

Yes, I just tried your patch and confirmed that the unit test passes without a problem.

No, you shouldn't keep (void) there. It's there just to silence the warning because the lambda is sitting unused outside the call to PrintedDeclCXX98Matches. Once you bring the lambda inside the call to PrintedDeclCXX98Matches, the lambda is used, so you shouldn't get a warning.

@zahiraam
Copy link
Contributor Author

Now I wonder if the fix should be with the (void) or without. Have you tried it locally to see if you get the same build error?

Yes, I just tried your patch and confirmed that the unit test passes without a problem.

No, you shouldn't keep (void) there. It's there just to silence the warning because the lambda is sitting unused outside the call to PrintedDeclCXX98Matches. Once you bring the lambda inside the call to PrintedDeclCXX98Matches, the lambda is used, so you shouldn't get a warning.

Perfect! As soon as the testing completes I will merge it in. Thanks.

@zahiraam zahiraam changed the title Fix buildbot failure. Fix calls to PrintedDeclCXX98Matches. Mar 28, 2024
@zahiraam zahiraam merged commit 5af7679 into llvm:main Mar 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
clang Clang issues not falling into any other category
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants