[Lldb-commits] [PATCH] D45977: Always normalize FileSpec paths.
Greg Clayton via Phabricator via lldb-commits
lldb-commits at lists.llvm.org
Mon Apr 23 15:09:23 PDT 2018
clayborg added inline comments.
================
Comment at: source/Utility/FileSpec.cpp:107
+ for (auto i = path.find('/'); i != llvm::StringRef::npos;
+ i = path.find('/', i + 1)) {
+ const auto nextChar = safeCharAtIndex(path, i+1);
----------------
I am fine switching to using the llvm functions for removing, this is only detecting if any normalization needs to happen. If there is an equivalent LLVM function that will only run through the string one time to detect all needs for normalization (no multiple passes looking for "..", then for "." etc like we used to have), I would be happy to use it, but there doesn't seem to be. We are trying to avoid having to create a "SmallVectorImpl< char >" for all paths if they don't need fixing here. This function is just iterating through an llvm::StringRef just to see if normalization needs to happen. If it does, then we make a SmallVectorImpl< char > and we fix the path. We can easily use llvm functions for the fixing part.
================
Comment at: source/Utility/FileSpec.cpp:115
+ case '/':
+ // "//" in the middle of a path needs to be normalized
+ if (i > 0)
----------------
aprantl wrote:
> Does this also turn "//WORKGROUP/Foo" into "/WORKGROUP/Foo/"?
No it does not,. Notice the "if (i > 0)" below. We need to keep leading "//"
https://reviews.llvm.org/D45977
More information about the lldb-commits
mailing list