[clang] [APINotes] Diagnose invalid Where.Parameters selectors (PR #209408)

Gábor Horváth via cfe-commits cfe-commits at lists.llvm.org
Tue Jul 28 05:31:13 PDT 2026


================
@@ -7,10 +7,35 @@
 //===----------------------------------------------------------------------===//
 
 #include "clang/APINotes/Types.h"
+#include "llvm/ADT/StringExtras.h"
 #include "llvm/Support/raw_ostream.h"
 
+namespace {
+template <typename ParameterT>
+std::string
+formatAPINotesParameterSelectorImpl(llvm::ArrayRef<ParameterT> Parameters) {
+  std::string Result;
+  llvm::raw_string_ostream OS(Result);
+  OS << "[";
+  llvm::interleaveComma(Parameters, OS);
+  OS << "]";
+  return Result;
+}
+} // namespace
+
 namespace clang {
 namespace api_notes {
+
+std::string
+formatAPINotesParameterSelector(llvm::ArrayRef<llvm::StringRef> Parameters) {
----------------
Xazax-hun wrote:

I wonder if we need these two overloads. Couldn't we call `formatAPINotesParameterSelectorImpl` directly and let template argument deduction do the work? Or alternatively, maybe we could just take an arbitrary range like:
```
template <typename R> std::string formatAPINotesParameterSelector(R &&)
```

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


More information about the cfe-commits mailing list