aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Support/FileCollector.cpp
diff options
context:
space:
mode:
authorDuncan P. N. Exon Smith <dexonsmith@apple.com>2021-01-21 16:53:26 -0800
committerDuncan P. N. Exon Smith <dexonsmith@apple.com>2021-01-22 16:17:58 -0800
commitba5628f2c2a9de049b80b3e276f7e05f481c49e7 (patch)
tree08b15d5d5693966db67ab856238f80b6a5cd68b2 /llvm/lib/Support/FileCollector.cpp
parent47e95e87a3e4f738635ff965616d4e2d96bf838a (diff)
downloadllvm-ba5628f2c2a9de049b80b3e276f7e05f481c49e7.zip
llvm-ba5628f2c2a9de049b80b3e276f7e05f481c49e7.tar.gz
llvm-ba5628f2c2a9de049b80b3e276f7e05f481c49e7.tar.bz2
ADT: Use 'using' to inherit assign and append in SmallString
Rather than reimplement, use a `using` declaration to bring in `SmallVectorImpl<char>`'s assign and append implementations in `SmallString`. The `SmallString` versions were missing reference invalidation assertions from `SmallVector`. This patch also fixes a bug in `llvm::FileCollector::addFileImpl`, which was a copy/paste from `clang::ModuleDependencyCollector::copyToRoot`, both caught by the no-longer-skipped assertions. As a drive-by, this also sinks the `const SmallVectorImpl&` versions of these methods down into `SmallVectorImpl`, since I imagine they'd be useful elsewhere. Differential Revision: https://reviews.llvm.org/D95202
Diffstat (limited to 'llvm/lib/Support/FileCollector.cpp')
-rw-r--r--llvm/lib/Support/FileCollector.cpp7
1 files changed, 4 insertions, 3 deletions
diff --git a/llvm/lib/Support/FileCollector.cpp b/llvm/lib/Support/FileCollector.cpp
index d0471ac..cb53878 100644
--- a/llvm/lib/Support/FileCollector.cpp
+++ b/llvm/lib/Support/FileCollector.cpp
@@ -86,17 +86,18 @@ void FileCollector::addFileImpl(StringRef SrcPath) {
sys::path::native(AbsoluteSrc);
// Remove redundant leading "./" pieces and consecutive separators.
- AbsoluteSrc = sys::path::remove_leading_dotslash(AbsoluteSrc);
+ StringRef TrimmedAbsoluteSrc =
+ sys::path::remove_leading_dotslash(AbsoluteSrc);
// Canonicalize the source path by removing "..", "." components.
- SmallString<256> VirtualPath = AbsoluteSrc;
+ SmallString<256> VirtualPath = TrimmedAbsoluteSrc;
sys::path::remove_dots(VirtualPath, /*remove_dot_dot=*/true);
// If a ".." component is present after a symlink component, remove_dots may
// lead to the wrong real destination path. Let the source be canonicalized
// like that but make sure we always use the real path for the destination.
SmallString<256> CopyFrom;
- if (!getRealPath(AbsoluteSrc, CopyFrom))
+ if (!getRealPath(TrimmedAbsoluteSrc, CopyFrom))
CopyFrom = VirtualPath;
SmallString<256> DstPath = StringRef(Root);