================
@@ -0,0 +1,202 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#include "FormatvStringCheck.h"
+#include "clang/AST/Expr.h"
+#include "clang/ASTMatchers/ASTMatchers.h"
+#include "llvm/ADT/STLExtras.h"
+#include "llvm/ADT/SmallBitVector.h"
+#include "llvm/ADT/SmallVector.h"
+#include "llvm/ADT/StringRef.h"
+#include "llvm/Support/Error.h"
+
+using namespace clang::ast_matchers;
+
+namespace clang::tidy::llvm_check {
+
+namespace {
+
+struct ParseResult {
+  llvm::SmallVector<unsigned, 4> Indices;
+  unsigned MaxIndex = 0;
+};
+
+} // namespace
+
+static llvm::Expected<ParseResult> parseFormatvString(llvm::StringRef Fmt) {
----------------
kastiglione wrote:

I am not particularly familiar with `std::format`. According to my searching, 
the format string validation is done at compile time by the standard library. 
In which case it seems unlikely to be able to reuse that validation?

Quoting https://en.cppreference.com/cpp/utility/format/format

> Since [P2216R3](https://wg21.link/P2216R3), `std::format` does a compile-time 
> check on the format string (via the helper type `std::format_string` or 
> `std::wformat_string`). If it is found to be invalid for the types of the 
> arguments to be formatted, a compilation error will be emitted. If the format 
> string cannot be a compile-time constant, or the compile-time check needs to 
> be avoided, use `std::vformat` or 
> [`std::dynamic_format`](https://en.cppreference.com/cpp/utility/format/dynamic_format)
>  on `fmt`(since C++26) instead.

https://github.com/llvm/llvm-project/pull/195974
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to