Skip to content

Pre-fix some build failures that we'll see with newer llvm #41550

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Mar 2, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions include/swift/ABI/TypeIdentity.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#define SWIFT_ABI_TYPEIDENTITY_H

#include "swift/Basic/LLVM.h"
#include <llvm/ADT/Optional.h>
#include <llvm/ADT/StringRef.h>

namespace swift {
Expand Down
3 changes: 1 addition & 2 deletions include/swift/Basic/DiverseStack.h
Original file line number Diff line number Diff line change
Expand Up @@ -395,8 +395,7 @@ class DiverseValueBuffer {
public:
DiverseValueBuffer(const T &value) {
size_t size = value.allocated_size();
data.reserve(size);
data.set_size(size);
data.resize_for_overwrite(size);
memcpy(data.data(), reinterpret_cast<const void *>(&value), size);
}

Expand Down
1 change: 1 addition & 0 deletions include/swift/Basic/Fingerprint.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

#include "swift/Basic/StableHasher.h"
#include "llvm/ADT/Hashing.h"
#include "llvm/ADT/Optional.h"
#include "llvm/ADT/SmallString.h"
#include "llvm/ADT/StringRef.h"

Expand Down
1 change: 1 addition & 0 deletions include/swift/Basic/SourceLoc.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
#include "swift/Basic/Debug.h"
#include "swift/Basic/LLVM.h"
#include "llvm/ADT/DenseMapInfo.h"
#include "llvm/ADT/Hashing.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/Support/SMLoc.h"
#include <functional>
Expand Down
1 change: 1 addition & 0 deletions include/swift/Basic/Statistic.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#ifndef SWIFT_BASIC_STATISTIC_H
#define SWIFT_BASIC_STATISTIC_H

#include "llvm/ADT/Optional.h"
#include "llvm/ADT/SmallString.h"
#include "llvm/ADT/Statistic.h"
#include "llvm/Support/Timer.h"
Expand Down
1 change: 1 addition & 0 deletions include/swift/Demangling/ManglingUtils.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#ifndef SWIFT_DEMANGLING_MANGLINGUTILS_H
#define SWIFT_DEMANGLING_MANGLINGUTILS_H

#include "llvm/ADT/Optional.h"
#include "llvm/ADT/StringRef.h"
#include "swift/Demangling/NamespaceMacros.h"
#include "swift/Demangling/Punycode.h"
Expand Down
1 change: 1 addition & 0 deletions include/swift/Remote/MemoryReader.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

#include "swift/Remote/RemoteAddress.h"
#include "swift/SwiftRemoteMirror/MemoryReaderInterface.h"
#include "llvm/ADT/Optional.h"

#include <cstring>
#include <functional>
Expand Down
4 changes: 2 additions & 2 deletions include/swift/SIL/SILInstruction.h
Original file line number Diff line number Diff line change
Expand Up @@ -277,12 +277,12 @@ SILInstructionResultArray::end() const {

inline SILInstructionResultArray::reverse_iterator
SILInstructionResultArray::rbegin() const {
return llvm::make_reverse_iterator(end());
return std::make_reverse_iterator(end());
}

inline SILInstructionResultArray::reverse_iterator
SILInstructionResultArray::rend() const {
return llvm::make_reverse_iterator(begin());
return std::make_reverse_iterator(begin());
}

inline SILInstructionResultArray::range
Expand Down
4 changes: 2 additions & 2 deletions include/swift/Syntax/AbsoluteRawSyntax.h
Original file line number Diff line number Diff line change
Expand Up @@ -397,11 +397,11 @@ class OptionalStorage<AbsoluteRawSyntax> {

bool hasValue() const { return !Storage.isNull(); }

AbsoluteRawSyntax &getValue() LLVM_LVALUE_FUNCTION {
AbsoluteRawSyntax &getValue() & {
assert(hasValue());
return Storage;
}
AbsoluteRawSyntax const &getValue() const LLVM_LVALUE_FUNCTION {
AbsoluteRawSyntax const &getValue() const & {
assert(hasValue());
return Storage;
}
Expand Down
4 changes: 2 additions & 2 deletions include/swift/Syntax/SyntaxData.h
Original file line number Diff line number Diff line change
Expand Up @@ -416,11 +416,11 @@ class OptionalStorage<SyntaxDataRef> {

bool hasValue() const { return !Storage.getAbsoluteRaw().isNull(); }

SyntaxDataRef &getValue() LLVM_LVALUE_FUNCTION {
SyntaxDataRef &getValue() & {
assert(hasValue());
return Storage;
}
SyntaxDataRef const &getValue() const LLVM_LVALUE_FUNCTION {
SyntaxDataRef const &getValue() const & {
assert(hasValue());
return Storage;
}
Expand Down
4 changes: 2 additions & 2 deletions lib/Basic/StringExtras.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -675,8 +675,8 @@ static Words::iterator matchTypeNameFromBackWithSpecialCases(

if (shortenedNameWord != newShortenedNameWord) {
unsigned targetSize = newShortenedNameWord.size();
auto newIter = llvm::make_reverse_iterator(WordIterator(name,
targetSize));
auto newIter = std::make_reverse_iterator(WordIterator(name,
targetSize));
#ifndef NDEBUG
while (nameWordRevIter.base().getPosition() > targetSize)
++nameWordRevIter;
Expand Down
3 changes: 1 addition & 2 deletions lib/IRGen/Explosion.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,7 @@ class Explosion {
Explosion &operator=(const Explosion &) = delete;
Explosion(Explosion &&other) : NextValue(0) {
// Do an uninitialized copy of the non-consumed elements.
Values.reserve(other.size());
Values.set_size(other.size());
Values.resize_for_overwrite(other.size());
std::uninitialized_copy(other.begin(), other.end(), Values.begin());

// Remove everything from the other explosion.
Expand Down
3 changes: 1 addition & 2 deletions lib/IRGen/GenCall.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3257,8 +3257,7 @@ void CallEmission::setFromCallee() {

// Set up the args array.
assert(Args.empty());
Args.reserve(numArgs);
Args.set_size(numArgs);
Args.resize_for_overwrite(numArgs);
LastArgWritten = numArgs;
}

Expand Down
2 changes: 1 addition & 1 deletion lib/SIL/Utils/MemoryLocations.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ void MemoryLocations::analyzeLocation(SILValue loc) {
SubLocationMap subLocationMap;
if (!analyzeLocationUsesRecursively(loc, currentLocIdx, collectedVals,
subLocationMap)) {
locations.set_size(currentLocIdx);
locations.truncate(currentLocIdx);
for (SILValue V : collectedVals) {
addr2LocIdx.erase(V);
}
Expand Down
8 changes: 4 additions & 4 deletions tools/SourceKit/tools/sourcekitd-repl/sourcekitd-repl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -91,29 +91,29 @@ using Convert = ConvertForWcharSize<sizeof(wchar_t)>;
static void convertFromUTF8(llvm::StringRef utf8,
llvm::SmallVectorImpl<wchar_t> &out) {
size_t reserve = out.size() + utf8.size();
out.reserve(reserve);
out.resize_for_overwrite(reserve);
const char *utf8_begin = utf8.begin();
wchar_t *wide_begin = out.end();
auto res = Convert::ConvertFromUTF8(&utf8_begin, utf8.end(),
&wide_begin, out.data() + reserve,
lenientConversion);
assert(res == conversionOK && "utf8-to-wide conversion failed!");
(void)res;
out.set_size(wide_begin - out.begin());
out.truncate(wide_begin - out.begin());
}

static void convertToUTF8(llvm::ArrayRef<wchar_t> wide,
llvm::SmallVectorImpl<char> &out) {
size_t reserve = out.size() + wide.size()*4;
out.reserve(reserve);
out.resize_for_overwrite(reserve);
const wchar_t *wide_begin = wide.begin();
char *utf8_begin = out.end();
auto res = Convert::ConvertToUTF8(&wide_begin, wide.end(),
&utf8_begin, out.data() + reserve,
lenientConversion);
assert(res == conversionOK && "wide-to-utf8 conversion failed!");
(void)res;
out.set_size(utf8_begin - out.begin());
out.truncate(utf8_begin - out.begin());
}
} // end anonymous namespace

Expand Down