================
@@ -73,3 +73,15 @@ class C {
// CHECK: void pwtt(void *, int) __attribute__((pointer_with_type_tag(foo,
2, 3)));
void pwtt(void *, int) __attribute__((pointer_with_type_tag(foo, 2, 3)));
};
+
+#define ANNOTATE_ATTR __attribute__((annotate("Annotated")))
+ANNOTATE_ATTR int annotated_attr ANNOTATE_ATTR = 0;
+// CHECK: __attribute__((annotate("Annotated"))) int annotated_attr
__attribute__((annotate("Annotated"))) = 0;
+
+// FIXME: We do not print the attribute as written after the type specifier.
+int ANNOTATE_ATTR annotated_attr_fixme = 0;
----------------
AaronBallman wrote:
The PR changes behavior from one really broken state to a slightly less but
still broken state. Consider:
```
[[clang::annotate("do the")]] int [[clang::annotate_type("test")]] *
[[clang::annotate_type("again")]] i [[clang::annotate("and again!")]] = 0;
```
Currently we print this back as: `int *i [[clang::annotate_type(...)]]
[[clang::annotate_type(...)]] [[clang::annotate("do the")]]
[[clang::annotate("and again!")]] = 0;` which is all kinds of wrong. Now we
print this back as: `[[clang::annotate("do the")]] int *i
[[clang::annotate_type(...)]] [[clang::annotate_type(...)]]
[[clang::annotate("and again!")]] = 0;` which is in better shape but still gets
the type attributes wrong by moving the attribute off `int` and `*` and onto
the declaration of `i`. The new code won't compile (it tries to add type
attributes to a declaration, and the `...` instead of the original string
literal won't compile either).
Given that printing is best-effort, perhaps this is fine because it's
incremental improvement, but we're still not quite there in terms of accurate
printing either.
https://github.com/llvm/llvm-project/pull/87281
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits