Skip to content

Commit 0bf1389

Browse files
authored
Merge pull request #40907 from apple/rebranch
Update swift:main to support llvm-project:stable/20211026 changes (Rebranch merge)
2 parents 6d4f2d9 + 32b5f85 commit 0bf1389

File tree

62 files changed

+209
-282
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

62 files changed

+209
-282
lines changed

include/swift/Basic/APIntMap.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,11 @@ struct WidthPreservingAPIntDenseMapInfo {
3838
}
3939

4040
static unsigned getHashValue(const APInt &Key) {
41-
return static_cast<unsigned>(hash_value(Key));
41+
return llvm::DenseMapInfo<APInt>::getHashValue(Key);
4242
}
4343

4444
static bool isEqual(const APInt &LHS, const APInt &RHS) {
45-
return LHS.getBitWidth() == RHS.getBitWidth() && LHS == RHS;
45+
return llvm::DenseMapInfo<APInt>::isEqual(LHS, RHS);
4646
}
4747
};
4848

include/swift/Basic/ExponentialGrowthAppendingBinaryByteStream.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -42,29 +42,29 @@ class ExponentialGrowthAppendingBinaryByteStream
4242

4343
llvm::support::endianness getEndian() const override { return Endian; }
4444

45-
llvm::Error readBytes(uint32_t Offset, uint32_t Size,
45+
llvm::Error readBytes(uint64_t Offset, uint64_t Size,
4646
ArrayRef<uint8_t> &Buffer) override;
4747

48-
llvm::Error readLongestContiguousChunk(uint32_t Offset,
48+
llvm::Error readLongestContiguousChunk(uint64_t Offset,
4949
ArrayRef<uint8_t> &Buffer) override;
5050

5151
MutableArrayRef<uint8_t> data() { return Data; }
5252

53-
uint32_t getLength() override { return Data.size(); }
53+
uint64_t getLength() override { return Data.size(); }
5454

55-
llvm::Error writeBytes(uint32_t Offset, ArrayRef<uint8_t> Buffer) override;
55+
llvm::Error writeBytes(uint64_t Offset, ArrayRef<uint8_t> Buffer) override;
5656

5757
/// This is an optimized version of \c writeBytes specifically for integers.
5858
/// Integers are written in little-endian byte order.
5959
template<typename T>
60-
llvm::Error writeInteger(uint32_t Offset, T Value) {
60+
llvm::Error writeInteger(uint64_t Offset, T Value) {
6161
static_assert(std::is_integral<T>::value, "Integer required.");
6262
if (auto Error = checkOffsetForWrite(Offset, sizeof(T))) {
6363
return Error;
6464
}
6565

6666
// Resize the internal buffer if needed.
67-
uint32_t RequiredSize = Offset + sizeof(T);
67+
uint64_t RequiredSize = Offset + sizeof(T);
6868
if (RequiredSize > Data.size()) {
6969
Data.resize(RequiredSize);
7070
}

include/swift/Basic/ExternalUnion.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,9 @@
2424

2525
#include "llvm/Support/ErrorHandling.h"
2626
#include "swift/Basic/type_traits.h"
27+
#include <cassert>
28+
#include <cstdint>
2729
#include <utility>
28-
#include <assert.h>
2930

3031
namespace swift {
3132

include/swift/Demangling/TypeLookupError.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@
2020

2121
#include "swift/Basic/TaggedUnion.h"
2222
#include "swift/Runtime/Portability.h"
23-
#include <string.h>
23+
#include <cstring>
24+
#include <string>
2425

2526
namespace swift {
2627

lib/AST/Availability.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -506,6 +506,7 @@ ASTContext::getSwift5PlusAvailability(llvm::VersionTuple swiftVersion) {
506506
default: break;
507507
}
508508
}
509-
llvm::report_fatal_error("Missing call to getSwiftXYAvailability for Swift " +
510-
swiftVersion.getAsString());
509+
llvm::report_fatal_error(
510+
Twine("Missing call to getSwiftXYAvailability for Swift ") +
511+
swiftVersion.getAsString());
511512
}

lib/AST/Builtins.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2208,18 +2208,17 @@ getSwiftFunctionTypeForIntrinsic(llvm::Intrinsic::ID ID,
22082208
return false;
22092209
ArgElts.push_back(ArgTy);
22102210
}
2211-
2211+
22122212
// Translate LLVM function attributes to Swift function attributes.
22132213
IntrinsicInfo II;
22142214
II.ID = ID;
22152215
auto attrs = II.getOrCreateAttributes(Context);
2216-
if (attrs.hasAttribute(llvm::AttributeList::FunctionIndex,
2217-
llvm::Attribute::NoReturn)) {
2216+
if (attrs.hasFnAttr(llvm::Attribute::NoReturn)) {
22182217
ResultTy = Context.getNeverType();
22192218
if (!ResultTy)
22202219
return false;
22212220
}
2222-
2221+
22232222
return true;
22242223
}
22252224

lib/Basic/ExponentialGrowthAppendingBinaryByteStream.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ using namespace llvm;
1616
using namespace swift;
1717

1818
Error ExponentialGrowthAppendingBinaryByteStream::readBytes(
19-
uint32_t Offset, uint32_t Size, ArrayRef<uint8_t> &Buffer) {
19+
uint64_t Offset, uint64_t Size, ArrayRef<uint8_t> &Buffer) {
2020
if (auto Error = checkOffsetForRead(Offset, Size)) {
2121
return Error;
2222
}
@@ -26,7 +26,7 @@ Error ExponentialGrowthAppendingBinaryByteStream::readBytes(
2626
}
2727

2828
Error ExponentialGrowthAppendingBinaryByteStream::readLongestContiguousChunk(
29-
uint32_t Offset, ArrayRef<uint8_t> &Buffer) {
29+
uint64_t Offset, ArrayRef<uint8_t> &Buffer) {
3030
if (auto Error = checkOffsetForRead(Offset, 0)) {
3131
return Error;
3232
}
@@ -40,7 +40,7 @@ void ExponentialGrowthAppendingBinaryByteStream::reserve(size_t Size) {
4040
}
4141

4242
Error ExponentialGrowthAppendingBinaryByteStream::writeBytes(
43-
uint32_t Offset, ArrayRef<uint8_t> Buffer) {
43+
uint64_t Offset, ArrayRef<uint8_t> Buffer) {
4444
if (Buffer.empty())
4545
return Error::success();
4646

@@ -49,7 +49,7 @@ Error ExponentialGrowthAppendingBinaryByteStream::writeBytes(
4949
}
5050

5151
// Resize the internal buffer if needed.
52-
uint32_t RequiredSize = Offset + Buffer.size();
52+
uint64_t RequiredSize = Offset + Buffer.size();
5353
if (RequiredSize > Data.size()) {
5454
Data.resize(RequiredSize);
5555
}

lib/ClangImporter/CFTypeInfo.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,10 @@
1414
//
1515
//===----------------------------------------------------------------------===//
1616
#ifndef SWIFT_IMPORTER_CFTYPEINFO_H
17-
#define SWIFT_IMPORTER_CFTYPEINFO_H
17+
#define SWIFT_IMPORTER_CFTYPEINFO_H
1818

1919
#include "llvm/ADT/PointerUnion.h"
20+
#include "llvm/ADT/StringRef.h"
2021

2122
namespace clang {
2223
class RecordDecl;

lib/ClangImporter/ClangAdapter.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -396,6 +396,7 @@ OmissionTypeName importer::getClangTypeNameForOmission(clang::ASTContext &ctx,
396396
case clang::BuiltinType::Float16:
397397
case clang::BuiltinType::Float128:
398398
case clang::BuiltinType::NullPtr:
399+
case clang::BuiltinType::Ibm128:
399400
return OmissionTypeName();
400401

401402
// Objective-C types that aren't mapped directly; rather, pointers to

lib/ClangImporter/ClangImporter.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1130,6 +1130,10 @@ ClangImporter::create(ASTContext &ctx,
11301130

11311131
// Create a compiler instance.
11321132
{
1133+
// The Clang modules produced by ClangImporter are always embedded in an
1134+
// ObjectFilePCHContainer and contain -gmodules debug info.
1135+
importer->Impl.Invocation->getCodeGenOpts().DebugTypeExtRefs = true;
1136+
11331137
auto PCHContainerOperations =
11341138
std::make_shared<clang::PCHContainerOperations>();
11351139
PCHContainerOperations->registerWriter(

lib/ClangImporter/ImportType.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -289,6 +289,7 @@ namespace {
289289
case clang::BuiltinType::Float128:
290290
case clang::BuiltinType::NullPtr:
291291
case clang::BuiltinType::Char8:
292+
case clang::BuiltinType::Ibm128:
292293
return Type();
293294

294295
// Objective-C types that aren't mapped directly; rather, pointers to

lib/ClangImporter/ImporterImpl.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1738,7 +1738,7 @@ class SwiftNameLookupExtension : public clang::ModuleFileExtension {
17381738
buffersForDiagnostics(buffersForDiagnostics), availability(avail) {}
17391739

17401740
clang::ModuleFileExtensionMetadata getExtensionMetadata() const override;
1741-
llvm::hash_code hashExtension(llvm::hash_code code) const override;
1741+
void hashExtension(ExtensionHashBuilder &HBuilder) const override;
17421742

17431743
std::unique_ptr<clang::ModuleFileExtensionWriter>
17441744
createExtensionWriter(clang::ASTWriter &writer) override;

lib/ClangImporter/SwiftLookupTable.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1849,12 +1849,12 @@ SwiftNameLookupExtension::getExtensionMetadata() const {
18491849
return metadata;
18501850
}
18511851

1852-
llvm::hash_code
1853-
SwiftNameLookupExtension::hashExtension(llvm::hash_code code) const {
1854-
return llvm::hash_combine(code, StringRef("swift.lookup"),
1855-
SWIFT_LOOKUP_TABLE_VERSION_MAJOR,
1856-
SWIFT_LOOKUP_TABLE_VERSION_MINOR,
1857-
version::getSwiftFullVersion());
1852+
void
1853+
SwiftNameLookupExtension::hashExtension(ExtensionHashBuilder &HBuilder) const {
1854+
HBuilder.add(StringRef("swift.lookup"));
1855+
HBuilder.add(SWIFT_LOOKUP_TABLE_VERSION_MAJOR);
1856+
HBuilder.add(SWIFT_LOOKUP_TABLE_VERSION_MINOR);
1857+
HBuilder.add(version::getSwiftFullVersion());
18581858
}
18591859

18601860
void importer::addEntryToLookupTable(SwiftLookupTable &table,

lib/Demangling/Demangler.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -91,10 +91,8 @@ static bool isRequirement(Node::Kind kind) {
9191
// Public utility functions //
9292
//////////////////////////////////
9393

94-
LLVM_ATTRIBUTE_NORETURN void swift::Demangle::failAssert(const char *file,
95-
unsigned line,
96-
NodePointer node,
97-
const char *expr) {
94+
void swift::Demangle::failAssert(const char *file, unsigned line,
95+
NodePointer node, const char *expr) {
9896
fprintf(stderr, "%s:%u: assertion failed for Node %p: %s", file, line, node,
9997
expr);
10098
abort();

lib/Demangling/DemanglerAssert.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,8 @@ namespace swift {
4646
namespace Demangle {
4747
SWIFT_BEGIN_INLINE_NAMESPACE
4848

49-
LLVM_ATTRIBUTE_NORETURN void failAssert(const char *file, unsigned line,
50-
NodePointer node, const char *expr);
49+
[[noreturn]] void failAssert(const char *file, unsigned line, NodePointer node,
50+
const char *expr);
5151

5252
SWIFT_END_INLINE_NAMESPACE
5353
} // end namespace Demangle

lib/DependencyScan/ScanDependencies.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -808,8 +808,8 @@ generateFullDependencyGraph(CompilerInstance &instance,
808808
module.first,
809809
{module.second, currentImportPathSet});
810810
if (!moduleDepsQuery) {
811-
std::string err = "Module Dependency Cache missing module" + module.first;
812-
llvm::report_fatal_error(err);
811+
llvm::report_fatal_error(Twine("Module Dependency Cache missing module") +
812+
module.first);
813813
}
814814

815815
auto moduleDeps = *moduleDepsQuery;

lib/Driver/Driver.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1157,7 +1157,8 @@ parseArgsUntil(const llvm::opt::OptTable& Opts,
11571157
}
11581158

11591159
unsigned Prev = Index;
1160-
Arg *A = Opts.ParseOneArg(*Args, Index, FlagsToInclude, FlagsToExclude);
1160+
Arg *A = Opts.ParseOneArg(*Args, Index, FlagsToInclude, FlagsToExclude)
1161+
.release();
11611162
assert(Index > Prev && "Parser failed to consume argument.");
11621163

11631164
// Check for missing argument error.

lib/Driver/UnixToolChains.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -310,11 +310,11 @@ toolchains::GenericUnix::constructInvocation(const DynamicLinkJobAction &job,
310310
}
311311

312312
if (!linkFilePath.empty()) {
313-
auto linkFile = linkFilePath.str();
314-
if (llvm::sys::fs::is_regular_file(linkFile)) {
315-
Arguments.push_back(context.Args.MakeArgString(Twine("@") + linkFile));
313+
if (llvm::sys::fs::is_regular_file(linkFilePath)) {
314+
Arguments.push_back(
315+
context.Args.MakeArgString(Twine("@") + linkFilePath));
316316
} else {
317-
llvm::report_fatal_error(linkFile + " not found");
317+
llvm::report_fatal_error(Twine(linkFilePath) + " not found");
318318
}
319319
}
320320

lib/DriverTool/swift_symbolgraph_extract_main.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
#include "swift/Option/Options.h"
2424
#include "swift/SymbolGraphGen/SymbolGraphGen.h"
2525
#include "llvm/ADT/ArrayRef.h"
26+
#include "llvm/ADT/SmallVector.h"
2627
#include "llvm/Support/raw_ostream.h"
2728

2829
using namespace swift;

lib/FrontendTool/FrontendTool.cpp

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1880,15 +1880,15 @@ int swift::performFrontend(ArrayRef<const char *> Args,
18801880
//
18811881
// Unfortunately it's not really safe to do anything else, since very
18821882
// low-level operations in LLVM can trigger fatal errors.
1883-
auto diagnoseFatalError = [&PDC](const std::string &reason, bool shouldCrash){
1884-
static const std::string *recursiveFatalError = nullptr;
1883+
auto diagnoseFatalError = [&PDC](const char *reason, bool shouldCrash) {
1884+
static const char *recursiveFatalError = nullptr;
18851885
if (recursiveFatalError) {
18861886
// Report the /original/ error through LLVM's default handler, not
18871887
// whatever we encountered.
18881888
llvm::remove_fatal_error_handler();
1889-
llvm::report_fatal_error(*recursiveFatalError, shouldCrash);
1889+
llvm::report_fatal_error(recursiveFatalError, shouldCrash);
18901890
}
1891-
recursiveFatalError = &reason;
1891+
recursiveFatalError = reason;
18921892

18931893
SourceManager dummyMgr;
18941894

@@ -1904,12 +1904,13 @@ int swift::performFrontend(ArrayRef<const char *> Args,
19041904
if (shouldCrash)
19051905
abort();
19061906
};
1907-
llvm::ScopedFatalErrorHandler handler([](void *rawCallback,
1908-
const std::string &reason,
1909-
bool shouldCrash) {
1910-
auto *callback = static_cast<decltype(&diagnoseFatalError)>(rawCallback);
1911-
(*callback)(reason, shouldCrash);
1912-
}, &diagnoseFatalError);
1907+
llvm::ScopedFatalErrorHandler handler(
1908+
[](void *rawCallback, const char *reason, bool shouldCrash) {
1909+
auto *callback =
1910+
static_cast<decltype(&diagnoseFatalError)>(rawCallback);
1911+
(*callback)(reason, shouldCrash);
1912+
},
1913+
&diagnoseFatalError);
19131914

19141915
std::unique_ptr<CompilerInstance> Instance =
19151916
std::make_unique<CompilerInstance>();

0 commit comments

Comments
 (0)