LLVM 19.0.0git
StringMap.h
Go to the documentation of this file.
1//===- llvm/Testing/ADT/StringMap.h ---------------------------------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
9#ifndef LLVM_TESTING_ADT_STRINGMAP_H_
10#define LLVM_TESTING_ADT_STRINGMAP_H_
11
12#include "llvm/ADT/STLExtras.h"
13#include "llvm/ADT/StringMap.h"
16#include <ostream>
17#include <sstream>
18
19namespace llvm {
20
21/// Support for printing to std::ostream, for use with e.g. producing more
22/// useful error messages with Google Test.
23template <typename T>
24std::ostream &operator<<(std::ostream &OS, const StringMap<T> &M) {
25 if (M.empty()) {
26 return OS << "{ }";
27 }
28
29 std::vector<std::string> Lines;
30 for (const auto &E : M) {
31 std::ostringstream SS;
32 SS << E << ",";
33 Lines.push_back(SS.str());
34 }
35 llvm::sort(Lines);
36 Lines.insert(Lines.begin(), "{");
37 Lines.insert(Lines.end(), "}");
38
39 return OS << llvm::formatv("{0:$[\n]}",
40 make_range(Lines.begin(), Lines.end()))
41 .str();
42}
43
44} // namespace llvm
45
46#endif
This file defines the StringMap class.
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
This file contains some templates that are useful if you are working with the STL at all.
raw_pwrite_stream & OS
StringMap - This is an unconventional map that is specialized for handling keys that are "strings",...
Definition: StringMap.h:127
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18
iterator_range< T > make_range(T x, T y)
Convenience function for iterating over sub-ranges.
auto formatv(const char *Fmt, Ts &&...Vals) -> formatv_object< decltype(std::make_tuple(support::detail::build_format_adapter(std::forward< Ts >(Vals))...))>
void sort(IteratorTy Start, IteratorTy End)
Definition: STLExtras.h:1647
raw_ostream & operator<<(raw_ostream &OS, const APFixedPoint &FX)
Definition: APFixedPoint.h:293