Skip to content

Commit 4a3a4d1

Browse files
committed
absl::string_view -> std::string_view.
Now that we depend on C++17, there is no need to use the ABSL version.
1 parent dc15373 commit 4a3a4d1

23 files changed

+188
-185
lines changed

.github/workflows/build.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ jobs:
2929
id: llvm-revision
3030
run: |
3131
echo "revision=$(git -C ${{ github.workspace }}/llvm-project rev-parse HEAD)" >> "$GITHUB_OUTPUT"
32-
- uses: actions/cache@v2
32+
- uses: actions/cache@v4
3333
id: llvm-build
3434
with:
3535
path: ${{ github.workspace }}/build/llvm-project
@@ -78,7 +78,7 @@ jobs:
7878
id: llvm-revision
7979
run: |
8080
echo "revision=$(git -C ${{ github.workspace }}/llvm-project rev-parse HEAD)" >> "$GITHUB_OUTPUT"
81-
- uses: actions/cache@v2
81+
- uses: actions/cache@v4
8282
id: llvm-build
8383
with:
8484
path: ${{ github.workspace }}/build/llvm-project
@@ -126,7 +126,7 @@ jobs:
126126
id: llvm-revision
127127
run: |
128128
echo "revision=$(git -C ${{ github.workspace }}/llvm-project rev-parse HEAD)" >> "$GITHUB_OUTPUT"
129-
- uses: actions/cache@v2
129+
- uses: actions/cache@v4
130130
id: llvm-build
131131
with:
132132
path: ${{ github.workspace }}/build/llvm-project

src/bloaty.cc

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,11 @@ typedef size_t z_size_t;
3636
#include <mutex>
3737
#include <sstream>
3838
#include <string>
39+
#include <string_view>
3940
#include <thread>
4041
#include <unordered_map>
4142
#include <vector>
43+
4244
#if !defined(_WIN32)
4345
#include <sys/mman.h>
4446
#include <sys/wait.h>
@@ -53,7 +55,6 @@ typedef size_t z_size_t;
5355
#include "absl/memory/memory.h"
5456
#include "absl/strings/numbers.h"
5557
#include "absl/strings/str_join.h"
56-
#include "absl/strings/string_view.h"
5758
#include "absl/strings/substitute.h"
5859
#include "bloaty.h"
5960
#include "bloaty.pb.h"
@@ -62,7 +63,7 @@ typedef size_t z_size_t;
6263
#include "re.h"
6364
#include "util.h"
6465

65-
using absl::string_view;
66+
using std::string_view;
6667

