Details
- Reviewers
erichkeane MaskRay jhenderson - Group Reviewers
Restricted Project
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
There's a few more callsites I'd like to clean up, tomorrow:
- llvm/tools/llvm-objdump/llvm-objdump.cpp
- llvm/tools/llvm-objdump/XCOFFDump.cpp
llvm/lib/Demangle/Demangle.cpp | ||
---|---|---|
29 | Should const be removed? (i.e. is StringRef not inherently const?) |
Unfortunately we cannot do this. LLVMSupport depends on LLVMDemangle. Due to library layering LLVMDemangle cannot depend on LLVMSupport.
The layering may look weird, but that's what we have.
Using std::string_view may possibly be fine.
We're C++17 compilation now, so we should be able to use std::string_view (and I think we're supposed to?).
llvm/lib/Demangle/Demangle.cpp | ||
---|---|---|
31 | std::string is implicitly constructible from a std::string_view, so I think on line 37 we can just do: MangledName[0] instead of S[0], and just do return MangledName below, rather than constructing it every time, despite it being just destructed in every other branch. Though, I guess the 'gotcha' here is that despite everything else not modifying the S here, that we're no longer able to use strlen for the length. Perhaps this change should be more viral, in that the other demangle functions should take a string_view instead of a const char * as well. |
llvm/lib/Demangle/Demangle.cpp | ||
---|---|---|
31 |
Sigh, include/llvm/Demangle/StringView.h has a comment 9 // FIXME: Use std::string_view instead when we support C++17. and is used throughout llvm/lib/Demangle/. This is potentially a large cleanup. Let me start on that... |
llvm/lib/Demangle/Demangle.cpp | ||
---|---|---|
31 | Not having starts_with and ends_with until C++20 is going to be a PITA. |
llvm/lib/Demangle/Demangle.cpp | ||
---|---|---|
31 | Ouch, yeah, i could see that being a problem. Perhaps we need an llvm::starts_with/llvm::ends_with that implements in terms of substr? |
llvm/lib/Demangle/Demangle.cpp | ||
---|---|---|
31 | Yeah, I guess llvm/ADT/STLExtras.h might be an appropriate place to add them. So far in the conversion, another pain point has been llvm::StringView's constructor that takes two char*'s. I think to break up this conversion, I might remove that constructor and modify the callsites. |
Should const be removed? (i.e. is StringRef not inherently const?)