[clang] [Clang] include attribute scope in diagnostics (PR #144619)
Oleksandr T. via cfe-commits
cfe-commits at lists.llvm.org
Fri Jun 27 05:03:56 PDT 2025
================
@@ -506,7 +506,15 @@ void clang::FormatASTNodeDiagnosticArgument(
case DiagnosticsEngine::ak_attr: {
const Attr *At = reinterpret_cast<Attr *>(Val);
assert(At && "Received null Attr object!");
- OS << '\'' << At->getSpelling() << '\'';
+
+ OS << '\'';
+ if (At->hasScope()) {
----------------
a-tarasyuk wrote:
@AaronBallman This kind is used here
https://github.com/llvm/llvm-project/blob/cf3d136c225361c9a3d1488cd285c784fd6a2a92/clang/include/clang/AST/Attr.h#L383-L387
Some custom attributes don’t explicitly set a name from the parsed attribute - for example:
https://github.com/llvm/llvm-project/blob/ec48d15b2003253e26d9f902b252f92e89a114e2/clang/lib/Sema/SemaHLSL.cpp#L704-L706
Instead, these attributes derive their name from the spelling, which is part of `Attr`.
https://github.com/llvm/llvm-project/blob/cf3d136c225361c9a3d1488cd285c784fd6a2a92/clang/include/clang/AST/Attr.h#L95
This _kind_ can likely be removed, and the logic for handling custom attributes without an explicit name can be moved into the overload. In that overload, we can either use a string-based kind directly or delegate to the `AttributeCommonInfo` overload
https://github.com/llvm/llvm-project/pull/144619
More information about the cfe-commits
mailing list