[libc-commits] [llvm] [libcxxabi] [lld] [clang-tools-extra] [clang] [openmp] [libc] [libcxx] [libunwind] [lldb] [mlir] [flang] [Clang][Sema] Don't say "is declared here" for invalid template locations (PR #71264)

Aaron Ballman via libc-commits libc-commits at lists.llvm.org
Wed Dec 6 12:10:54 PST 2023


================
@@ -898,8 +895,9 @@ void Sema::DiagnoseTemplateParameterShadow(SourceLocation Loc, Decl *PrevDecl) {
   // Make this a warning when MSVC compatibility is requested.
   unsigned DiagId = getLangOpts().MSVCCompat ? diag::ext_template_param_shadow
                                              : diag::err_template_param_shadow;
-  Diag(Loc, DiagId) << cast<NamedDecl>(PrevDecl)->getDeclName();
-  Diag(PrevDecl->getLocation(), diag::note_template_param_here);
+  NamedDecl *ND = cast<NamedDecl>(PrevDecl);
----------------
AaronBallman wrote:

```suggestion
  const auto *ND = cast<NamedDecl>(PrevDecl);
```

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


More information about the libc-commits mailing list