[PATCH] D32424: Add a fix-it for -Wunguarded-availability

Erik Pilkington via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu May 4 09:18:26 PDT 2017


erik.pilkington added a comment.

Hi Alex, thanks for working on this! This looks right, but I have a couple of comments.
Thanks,
Erik



================
Comment at: lib/Sema/SemaDeclAttr.cpp:7151
+    Visitor.Scope = Scope;
+    Visitor.TraverseStmt(const_cast<CompoundStmt *>(Scope));
+    return Visitor.LastMatchingDREFirstNonScopeStmt;
----------------
I think this could be simplified: If we iterate backwards through the CompoundStmt::body(), calling `RecursiveASTVisitor::TraverseStmt()`, and bail out if we encounter a `DeclRefExpr` to D, returning the current Stmt. This also has the advantage that we don't have to iterate forward through the CompoundStmt when we're looking for the last Child Stmt. Have you considered this option?


================
Comment at: lib/Sema/SemaDeclAttr.cpp:7249
+    auto FixitDiag =
+        SemaRef.Diag(Range.getBegin(), diag::note_unguarded_available_silence)
         << Range << D;
----------------
Since we emit a fixit to use `__builtin_available` in non objective-c modes, this diagnostic should take another argument to suggest using the right form of @available depending on the source language. (Currently it's hard-coded to suggest @available).


Repository:
  rL LLVM

https://reviews.llvm.org/D32424





More information about the cfe-commits mailing list