diff options
author | Duncan P. N. Exon Smith <dexonsmith@apple.com> | 2021-01-21 16:53:26 -0800 |
---|---|---|
committer | Duncan P. N. Exon Smith <dexonsmith@apple.com> | 2021-01-22 16:17:58 -0800 |
commit | ba5628f2c2a9de049b80b3e276f7e05f481c49e7 (patch) | |
tree | 08b15d5d5693966db67ab856238f80b6a5cd68b2 /clang/lib/Frontend/ModuleDependencyCollector.cpp | |
parent | 47e95e87a3e4f738635ff965616d4e2d96bf838a (diff) | |
download | llvm-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 'clang/lib/Frontend/ModuleDependencyCollector.cpp')
-rw-r--r-- | clang/lib/Frontend/ModuleDependencyCollector.cpp | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/clang/lib/Frontend/ModuleDependencyCollector.cpp b/clang/lib/Frontend/ModuleDependencyCollector.cpp index b54eb97..2b98122 100644 --- a/clang/lib/Frontend/ModuleDependencyCollector.cpp +++ b/clang/lib/Frontend/ModuleDependencyCollector.cpp @@ -190,17 +190,17 @@ std::error_code ModuleDependencyCollector::copyToRoot(StringRef Src, // Canonicalize src to a native path to avoid mixed separator styles. path::native(AbsoluteSrc); // Remove redundant leading "./" pieces and consecutive separators. - AbsoluteSrc = path::remove_leading_dotslash(AbsoluteSrc); + StringRef TrimmedAbsoluteSrc = path::remove_leading_dotslash(AbsoluteSrc); // Canonicalize the source path by removing "..", "." components. - SmallString<256> VirtualPath = AbsoluteSrc; + SmallString<256> VirtualPath = TrimmedAbsoluteSrc; 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> CacheDst = getDest(); |