Index: clang/lib/Frontend/ModuleDependencyCollector.cpp =================================================================== --- clang/lib/Frontend/ModuleDependencyCollector.cpp +++ clang/lib/Frontend/ModuleDependencyCollector.cpp @@ -190,7 +190,11 @@ // 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 DroppedDotSlash = path::remove_leading_dotslash(AbsoluteSrc); + if (DroppedDotSlash.begin() != AbsoluteSrc.begin()) + AbsoluteSrc.erase(AbsoluteSrc.begin(), DroppedDotSlash.begin()); + } // Canonicalize the source path by removing "..", "." components. SmallString<256> VirtualPath = AbsoluteSrc; Index: llvm/include/llvm/ADT/SmallString.h =================================================================== --- llvm/include/llvm/ADT/SmallString.h +++ llvm/include/llvm/ADT/SmallString.h @@ -40,35 +40,15 @@ template SmallString(ItTy S, ItTy E) : SmallVector(S, E) {} - // Note that in order to add new overloads for append & assign, we have to - // duplicate the inherited versions so as not to inadvertently hide them. - /// @} /// @name String Assignment /// @{ - /// Assign from a repeated element. - void assign(size_t NumElts, char Elt) { - this->SmallVectorImpl::assign(NumElts, Elt); - } - - /// Assign from an iterator pair. - template - void assign(in_iter S, in_iter E) { - this->clear(); - SmallVectorImpl::append(S, E); - } + using SmallVector::assign; /// Assign from a StringRef. void assign(StringRef RHS) { - this->clear(); - SmallVectorImpl::append(RHS.begin(), RHS.end()); - } - - /// Assign from a SmallVector. - void assign(const SmallVectorImpl &RHS) { - this->clear(); - SmallVectorImpl::append(RHS.begin(), RHS.end()); + SmallVectorImpl::assign(RHS.begin(), RHS.end()); } /// Assign from a list of StringRefs. @@ -81,26 +61,13 @@ /// @name String Concatenation /// @{ - /// Append from an iterator pair. - template - void append(in_iter S, in_iter E) { - SmallVectorImpl::append(S, E); - } - - void append(size_t NumInputs, char Elt) { - SmallVectorImpl::append(NumInputs, Elt); - } + using SmallVector::append; /// Append from a StringRef. void append(StringRef RHS) { SmallVectorImpl::append(RHS.begin(), RHS.end()); } - /// Append from a SmallVector. - void append(const SmallVectorImpl &RHS) { - SmallVectorImpl::append(RHS.begin(), RHS.end()); - } - /// Append from a list of StringRefs. void append(std::initializer_list Refs) { size_t SizeNeeded = this->size(); Index: llvm/include/llvm/ADT/SmallVector.h =================================================================== --- llvm/include/llvm/ADT/SmallVector.h +++ llvm/include/llvm/ADT/SmallVector.h @@ -664,6 +664,8 @@ append(IL.begin(), IL.end()); } + void append(const SmallVectorImpl &RHS) { append(RHS.begin(), RHS.end()); } + void assign(size_type NumElts, ValueParamT Elt) { // Note that Elt could be an internal reference. if (NumElts > this->capacity()) { @@ -698,6 +700,8 @@ append(IL); } + void assign(const SmallVectorImpl &RHS) { assign(RHS.begin(), RHS.end()); } + iterator erase(const_iterator CI) { // Just cast away constness because this is a non-const member function. iterator I = const_cast(CI); Index: llvm/lib/Support/FileCollector.cpp =================================================================== --- llvm/lib/Support/FileCollector.cpp +++ llvm/lib/Support/FileCollector.cpp @@ -86,7 +86,11 @@ sys::path::native(AbsoluteSrc); // Remove redundant leading "./" pieces and consecutive separators. - AbsoluteSrc = sys::path::remove_leading_dotslash(AbsoluteSrc); + { + StringRef DroppedDotSlash = sys::path::remove_leading_dotslash(AbsoluteSrc); + if (DroppedDotSlash.begin() != AbsoluteSrc.begin()) + AbsoluteSrc.erase(AbsoluteSrc.begin(), DroppedDotSlash.begin()); + } // Canonicalize the source path by removing "..", "." components. SmallString<256> VirtualPath = AbsoluteSrc; Index: llvm/unittests/ADT/SmallVectorTest.cpp =================================================================== --- llvm/unittests/ADT/SmallVectorTest.cpp +++ llvm/unittests/ADT/SmallVectorTest.cpp @@ -485,6 +485,15 @@ this->assertValuesInOrder(this->theVector, 3u, 1, 7, 7); } +TYPED_TEST(SmallVectorTest, AppendSmallVector) { + SCOPED_TRACE("AppendSmallVector"); + + SmallVector otherVector = { 7, 7 }; + this->theVector.push_back(Constructable(1)); + this->theVector.append(otherVector); + this->assertValuesInOrder(this->theVector, 3u, 1, 7, 7); +} + // Assign test TYPED_TEST(SmallVectorTest, AssignTest) { SCOPED_TRACE("AssignTest"); @@ -513,6 +522,15 @@ this->assertValuesInOrder(this->theVector, 2u, 7, 7); } +TYPED_TEST(SmallVectorTest, AssignSmallVector) { + SCOPED_TRACE("AssignSmallVector"); + + SmallVector otherVector = { 7, 7 }; + this->theVector.push_back(Constructable(1)); + this->theVector.assign(otherVector); + this->assertValuesInOrder(this->theVector, 2u, 7, 7); +} + // Move-assign test TYPED_TEST(SmallVectorTest, MoveAssignTest) { SCOPED_TRACE("MoveAssignTest");