Skip to content

Commit cdfd836

Browse files
authored
Merge pull request #24880 from gmittert/FixBuild
Update master-next for llvm api changes
2 parents d1ba83f + 67cfef2 commit cdfd836

File tree

13 files changed

+57
-39
lines changed

13 files changed

+57
-39
lines changed

include/swift/AST/ASTNode.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,10 @@ namespace swift {
3636
enum class DeclKind : uint8_t;
3737
enum class StmtKind;
3838

39-
struct ASTNode : public llvm::PointerUnion3<Expr*, Stmt*, Decl*> {
39+
struct ASTNode : public llvm::PointerUnion<Expr*, Stmt*, Decl*> {
4040
// Inherit the constructors from PointerUnion.
41-
using PointerUnion3::PointerUnion3;
42-
41+
using PointerUnion::PointerUnion;
42+
4343
SourceRange getSourceRange() const;
4444

4545
/// Return the location of the start of the statement.

include/swift/AST/Decl.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4773,7 +4773,7 @@ class VarDecl : public AbstractStorageDecl {
47734773
};
47744774

47754775
protected:
4776-
PointerUnion3<PatternBindingDecl *, Stmt *, VarDecl *> Parent;
4776+
PointerUnion<PatternBindingDecl *, Stmt *, VarDecl *> Parent;
47774777

47784778
VarDecl(DeclKind Kind, bool IsStatic, Specifier Sp, bool IsCaptureList,
47794779
SourceLoc NameLoc, Identifier Name, DeclContext *DC)

include/swift/AST/GenericSignatureBuilder.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -92,10 +92,10 @@ class GenericSignatureBuilder {
9292
class ResolvedType;
9393

9494
using UnresolvedRequirementRHS =
95-
llvm::PointerUnion3<Type, PotentialArchetype *, LayoutConstraint>;
95+
llvm::PointerUnion<Type, PotentialArchetype *, LayoutConstraint>;
9696

9797
using RequirementRHS =
98-
llvm::PointerUnion3<Type, PotentialArchetype *, LayoutConstraint>;
98+
llvm::PointerUnion<Type, PotentialArchetype *, LayoutConstraint>;
9999

100100
/// The location of a requirement as written somewhere in the source.
101101
typedef llvm::PointerUnion<const TypeRepr *, const RequirementRepr *>
@@ -1374,8 +1374,8 @@ class GenericSignatureBuilder::FloatingRequirementSource {
13741374
} kind;
13751375

13761376
using Storage =
1377-
llvm::PointerUnion3<const RequirementSource *, const TypeRepr *,
1378-
const RequirementRepr *>;
1377+
llvm::PointerUnion<const RequirementSource *, const TypeRepr *,
1378+
const RequirementRepr *>;
13791379

13801380
Storage storage;
13811381

include/swift/AST/TypeCheckRequests.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -301,7 +301,7 @@ struct WhereClauseOwner {
301301

302302
/// The source of the where clause, which can be a generic parameter list
303303
/// or a declaration that can have a where clause.
304-
llvm::PointerUnion3<GenericParamList *, Decl *, SpecializeAttr *> source;
304+
llvm::PointerUnion<GenericParamList *, Decl *, SpecializeAttr *> source;
305305

306306
WhereClauseOwner(Decl *decl);
307307

include/swift/Basic/LLVM.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,7 @@ namespace llvm {
4242
template<typename T> class MutableArrayRef;
4343
template<typename T> class TinyPtrVector;
4444
template<typename T> class Optional;
45-
template <typename PT1, typename PT2> class PointerUnion;
46-
template <typename PT1, typename PT2, typename PT3> class PointerUnion3;
45+
template <typename ...PTs> class PointerUnion;
4746
class SmallBitVector;
4847

4948
// Other common classes.
@@ -68,7 +67,6 @@ namespace swift {
6867
using llvm::None;
6968
using llvm::Optional;
7069
using llvm::PointerUnion;
71-
using llvm::PointerUnion3;
7270
using llvm::SmallBitVector;
7371
using llvm::SmallPtrSet;
7472
using llvm::SmallPtrSetImpl;

include/swift/Parse/Parser.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
#include "llvm/ADT/SetVector.h"
3939

4040
namespace llvm {
41-
template <typename PT1, typename PT2, typename PT3> class PointerUnion3;
41+
template <typename... PTs> class PointerUnion;
4242
}
4343

4444
namespace swift {

include/swift/SILOptimizer/Analysis/LoopRegionAnalysis.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -384,7 +384,7 @@ class LoopRegion {
384384
private:
385385
/// A pointer to one of a Loop, Basic Block, or Function represented by this
386386
/// region.
387-
llvm::PointerUnion3<FunctionTy *, LoopTy *, BlockTy *> Ptr;
387+
llvm::PointerUnion<FunctionTy *, LoopTy *, BlockTy *> Ptr;
388388

389389
/// The ID of this region.
390390
unsigned ID;

lib/ClangImporter/SwiftLookupTable.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -307,8 +307,8 @@ class SwiftLookupTable {
307307
static bool contextRequiresName(ContextKind kind);
308308

309309
/// A single entry referencing either a named declaration or a macro.
310-
typedef llvm::PointerUnion3<clang::NamedDecl *, clang::MacroInfo *,
311-
clang::ModuleMacro *>
310+
typedef llvm::PointerUnion<clang::NamedDecl *, clang::MacroInfo *,
311+
clang::ModuleMacro *>
312312
SingleEntry;
313313

314314
/// A stored version of the context of an entity, which is Clang

lib/IRGen/IRGen.cpp

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -385,11 +385,13 @@ static bool needsRecompile(StringRef OutputFilename, ArrayRef<uint8_t> HashData,
385385
StringRef SectionName;
386386
Section.getName(SectionName);
387387
if (SectionName == HashSectionName) {
388-
StringRef SectionData;
389-
Section.getContents(SectionData);
388+
llvm::Expected<llvm::StringRef> SectionData = Section.getContents();
389+
if (!SectionData) {
390+
return true;
391+
}
390392
ArrayRef<uint8_t> PrevHashData(
391-
reinterpret_cast<const uint8_t *>(SectionData.data()),
392-
SectionData.size());
393+
reinterpret_cast<const uint8_t *>(SectionData->data()),
394+
SectionData->size());
393395
LLVM_DEBUG(if (PrevHashData.size() == sizeof(MD5::MD5Result)) {
394396
if (DiagMutex) DiagMutex->lock();
395397
SmallString<32> HashStr;

tools/driver/autolink_extract_main.cpp

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -107,26 +107,38 @@ class AutolinkExtractInvocation {
107107

108108
/// Look inside the object file 'ObjectFile' and append any linker flags found in
109109
/// its ".swift1_autolink_entries" section to 'LinkerFlags'.
110-
static void
110+
/// Return 'true' if there was an error, and 'false' otherwise.
111+
static bool
111112
extractLinkerFlagsFromObjectFile(const llvm::object::ObjectFile *ObjectFile,
112-
std::vector<std::string> &LinkerFlags) {
113+
std::vector<std::string> &LinkerFlags,
114+
CompilerInstance &Instance) {
113115
// Search for the section we hold autolink entries in
114116
for (auto &Section : ObjectFile->sections()) {
115117
llvm::StringRef SectionName;
116118
Section.getName(SectionName);
117119
if (SectionName == ".swift1_autolink_entries") {
118-
llvm::StringRef SectionData;
119-
Section.getContents(SectionData);
120+
llvm::Expected<llvm::StringRef> SectionData = Section.getContents();
121+
if (!SectionData) {
122+
std::string message;
123+
{
124+
llvm::raw_string_ostream os(message);
125+
logAllUnhandledErrors(SectionData.takeError(), os, "");
126+
}
127+
Instance.getDiags().diagnose(SourceLoc(), diag::error_open_input_file,
128+
ObjectFile->getFileName() , message);
129+
return true;
130+
}
120131

121132
// entries are null-terminated, so extract them and push them into
122133
// the set.
123134
llvm::SmallVector<llvm::StringRef, 4> SplitFlags;
124-
SectionData.split(SplitFlags, llvm::StringRef("\0", 1), -1,
125-
/*KeepEmpty=*/false);
135+
SectionData->split(SplitFlags, llvm::StringRef("\0", 1), -1,
136+
/*KeepEmpty=*/false);
126137
for (const auto &Flag : SplitFlags)
127138
LinkerFlags.push_back(Flag);
128139
}
129140
}
141+
return false;
130142
}
131143

132144
/// Look inside the binary 'Bin' and append any linker flags found in its
@@ -138,12 +150,10 @@ static bool extractLinkerFlags(const llvm::object::Binary *Bin,
138150
StringRef BinaryFileName,
139151
std::vector<std::string> &LinkerFlags) {
140152
if (auto *ObjectFile = llvm::dyn_cast<llvm::object::ELFObjectFileBase>(Bin)) {
141-
extractLinkerFlagsFromObjectFile(ObjectFile, LinkerFlags);
142-
return false;
153+
return extractLinkerFlagsFromObjectFile(ObjectFile, LinkerFlags, Instance);
143154
} else if (auto *ObjectFile =
144155
llvm::dyn_cast<llvm::object::COFFObjectFile>(Bin)) {
145-
extractLinkerFlagsFromObjectFile(ObjectFile, LinkerFlags);
146-
return false;
156+
return extractLinkerFlagsFromObjectFile(ObjectFile, LinkerFlags, Instance);
147157
} else if (auto *Archive = llvm::dyn_cast<llvm::object::Archive>(Bin)) {
148158
llvm::Error Error = llvm::Error::success();
149159
for (const auto &Child : Archive->children(Error)) {

tools/lldb-moduleimport-test/lldb-moduleimport-test.cpp

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -169,10 +169,15 @@ collectASTModules(llvm::cl::list<std::string> &InputNames,
169169
(ELF && Name == swift::ELFASTSectionName) ||
170170
(COFF && Name == swift::COFFASTSectionName)) {
171171
uint64_t Size = Section.getSize();
172-
StringRef ContentsReference;
173-
Section.getContents(ContentsReference);
172+
173+
llvm::Expected<llvm::StringRef> ContentsReference = Section.getContents();
174+
if (!ContentsReference) {
175+
llvm::outs() << "error: " << name << " "
176+
<< errorToErrorCode(OF.takeError()).message() << "\n";
177+
return false;
178+
}
174179
char *Module = Alloc.Allocate<char>(Size);
175-
std::memcpy(Module, (void *)ContentsReference.begin(), Size);
180+
std::memcpy(Module, (void *)ContentsReference->begin(), Size);
176181
Modules.push_back({Module, Size});
177182
}
178183
}

tools/swift-reflection-dump/swift-reflection-dump.cpp

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
#include "llvm/Object/ELFObjectFile.h"
2727
#include "llvm/Object/MachOUniversal.h"
2828
#include "llvm/Support/CommandLine.h"
29+
#include "llvm/Support/Error.h"
2930

3031
#if defined(_WIN32)
3132
#include <io.h>
@@ -137,11 +138,11 @@ class Image {
137138
for (SectionRef S : O->sections()) {
138139
if (!needToRelocate(S))
139140
continue;
140-
StringRef Content;
141-
if (auto EC = S.getContents(Content))
142-
reportError(EC);
143-
std::memcpy(&Memory[getSectionAddress(S)], Content.data(),
144-
Content.size());
141+
llvm::Expected<llvm::StringRef> Content = S.getContents();
142+
if (!Content)
143+
reportError(errorToErrorCode(Content.takeError()));
144+
std::memcpy(&Memory[getSectionAddress(S)], Content->data(),
145+
Content->size());
145146
}
146147
}
147148

unittests/Parse/LexerTests.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -825,7 +825,9 @@ TEST_F(LexerTest, DiagnoseEmbeddedNulOffset) {
825825
// This test requires mmap because llvm::sys::Memory doesn't support protecting
826826
// pages to have no permissions.
827827
TEST_F(LexerTest, EncodedStringSegmentPastTheEnd) {
828-
size_t PageSize = llvm::sys::Process::getPageSize();
828+
Expected<size_t> ExptPageSize = llvm::sys::Process::getPageSize();
829+
ASSERT_TRUE(bool(ExptPageSize));
830+
size_t PageSize = *ExptPageSize;
829831

830832
void *FirstPage = mmap(/*addr*/nullptr, PageSize * 2, PROT_NONE,
831833
MAP_PRIVATE | MAP_ANON, /*fd*/-1, /*offset*/0);

0 commit comments

Comments
 (0)