Skip to content

Commit 11f2819

Browse files
authored
Merge pull request #40168 from bnbarham/rebranch-failures
[rebranch] Fix compilation failures
2 parents 73e3570 + 8e99992 commit 11f2819

Some content is hidden

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

41 files changed

+168
-231
lines changed

include/swift/Basic/APIntMap.h

+2-2
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/Demangling/TypeLookupError.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020

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

2525
namespace swift {
2626

lib/ClangImporter/ClangAdapter.cpp

+1
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/ImportType.cpp

+1
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

+1-1
Original file line numberDiff line numberDiff line change
@@ -1618,7 +1618,7 @@ class SwiftNameLookupExtension : public clang::ModuleFileExtension {
16181618
buffersForDiagnostics(buffersForDiagnostics), availability(avail) {}
16191619

16201620
clang::ModuleFileExtensionMetadata getExtensionMetadata() const override;
1621-
llvm::hash_code hashExtension(llvm::hash_code code) const override;
1621+
void hashExtension(ExtensionHashBuilder &HBuilder) const override;
16221622

16231623
std::unique_ptr<clang::ModuleFileExtensionWriter>
16241624
createExtensionWriter(clang::ASTWriter &writer) override;

lib/ClangImporter/SwiftLookupTable.cpp

+6-6
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/DependencyScan/ScanDependencies.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -775,8 +775,8 @@ generateFullDependencyGraph(CompilerInstance &instance,
775775
module.first,
776776
{module.second, currentImportPathSet});
777777
if (!moduleDepsQuery) {
778-
std::string err = "Module Dependency Cache missing module" + module.first;
779-
llvm::report_fatal_error(err);
778+
llvm::report_fatal_error(Twine("Module Dependency Cache missing module") +
779+
module.first);
780780
}
781781

782782
auto moduleDeps = *moduleDepsQuery;

lib/Driver/Driver.cpp

+3-2
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+
std::unique_ptr<Arg> A = Opts.ParseOneArg(*Args, Index, FlagsToInclude,
1161+
FlagsToExclude);
11611162
assert(Index > Prev && "Parser failed to consume argument.");
11621163

11631164
// Check for missing argument error.
@@ -1169,7 +1170,7 @@ parseArgsUntil(const llvm::opt::OptTable& Opts,
11691170
break;
11701171
}
11711172

1172-
Args->append(A);
1173+
Args->append(A.release());
11731174

11741175
if (CheckUntil && A->getOption().matches(UntilOption)) {
11751176
if (Index < End)

lib/Driver/UnixToolChains.cpp

+4-4
Original file line numberDiff line numberDiff line change
@@ -307,11 +307,11 @@ toolchains::GenericUnix::constructInvocation(const DynamicLinkJobAction &job,
307307
}
308308

309309
if (!linkFilePath.empty()) {
310-
auto linkFile = linkFilePath.str();
311-
if (llvm::sys::fs::is_regular_file(linkFile)) {
312-
Arguments.push_back(context.Args.MakeArgString(Twine("@") + linkFile));
310+
if (llvm::sys::fs::is_regular_file(linkFilePath)) {
311+
Arguments.push_back(
312+
context.Args.MakeArgString(Twine("@") + linkFilePath));
313313
} else {
314-
llvm::report_fatal_error(linkFile + " not found");
314+
llvm::report_fatal_error(Twine(linkFilePath) + " not found");
315315
}
316316
}
317317

lib/FrontendTool/FrontendTool.cpp

+11-10
Original file line numberDiff line numberDiff line change
@@ -1844,15 +1844,15 @@ int swift::performFrontend(ArrayRef<const char *> Args,
18441844
//
18451845
// Unfortunately it's not really safe to do anything else, since very
18461846
// low-level operations in LLVM can trigger fatal errors.
1847-
auto diagnoseFatalError = [&PDC](const std::string &reason, bool shouldCrash){
1848-
static const std::string *recursiveFatalError = nullptr;
1847+
auto diagnoseFatalError = [&PDC](const char *reason, bool shouldCrash) {
1848+
static const char *recursiveFatalError = nullptr;
18491849
if (recursiveFatalError) {
18501850
// Report the /original/ error through LLVM's default handler, not
18511851
// whatever we encountered.
18521852
llvm::remove_fatal_error_handler();
1853-
llvm::report_fatal_error(*recursiveFatalError, shouldCrash);
1853+
llvm::report_fatal_error(recursiveFatalError, shouldCrash);
18541854
}
1855-
recursiveFatalError = &reason;
1855+
recursiveFatalError = reason;
18561856

18571857
SourceManager dummyMgr;
18581858

@@ -1868,12 +1868,13 @@ int swift::performFrontend(ArrayRef<const char *> Args,
18681868
if (shouldCrash)
18691869
abort();
18701870
};
1871-
llvm::ScopedFatalErrorHandler handler([](void *rawCallback,
1872-
const std::string &reason,
1873-
bool shouldCrash) {
1874-
auto *callback = static_cast<decltype(&diagnoseFatalError)>(rawCallback);
1875-
(*callback)(reason, shouldCrash);
1876-
}, &diagnoseFatalError);
1871+
llvm::ScopedFatalErrorHandler handler(
1872+
[](void *rawCallback, const char *reason, bool shouldCrash) {
1873+
auto *callback =
1874+
static_cast<decltype(&diagnoseFatalError)>(rawCallback);
1875+
(*callback)(reason, shouldCrash);
1876+
},
1877+
&diagnoseFatalError);
18771878

18781879
std::unique_ptr<CompilerInstance> Instance =
18791880
std::make_unique<CompilerInstance>();

lib/FrontendTool/LoadedModuleTrace.cpp

+17-25
Original file line numberDiff line numberDiff line change
@@ -154,8 +154,8 @@ class ABIDependencyEvaluator {
154154
llvm::DenseSet<ModuleDecl *> visited;
155155

156156
/// Helper function to handle invariant violations as crashes in debug mode.
157-
void crashOnInvariantViolation(
158-
llvm::function_ref<void(llvm::raw_string_ostream &)> f) const;
157+
void
158+
crashOnInvariantViolation(llvm::function_ref<void(raw_ostream &)> f) const;
159159

160160
/// Computes the ABI exports for \p importedModule and adds them to
161161
/// \p module's ABI exports.
@@ -223,13 +223,13 @@ class ABIDependencyEvaluator {
223223
// See [NOTE: Bailing-vs-crashing-in-trace-emission].
224224
// TODO: Use PrettyStackTrace instead?
225225
void ABIDependencyEvaluator::crashOnInvariantViolation(
226-
llvm::function_ref<void(llvm::raw_string_ostream &)> f) const {
226+
llvm::function_ref<void(raw_ostream &)> f) const {
227227
#ifndef NDEBUG
228-
std::string msg;
229-
llvm::raw_string_ostream os(msg);
228+
SmallVector<char, 0> msg;
229+
llvm::raw_svector_ostream os(msg);
230230
os << "error: invariant violation: ";
231231
f(os);
232-
llvm::report_fatal_error(os.str());
232+
llvm::report_fatal_error(msg);
233233
#endif
234234
}
235235

@@ -256,7 +256,7 @@ void ABIDependencyEvaluator::reexposeImportedABI(ModuleDecl *module,
256256
ModuleDecl *importedModule,
257257
bool includeImportedModule) {
258258
if (module == importedModule) {
259-
crashOnInvariantViolation([&](llvm::raw_string_ostream &os) {
259+
crashOnInvariantViolation([&](raw_ostream &os) {
260260
os << "module ";
261261
printModule(module, os);
262262
os << " imports itself!\n";
@@ -266,7 +266,7 @@ void ABIDependencyEvaluator::reexposeImportedABI(ModuleDecl *module,
266266

267267
auto addToABIExportMap = [this](ModuleDecl *module, ModuleDecl *reexport) {
268268
if (module == reexport) {
269-
crashOnInvariantViolation([&](llvm::raw_string_ostream &os) {
269+
crashOnInvariantViolation([&](raw_ostream &os) {
270270
os << "expected module ";
271271
printModule(reexport, os);
272272
os << " to not re-export itself\n";
@@ -409,7 +409,7 @@ void ABIDependencyEvaluator::computeABIDependenciesForModule(
409409
if (moduleIter != searchStack.end()) {
410410
if (isFakeCycleThroughOverlay(moduleIter))
411411
return;
412-
crashOnInvariantViolation([&](llvm::raw_string_ostream &os) {
412+
crashOnInvariantViolation([&](raw_ostream &os) {
413413
os << "unexpected cycle in import graph!\n";
414414
for (auto m : searchStack) {
415415
printModule(m, os);
@@ -557,21 +557,6 @@ static void computeSwiftModuleTraceInfo(
557557
const llvm::DenseMap<StringRef, ModuleDecl *> &pathToModuleDecl,
558558
const DependencyTracker &depTracker, StringRef prebuiltCachePath,
559559
std::vector<SwiftModuleTraceInfo> &traceInfo) {
560-
561-
SmallString<256> buffer;
562-
563-
std::string errMsg;
564-
llvm::raw_string_ostream err(errMsg);
565-
566-
// FIXME: Use PrettyStackTrace instead.
567-
auto errorUnexpectedPath =
568-
[&pathToModuleDecl](llvm::raw_string_ostream &errStream) {
569-
errStream << "The module <-> path mapping we have is:\n";
570-
for (auto &m : pathToModuleDecl)
571-
errStream << m.second->getName() << " <-> " << m.first << '\n';
572-
llvm::report_fatal_error(errStream.str());
573-
};
574-
575560
using namespace llvm::sys;
576561

577562
auto computeAdjacentInterfacePath = [](SmallVectorImpl<char> &modPath) {
@@ -580,6 +565,7 @@ static void computeSwiftModuleTraceInfo(
580565
path::replace_extension(modPath, swiftInterfaceExt);
581566
};
582567

568+
SmallString<256> buffer;
583569
auto deps = depTracker.getDependencies();
584570
SmallVector<std::string, 16> dependencies{deps.begin(), deps.end()};
585571
auto incrDeps = depTracker.getIncrementalDependencyPaths();
@@ -643,8 +629,14 @@ static void computeSwiftModuleTraceInfo(
643629
// built a swiftmodule from that interface, so we should have that
644630
// filename available.
645631
if (isSwiftinterface) {
632+
// FIXME: Use PrettyStackTrace instead.
633+
SmallVector<char, 0> errMsg;
634+
llvm::raw_svector_ostream err(errMsg);
646635
err << "Unexpected path for swiftinterface file:\n" << depPath << "\n";
647-
errorUnexpectedPath(err);
636+
err << "The module <-> path mapping we have is:\n";
637+
for (auto &m : pathToModuleDecl)
638+
err << m.second->getName() << " <-> " << m.first << '\n';
639+
llvm::report_fatal_error(errMsg);
648640
}
649641

650642
// Skip cached modules in the prebuilt cache. We will add the corresponding

lib/IDE/SyntaxModel.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -1599,10 +1599,10 @@ class DocFieldParser {
15991599
if (!advanceIf('-') || !advanceIf(' '))
16001600
return None;
16011601

1602-
if (ptr == end || !clang::isIdentifierBody(*ptr))
1602+
if (ptr == end || !clang::isAsciiIdentifierContinue(*ptr))
16031603
return None;
16041604
const char *identStart = ptr++;
1605-
while (advanceIf([](char c) { return clang::isIdentifierBody(c); }))
1605+
while (advanceIf([](char c) { return clang::isAsciiIdentifierContinue(c); }))
16061606
;
16071607
StringRef ident(identStart, ptr - identStart);
16081608

lib/IRGen/CallEmission.h

+3-1
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,9 @@ class CallEmission {
9797
WitnessMetadata *witnessMetadata);
9898
virtual Address getCalleeErrorSlot(SILType errorType, bool isCalleeAsync) = 0;
9999

100-
void addAttribute(unsigned Index, llvm::Attribute::AttrKind Attr);
100+
void addFnAttribute(llvm::Attribute::AttrKind Attr);
101+
102+
void addParamAttribute(unsigned ParamIndex, llvm::Attribute::AttrKind Attr);
101103

102104
void emitToMemory(Address addr, const LoadableTypeInfo &substResultTI,
103105
bool isOutlined);

lib/IRGen/GenArchetype.cpp

+2-4
Original file line numberDiff line numberDiff line change
@@ -518,8 +518,7 @@ MetadataResponse irgen::emitOpaqueTypeMetadataRef(IRGenFunction &IGF,
518518
{request.get(IGF), genericArgs, descriptor, indexValue});
519519
result->setDoesNotThrow();
520520
result->setCallingConv(IGF.IGM.SwiftCC);
521-
result->addAttribute(llvm::AttributeList::FunctionIndex,
522-
llvm::Attribute::ReadOnly);
521+
result->addFnAttr(llvm::Attribute::ReadOnly);
523522
});
524523
assert(result);
525524

@@ -552,8 +551,7 @@ llvm::Value *irgen::emitOpaqueTypeWitnessTableRef(IRGenFunction &IGF,
552551
{genericArgs, descriptor, indexValue});
553552
result->setDoesNotThrow();
554553
result->setCallingConv(IGF.IGM.SwiftCC);
555-
result->addAttribute(llvm::AttributeList::FunctionIndex,
556-
llvm::Attribute::ReadOnly);
554+
result->addFnAttr(llvm::Attribute::ReadOnly);
557555
});
558556
assert(result);
559557

lib/IRGen/GenBuiltin.cpp

+2-4
Original file line numberDiff line numberDiff line change
@@ -603,10 +603,8 @@ if (Builtin.ID == BuiltinValueKind::id) { \
603603
llvm::CallInst *call = IGF.Builder.CreateCall(fn,
604604
{context, errorBuffer.getAddress()});
605605
call->setCallingConv(IGF.IGM.SwiftCC);
606-
call->addAttribute(llvm::AttributeList::FunctionIndex,
607-
llvm::Attribute::NoUnwind);
608-
call->addAttribute(llvm::AttributeList::FirstArgIndex + 1,
609-
llvm::Attribute::ReadOnly);
606+
call->addFnAttr(llvm::Attribute::NoUnwind);
607+
call->addParamAttr(1, llvm::Attribute::ReadOnly);
610608

611609
auto attrs = call->getAttributes();
612610
IGF.IGM.addSwiftSelfAttributes(attrs, 0);

0 commit comments

Comments
 (0)