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

via cfe-commits cfe-commits at lists.llvm.org
Thu Nov 30 11:25:59 PST 2023


================
@@ -7909,6 +7903,37 @@ bool Sema::CheckTemplateTemplateArgument(TemplateTemplateParmDecl *Param,
                                          Arg.getLocation());
 }
 
+static Sema::SemaDiagnosticBuilder noteLocation(Sema &S, const NamedDecl &Decl,
+                                                unsigned HereDiagID,
+                                                unsigned ExternalDiagID) {
+  if (Decl.getLocation().isValid())
+    return S.Diag(Decl.getLocation(), HereDiagID);
+
+  SmallString<128> Str;
+  llvm::raw_svector_ostream Out(Str);
+  PrintingPolicy PP = S.getPrintingPolicy();
+  PP.TerseOutput = 1;
+  Decl.print(Out, PP);
+  return S.Diag(Decl.getLocation(), ExternalDiagID) << Out.str();
----------------
cor3ntin wrote:

Why not `<< Decl` directly?

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


More information about the cfe-commits mailing list