================
@@ -452,6 +452,124 @@ template <typename U, bool>
 inline T Foo<T>::bar(const T& t, const U& u) { return {}; }
 )cpp",
           ""},
+      // C++11 attribute list
+      {
+          R"cpp(
+            struct A {
+              [ [nodiscard, deprecated("no")] ] int ^foo() { return 0; }
+            };
+)cpp",
+          R"cpp(
+            struct A {
+              [ [nodiscard, deprecated("no")] ] int foo() ;
+            };
+)cpp",
+          "int A::foo() { return 0; }\n"},
+      // GNU attribute list
+      {
+          R"cpp(
+            struct A {
+              __attribute__((noinline, annotate("bar"))) int ^foo() { return 
0; }
+            };
+)cpp",
+          R"cpp(
+            struct A {
+              __attribute__((noinline, annotate("bar"))) int foo() ;
+            };
+)cpp",
+          "int A::foo() { return 0; }\n"},
+      // Attribute at the end of the function declarator
+      {
+          R"cpp(
+            struct A {
+              int ^foo() __attribute__((noinline)) { return 0; }
+            };
+)cpp",
+          R"cpp(
+            struct A {
+              int foo() __attribute__((noinline)) ;
+            };
+)cpp",
+          "int A::foo() { return 0; }\n"},
+      // Mixed attributes
+      {
+          R"cpp(
+            struct A {
+              __attribute__((noinline)) [ [nodiscard] ] int ^foo() { return 0; 
}
+            };
+)cpp",
+          R"cpp(
+            struct A {
+              __attribute__((noinline)) [ [nodiscard] ] int foo() ;
+            };
+)cpp",
+          "int A::foo() { return 0; }\n"},
+      // Attributes with namespaces
+      {
+          R"cpp(
+            struct A {
+              [ [clang::noinline] ] int ^foo() { return 0; }
+            };
+)cpp",
+          R"cpp(
+            struct A {
+              [ [clang::noinline] ] int foo() ;
+            };
+)cpp",
+          "int A::foo() { return 0; }\n"},
+      {
+          R"cpp(
+            struct A {
+              [ [using clang: noinline, annotate("x")] ] int ^foo() { return 
0; }
+            };
+)cpp",
+          R"cpp(
+            struct A {
+              [ [using clang: noinline, annotate("x")] ] int foo() ;
+            };
+)cpp",
+          "int A::foo() { return 0; }\n"},
+      // Unknown attributes (not part of the AST, so they are not removed)
+      {
+          R"cpp(
+            struct A {
+              [ [unknown] ] int ^foo() { return 0; }
+            };
+)cpp",
+          R"cpp(
+            struct A {
+              [ [unknown] ] int foo() ;
+            };
+)cpp",
+          "[ [unknown] ] int A::foo() { return 0; }\n"},
+      // Unknown and known attribute in one list
+      {
+          R"cpp(
+            struct A {
+              [ [unknown, nodiscard] ] int ^foo() { return 0; }
----------------
max-winkler wrote:

PR description is updated accordingly.

https://github.com/llvm/llvm-project/pull/242635
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to