6768
namespace bloaty {
6869

@@ -899,11 +900,11 @@ class MmapInputFile : public InputFile {
899900
MmapInputFile& operator=(const MmapInputFile&) = delete;
900901
~MmapInputFile() override;
901902

902-
bool TryOpen(absl::string_view filename,
903+
bool TryOpen(std::string_view filename,
903904
std::unique_ptr<InputFile>& file) override {
904905
return DoTryOpen(filename, file);
905906
}
906-
static bool DoTryOpen(absl::string_view filename,
907+
static bool DoTryOpen(std::string_view filename,
907908
std::unique_ptr<InputFile>& file);
908909
};
909910

@@ -923,7 +924,7 @@ class FileDescriptor {
923924
int fd_;
924925
};
925926

926-
bool MmapInputFile::DoTryOpen(absl::string_view filename,
927+
bool MmapInputFile::DoTryOpen(std::string_view filename,
927928
std::unique_ptr<InputFile>& file) {
928929
std::string str(filename);
929930
FileDescriptor fd(open(str.c_str(), O_RDONLY));
@@ -987,11 +988,11 @@ class Win32MMapInputFile : public InputFile {
987988
Win32MMapInputFile& operator=(const Win32MMapInputFile&) = delete;
988989
~Win32MMapInputFile() override;
989990

990-
bool TryOpen(absl::string_view filename,
991+
bool TryOpen(std::string_view filename,
991992
std::unique_ptr<InputFile>& file) override {
992993
return DoTryOpen(filename, file);
993994
}
994-
static bool DoTryOpen(absl::string_view filename,
995+
static bool DoTryOpen(std::string_view filename,
995996
std::unique_ptr<InputFile>& file);
996997
};
997998

@@ -1017,7 +1018,7 @@ Win32MMapInputFile::Win32MMapInputFile(string_view filename, string_view data)
10171018
data_ = data;
10181019
}
10191020

1020-
bool Win32MMapInputFile::DoTryOpen(absl::string_view filename,
1021+
bool Win32MMapInputFile::DoTryOpen(std::string_view filename,
10211022
std::unique_ptr<InputFile>& file) {
10221023
std::string str(filename);
10231024
Win32Handle fd(::CreateFileA(str.c_str(), FILE_GENERIC_READ, FILE_SHARE_READ,
@@ -1221,8 +1222,8 @@ void RangeSink::AddFileRangeForVMAddr(const char* analyzer,
12211222
}
12221223

12231224
void RangeSink::AddFileRangeForFileRange(const char* analyzer,
1224-
absl::string_view from_file_range,
1225-
absl::string_view file_range) {
1225+
std::string_view from_file_range,
1226+
std::string_view file_range) {
12261227
uint64_t file_offset = file_range.data() - file_->data().data();
12271228
uint64_t from_file_offset = from_file_range.data() - file_->data().data();
12281229
bool verbose = IsVerboseForFileRange(file_offset, file_range.size());
@@ -1366,7 +1367,7 @@ uint64_t RangeSink::TranslateFileToVM(const char* ptr) {
13661367
return translated;
13671368
}
13681369

1369-
absl::string_view RangeSink::TranslateVMToFile(uint64_t address) {
1370+
std::string_view RangeSink::TranslateVMToFile(uint64_t address) {
13701371
assert(translator_);
13711372
uint64_t translated;
13721373
if (!translator_->vm_map.Translate(address, &translated) ||
@@ -1377,7 +1378,7 @@ absl::string_view RangeSink::TranslateVMToFile(uint64_t address) {
13771378
return file_->data().substr(translated);
13781379
}
13791380

1380-
absl::string_view RangeSink::ZlibDecompress(absl::string_view data,
1381+
std::string_view RangeSink::ZlibDecompress(std::string_view data,
13811382
uint64_t uncompressed_size) {
13821383
if (!arena_) {
13831384
THROW("This range sink isn't prepared to zlib decompress.");
@@ -1390,7 +1391,7 @@ absl::string_view RangeSink::ZlibDecompress(absl::string_view data,
13901391
"warning: ignoring compressed debug data, implausible uncompressed "
13911392
"size (compressed: %zu, uncompressed: %" PRIu64 ")\n",
13921393
data.size(), uncompressed_size);
1393-
return absl::string_view();
1394+
return std::string_view();
13941395
}
13951396
unsigned char* dbuf =
13961397
arena_->google::protobuf::Arena::CreateArray<unsigned char>(

src/bloaty.h

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,10 @@
2828
#include <memory>
2929
#include <set>
3030
#include <string>
31+
#include <string_view>
3132
#include <unordered_map>
3233
#include <vector>
3334

34-
#include "absl/strings/string_view.h"
3535
#include "absl/strings/strip.h"
3636
#include "capstone/capstone.h"
3737

@@ -69,21 +69,21 @@ enum class DataSource {
6969

7070
class InputFile {
7171
public:
72-
InputFile(absl::string_view filename) : filename_(filename) {}
72+
InputFile(std::string_view filename) : filename_(filename) {}
7373
InputFile(const InputFile&) = delete;
7474
InputFile& operator=(const InputFile&) = delete;
75-
virtual bool TryOpen(absl::string_view filename,
75+
virtual bool TryOpen(std::string_view filename,
7676
std::unique_ptr<InputFile>& file) = 0;
7777
virtual ~InputFile() {}
7878

7979
const std::string& filename() const { return filename_; }
80-
absl::string_view data() const { return data_; }
80+
std::string_view data() const { return data_; }
8181

8282
private:
8383
const std::string filename_;
8484

8585
protected:
86-
absl::string_view data_;
86+
std::string_view data_;
8787
};
8888

8989
class InputFileFactory {
@@ -129,34 +129,34 @@ class RangeSink {
129129
// If vmsize or filesize is zero, this mapping is presumed not to exist in
130130
// that domain. For example, .bss mappings don't exist in the file, and
131131
// .debug_* mappings don't exist in memory.
132-
void AddRange(const char *analyzer, absl::string_view name, uint64_t vmaddr,
132+
void AddRange(const char *analyzer, std::string_view name, uint64_t vmaddr,
133133
uint64_t vmsize, uint64_t fileoff, uint64_t filesize);
134134

135-
void AddRange(const char *analyzer, absl::string_view name, uint64_t vmaddr,
136-
uint64_t vmsize, absl::string_view file_range) {
135+
void AddRange(const char *analyzer, std::string_view name, uint64_t vmaddr,
136+
uint64_t vmsize, std::string_view file_range) {
137137
AddRange(analyzer, name, vmaddr, vmsize,
138138
file_range.data() - file_->data().data(), file_range.size());
139139
}
140140

141-
void AddFileRange(const char* analyzer, absl::string_view name,
141+
void AddFileRange(const char* analyzer, std::string_view name,
142142
uint64_t fileoff, uint64_t filesize);
143143

144144
// Like AddFileRange(), but the label is whatever label was previously
145145
// assigned to VM address |label_from_vmaddr|. If no existing label is
146146
// assigned to |label_from_vmaddr|, this function does nothing.
147147
void AddFileRangeForVMAddr(const char* analyzer, uint64_t label_from_vmaddr,
148-
absl::string_view file_range);
148+
std::string_view file_range);
149149
void AddVMRangeForVMAddr(const char* analyzer, uint64_t label_from_vmaddr,
150150
uint64_t addr, uint64_t size);
151151

152152
// Applies this label from |from_file_range| to |file_range|, but only if the
153153
// entire |from_file_range| has a single label. If not, this does nothing.
154154
void AddFileRangeForFileRange(const char* analyzer,
155-
absl::string_view from_file_range,
156-
absl::string_view file_range);
155+
std::string_view from_file_range,
156+
std::string_view file_range);
157157

158-
void AddFileRange(const char* analyzer, absl::string_view name,
159-
absl::string_view file_range) {
158+
void AddFileRange(const char* analyzer, std::string_view name,
159+
std::string_view file_range) {
160160
// When separate debug files are being used, the DWARF analyzer will try to
161161
// add sections of the debug file. We want to prevent this because we only
162162
// want to profile the main file (not the debug file), so we filter these
@@ -202,21 +202,21 @@ class RangeSink {
202202
// Translates the given pointer (which must be within the range of
203203
// input_file().data()) to a VM address.
204204
uint64_t TranslateFileToVM(const char* ptr);
205-
absl::string_view TranslateVMToFile(uint64_t address);
205+
std::string_view TranslateVMToFile(uint64_t address);
206206
const DualMap* Translator() { return translator_; }
207207

208208

209209
// Decompresses zlib-formatted data and returns the decompressed data.
210210
// Since the decompressed data is not actually part of the file, any
211211
// Add*Range() calls to this region will be no-ops.
212-
absl::string_view ZlibDecompress(absl::string_view contents,
212+
std::string_view ZlibDecompress(std::string_view contents,
213213
uint64_t uncompressed_size);
214214

215215
static constexpr uint64_t kUnknownSize = RangeMap::kUnknownSize;
216216

217217
private:
218218
bool FileContainsPointer(const void* ptr) const {
219-
absl::string_view file_data = file_->data();
219+
std::string_view file_data = file_->data();
220220
return ptr >= file_data.data() && ptr < file_data.data() + file_data.size();
221221
}
222222

@@ -246,15 +246,15 @@ class NameMunger {
246246
// Adds a regex that will be applied to all names. All regexes will be
247247
// applied in sequence.
248248
void AddRegex(const std::string& regex, const std::string& replacement);
249-
std::string Munge(absl::string_view name) const;
249+
std::string Munge(std::string_view name) const;
250250

251251
bool IsEmpty() const { return regexes_.empty(); }
252252

253253
private:
254254
std::vector<std::pair<std::unique_ptr<ReImpl>, std::string>> regexes_;
255255
};
256256

257-
typedef std::map<absl::string_view, std::pair<uint64_t, uint64_t>> SymbolTable;
257+
typedef std::map<std::string_view, std::pair<uint64_t, uint64_t>> SymbolTable;
258258

259259
// Represents an object/executable file in a format like ELF, Mach-O, PE, etc.
260260
// To support a new file type, implement this interface.
@@ -271,7 +271,7 @@ class ObjectFile {
271271
// given here, otherwise it is |this|.
272272
virtual void ProcessFile(const std::vector<RangeSink*>& sinks) const = 0;
273273

274-
virtual bool GetDisassemblyInfo(absl::string_view symbol,
274+
virtual bool GetDisassemblyInfo(std::string_view symbol,
275275
DataSource symbol_source,
276276
DisassemblyInfo* info) const = 0;
277277

@@ -307,12 +307,12 @@ inline void ReadDWARFCompileUnits(const dwarf::File& file, const DualMap& map,
307307
}
308308
void ReadDWARFInlines(const dwarf::File& file, RangeSink* sink,
309309
bool include_line);
310-
void ReadEhFrame(absl::string_view contents, RangeSink* sink);
311-
void ReadEhFrameHdr(absl::string_view contents, RangeSink* sink);
310+
void ReadEhFrame(std::string_view contents, RangeSink* sink);
311+
void ReadEhFrameHdr(std::string_view contents, RangeSink* sink);
312312

313313
// Demangle C++ symbols according to the Itanium ABI. The |source| argument
314314
// controls what demangling mode we are using.
315-
std::string ItaniumDemangle(absl::string_view symbol, DataSource source);
315+
std::string ItaniumDemangle(std::string_view symbol, DataSource source);
316316

317317

318318
// DualMap /////////////////////////////////////////////////////////////////////
@@ -325,7 +325,7 @@ struct DualMap {
325325
};
326326

327327
struct DisassemblyInfo {
328-
absl::string_view text;
328+
std::string_view text;
329329
DualMap symbol_map;
330330
cs_arch arch;
331331
cs_mode mode;
@@ -398,17 +398,17 @@ struct RollupOutput {
398398
RollupOutput(const RollupOutput&) = delete;
399399
RollupOutput& operator=(const RollupOutput&) = delete;
400400

401-
void AddDataSourceName(absl::string_view name) {
401+
void AddDataSourceName(std::string_view name) {
402402
source_names_.emplace_back(std::string(name));
403403
}
404404

405405
const std::vector<std::string>& source_names() const { return source_names_; }
406406
void Print(const OutputOptions& options, std::ostream* out);
407-
void SetDisassembly(absl::string_view disassembly) {
407+
void SetDisassembly(std::string_view disassembly) {
408408
disassembly_ = std::string(disassembly);
409409
}
410410

411-
absl::string_view GetDisassembly() { return disassembly_; }
411+
std::string_view GetDisassembly() { return disassembly_; }
412412

413413
// For debugging.
414414
const RollupRow& toplevel_row() const { return toplevel_row_; }

src/disassemble.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,18 +13,18 @@
1313
// limitations under the License.
1414

1515
#include <string>
16+
#include <string_view>
1617

1718
#include "absl/strings/ascii.h"
1819
#include "absl/strings/escaping.h"
1920
#include "absl/strings/str_cat.h"
20-
#include "absl/strings/string_view.h"
2121
#include "absl/strings/substitute.h"
2222
#include "bloaty.h"
2323
#include "capstone/capstone.h"
2424
#include "re.h"
2525
#include "util.h"
2626

27-
using absl::string_view;
27+
using std::string_view;
2828

2929
namespace bloaty {
3030

src/dwarf.cc

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,13 @@
2121
#include <limits>
2222
#include <memory>
2323
#include <stack>
24+
#include <string_view>
2425
#include <unordered_map>
2526
#include <unordered_set>
2627
#include <vector>
2728

2829
#include "absl/base/attributes.h"
2930
#include "absl/base/macros.h"
30-
#include "absl/strings/string_view.h"
3131
#include "absl/strings/substitute.h"
3232
#include "absl/types/optional.h"
3333
#include "bloaty.h"
@@ -39,7 +39,7 @@
3939
#include "dwarf/line_info.h"
4040

4141
using namespace dwarf2reader;
42-
using absl::string_view;
42+
using std::string_view;
4343

4444
namespace bloaty {
4545

@@ -446,7 +446,7 @@ void AddDIE(const dwarf::CU& cu, const GeneralDIE& die,
446446
if (die.location_uint64) {
447447
uint64_t location = *die.location_uint64;;
448448
if (location < cu.dwarf().debug_loc.size()) {
449-
absl::string_view loc_range = cu.dwarf().debug_loc.substr(location);
449+
std::string_view loc_range = cu.dwarf().debug_loc.substr(location);
450450
loc_range = GetLocationListRange(cu.unit_sizes(), loc_range);
451451
sink->AddFileRange("dwarf_locrange", cu.unit_name(), loc_range);
452452
} else if (verbose_level > 0) {
@@ -526,7 +526,7 @@ void AddDIE(const dwarf::CU& cu, const GeneralDIE& die,
526526

527527
if (ranges_offset != UINT64_MAX) {
528528
if (ranges_offset < cu.dwarf().debug_ranges.size()) {
529-
absl::string_view data = cu.dwarf().debug_ranges.substr(ranges_offset);
529+
std::string_view data = cu.dwarf().debug_ranges.substr(ranges_offset);
530530
const char* start = data.data();
531531
ReadRangeList(cu, low_pc, cu.unit_name(), sink, &data);
532532
string_view all(start, data.data() - start);

src/dwarf/attr.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
#include "dwarf_constants.h"
2020
#include "util.h"
2121

22-
using string_view = absl::string_view;
22+
using string_view = std::string_view;
2323
using namespace dwarf2reader;
2424

2525
namespace bloaty {

0 commit comments

Comments
 (0)