[clang] [Clang]: enhance handling of [[deprecated]] attribute diagnostics for local variables (PR #113575)

via cfe-commits cfe-commits at lists.llvm.org
Thu Oct 24 23:45:41 PDT 2024


================
@@ -182,6 +182,12 @@ static bool ShouldDiagnoseAvailabilityInContext(
       return false;
   }
 
+  if (K == AR_Deprecated) {
+    if (const auto *VD = dyn_cast<VarDecl>(OffendingDecl))
+      if (VD->isLocalVarDecl() && VD->isDeprecated())
----------------
Sirraide wrote:

```suggestion
      if (VD->isLocalVarDeclOrParm() && VD->isDeprecated())
```
Otherwise, this won’t handle cases such as:
```c++
[[deprecated]] void f([[deprecated]] int x) { x = 4; }
```
We should also add a test for that.

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


More information about the cfe-commits mailing list