https://github.com/jtstogel created
https://github.com/llvm/llvm-project/pull/190374
After a68ae7b0cc0922b79114aabe8cf1ec8dc68524d7, calling `<<` with a
`std::string_view` gives:
```
clang/include/clang/Basic/Diagnostic.h:1319:8: error: use of overloaded
operator '<<' is ambiguous (with operand types 'const StreamingDiagnostic' and
'const std::string_view')
1319 | DB << V;
| ~~ ^ ~
```
>From 6b8b34a84f1fb8ba66dc0b2f20e3870a43291715 Mon Sep 17 00:00:00 2001
From: jtstogel <[email protected]>
Date: Fri, 3 Apr 2026 10:31:09 -0700
Subject: [PATCH] [DiagnosticInfo] Allow std::string_view in DiagnosticBuilder
opeartor<<.
After a68ae7b0cc0922b79114aabe8cf1ec8dc68524d7, calling `<<` with a
`std::string_view` gives:
```
clang/include/clang/Basic/Diagnostic.h:1319:8: error: use of overloaded
operator '<<' is ambiguous (with operand types 'const StreamingDiagnostic' and
'const std::string_view')
1319 | DB << V;
| ~~ ^ ~
```
---
clang/include/clang/Basic/Diagnostic.h | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/clang/include/clang/Basic/Diagnostic.h
b/clang/include/clang/Basic/Diagnostic.h
index 5a6f5fd61a5db..6dc2eb040c9ca 100644
--- a/clang/include/clang/Basic/Diagnostic.h
+++ b/clang/include/clang/Basic/Diagnostic.h
@@ -1374,6 +1374,12 @@ inline const StreamingDiagnostic &operator<<(const
StreamingDiagnostic &DB,
return DB;
}
+inline const StreamingDiagnostic &operator<<(const StreamingDiagnostic &DB,
+ std::string_view S) {
+ DB.AddString(S);
+ return DB;
+}
+
inline const StreamingDiagnostic &operator<<(const StreamingDiagnostic &DB,
const std::string &S) {
DB.AddString(S);
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits