[clang] [Clang] add fix-it hints for unknown attributes (PR #141305)

Erich Keane via cfe-commits cfe-commits at lists.llvm.org
Wed May 28 06:47:17 PDT 2025


================
@@ -672,12 +672,13 @@ static Attr *ProcessStmtAttribute(Sema &S, Stmt *St, const ParsedAttr &A,
       !(A.existsInTarget(S.Context.getTargetInfo()) ||
         (S.Context.getLangOpts().SYCLIsDevice && Aux &&
          A.existsInTarget(*Aux)))) {
-    S.Diag(A.getLoc(), A.isRegularKeywordAttribute()
-                           ? (unsigned)diag::err_keyword_not_supported_on_target
-                       : A.isDeclspecAttribute()
-                           ? (unsigned)diag::warn_unhandled_ms_attribute_ignored
-                           : (unsigned)diag::warn_unknown_attribute_ignored)
-        << A << A.getRange();
+    if (A.isRegularKeywordAttribute() || A.isDeclspecAttribute())
----------------
erichkeane wrote:

This 'if' is REALLY pushing our 'single-statement, no curleys' rule, and I think hits: `However, braces should be used in cases where the omission of braces harm the readability and maintainability of the code.`

So I'd ask for curleys on this + the else.

https://github.com/llvm/llvm-project/pull/141305


More information about the cfe-commits mailing list