[clang] [Parser][BoundsSafety] Print attribute as macro if it's system defined (PR #107619)
Yeoul Na via cfe-commits
cfe-commits at lists.llvm.org
Tue Sep 17 12:59:14 PDT 2024
================
@@ -1105,16 +1120,16 @@ enum AttributeDeclKind {
inline const StreamingDiagnostic &operator<<(const StreamingDiagnostic &DB,
const ParsedAttr &At) {
- DB.AddTaggedVal(reinterpret_cast<uint64_t>(At.getAttrName()),
+ const IdentifierInfo *AttrName =
+ At.printAsMacro() ? At.getMacroIdentifier() : At.getAttrName();
+ DB.AddTaggedVal(reinterpret_cast<uint64_t>(AttrName),
----------------
rapidsna wrote:
@AaronBallman @erichkeane Thanks for the valuable feedback!
Our motivation was that with `-fbounds-safety`, we would have a toolchain header defines this:
`#define __counted_by(c) __attribute__((__counted_by(c)__))`
then the user code uses it as `__counted_by` spelling,
we'd like it to be just printed as `__counted_by` and we don't want it to be printed as `__counted_by__` nor having a redundant aka (`__counted_by__` ) next to `__counted_by`.
Also, that was why we were limiting this change specifically to "system-defined" macros.
Does it make sense? I guess there might be a better way to implement this behavior in Clang?
https://github.com/llvm/llvm-project/pull/107619
More information about the cfe-commits
mailing list