Skip to content

[rebranch] Fix compilation failures #40168

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 10 commits into from
Nov 16, 2021
Merged
4 changes: 2 additions & 2 deletions include/swift/Basic/APIntMap.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,11 @@ struct WidthPreservingAPIntDenseMapInfo {
}

static unsigned getHashValue(const APInt &Key) {
return static_cast<unsigned>(hash_value(Key));
return llvm::DenseMapInfo<APInt>::getHashValue(Key);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rjmccall any objections to this change? I'm actually not sure what header is no longer including Hashing.h but this avoids including any extra entirely 🤷

}

static bool isEqual(const APInt &LHS, const APInt &RHS) {
return LHS.getBitWidth() == RHS.getBitWidth() && LHS == RHS;
return llvm::DenseMapInfo<APInt>::isEqual(LHS, RHS);
}
};

Expand Down
2 changes: 1 addition & 1 deletion include/swift/Demangling/TypeLookupError.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

#include "swift/Basic/TaggedUnion.h"
#include "swift/Runtime/Portability.h"
#include <string.h>
#include <string>

namespace swift {

Expand Down
1 change: 1 addition & 0 deletions lib/ClangImporter/ClangAdapter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -396,6 +396,7 @@ OmissionTypeName importer::getClangTypeNameForOmission(clang::ASTContext &ctx,
case clang::BuiltinType::Float16:
case clang::BuiltinType::Float128:
case clang::BuiltinType::NullPtr:
case clang::BuiltinType::Ibm128:
return OmissionTypeName();

// Objective-C types that aren't mapped directly; rather, pointers to
Expand Down
1 change: 1 addition & 0 deletions lib/ClangImporter/ImportType.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,7 @@ namespace {
case clang::BuiltinType::Float128:
case clang::BuiltinType::NullPtr:
case clang::BuiltinType::Char8:
case clang::BuiltinType::Ibm128:
return Type();

// Objective-C types that aren't mapped directly; rather, pointers to
Expand Down
2 changes: 1 addition & 1 deletion lib/ClangImporter/ImporterImpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -1618,7 +1618,7 @@ class SwiftNameLookupExtension : public clang::ModuleFileExtension {
buffersForDiagnostics(buffersForDiagnostics), availability(avail) {}

clang::ModuleFileExtensionMetadata getExtensionMetadata() const override;
llvm::hash_code hashExtension(llvm::hash_code code) const override;
void hashExtension(ExtensionHashBuilder &HBuilder) const override;

std::unique_ptr<clang::ModuleFileExtensionWriter>
createExtensionWriter(clang::ASTWriter &writer) override;
Expand Down
12 changes: 6 additions & 6 deletions lib/ClangImporter/SwiftLookupTable.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1849,12 +1849,12 @@ SwiftNameLookupExtension::getExtensionMetadata() const {
return metadata;
}

llvm::hash_code
SwiftNameLookupExtension::hashExtension(llvm::hash_code code) const {
return llvm::hash_combine(code, StringRef("swift.lookup"),
SWIFT_LOOKUP_TABLE_VERSION_MAJOR,
SWIFT_LOOKUP_TABLE_VERSION_MINOR,
version::getSwiftFullVersion());
void
SwiftNameLookupExtension::hashExtension(ExtensionHashBuilder &HBuilder) const {
HBuilder.add(StringRef("swift.lookup"));
HBuilder.add(SWIFT_LOOKUP_TABLE_VERSION_MAJOR);
HBuilder.add(SWIFT_LOOKUP_TABLE_VERSION_MINOR);
HBuilder.add(version::getSwiftFullVersion());
}

void importer::addEntryToLookupTable(SwiftLookupTable &table,
Expand Down
4 changes: 2 additions & 2 deletions lib/DependencyScan/ScanDependencies.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -775,8 +775,8 @@ generateFullDependencyGraph(CompilerInstance &instance,
module.first,
{module.second, currentImportPathSet});
if (!moduleDepsQuery) {
std::string err = "Module Dependency Cache missing module" + module.first;
llvm::report_fatal_error(err);
llvm::report_fatal_error(Twine("Module Dependency Cache missing module") +
module.first);
}

auto moduleDeps = *moduleDepsQuery;
Expand Down
5 changes: 3 additions & 2 deletions lib/Driver/Driver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1157,7 +1157,8 @@ parseArgsUntil(const llvm::opt::OptTable& Opts,
}

unsigned Prev = Index;
Arg *A = Opts.ParseOneArg(*Args, Index, FlagsToInclude, FlagsToExclude);
std::unique_ptr<Arg> A = Opts.ParseOneArg(*Args, Index, FlagsToInclude,
FlagsToExclude);
assert(Index > Prev && "Parser failed to consume argument.");

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

Args->append(A);
Args->append(A.release());

if (CheckUntil && A->getOption().matches(UntilOption)) {
if (Index < End)
Expand Down
8 changes: 4 additions & 4 deletions lib/Driver/UnixToolChains.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -307,11 +307,11 @@ toolchains::GenericUnix::constructInvocation(const DynamicLinkJobAction &job,
}

if (!linkFilePath.empty()) {
auto linkFile = linkFilePath.str();
if (llvm::sys::fs::is_regular_file(linkFile)) {
Arguments.push_back(context.Args.MakeArgString(Twine("@") + linkFile));
if (llvm::sys::fs::is_regular_file(linkFilePath)) {
Arguments.push_back(
context.Args.MakeArgString(Twine("@") + linkFilePath));
} else {
llvm::report_fatal_error(linkFile + " not found");
llvm::report_fatal_error(Twine(linkFilePath) + " not found");
}
}

Expand Down
21 changes: 11 additions & 10 deletions lib/FrontendTool/FrontendTool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1978,15 +1978,15 @@ int swift::performFrontend(ArrayRef<const char *> Args,
//
// Unfortunately it's not really safe to do anything else, since very
// low-level operations in LLVM can trigger fatal errors.
auto diagnoseFatalError = [&PDC](const std::string &reason, bool shouldCrash){
static const std::string *recursiveFatalError = nullptr;
auto diagnoseFatalError = [&PDC](const char *reason, bool shouldCrash) {
static const char *recursiveFatalError = nullptr;
if (recursiveFatalError) {
// Report the /original/ error through LLVM's default handler, not
// whatever we encountered.
llvm::remove_fatal_error_handler();
llvm::report_fatal_error(*recursiveFatalError, shouldCrash);
llvm::report_fatal_error(recursiveFatalError, shouldCrash);
}
recursiveFatalError = &reason;
recursiveFatalError = reason;

SourceManager dummyMgr;

Expand All @@ -2002,12 +2002,13 @@ int swift::performFrontend(ArrayRef<const char *> Args,
if (shouldCrash)
abort();
};
llvm::ScopedFatalErrorHandler handler([](void *rawCallback,
const std::string &reason,
bool shouldCrash) {
auto *callback = static_cast<decltype(&diagnoseFatalError)>(rawCallback);
(*callback)(reason, shouldCrash);
}, &diagnoseFatalError);
llvm::ScopedFatalErrorHandler handler(
[](void *rawCallback, const char *reason, bool shouldCrash) {
auto *callback =
static_cast<decltype(&diagnoseFatalError)>(rawCallback);
(*callback)(reason, shouldCrash);
},
&diagnoseFatalError);

std::unique_ptr<CompilerInstance> Instance =
std::make_unique<CompilerInstance>();
Expand Down
42 changes: 17 additions & 25 deletions lib/FrontendTool/LoadedModuleTrace.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -154,8 +154,8 @@ class ABIDependencyEvaluator {
llvm::DenseSet<ModuleDecl *> visited;

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

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

Expand All @@ -256,7 +256,7 @@ void ABIDependencyEvaluator::reexposeImportedABI(ModuleDecl *module,
ModuleDecl *importedModule,
bool includeImportedModule) {
if (module == importedModule) {
crashOnInvariantViolation([&](llvm::raw_string_ostream &os) {
crashOnInvariantViolation([&](raw_ostream &os) {
os << "module ";
printModule(module, os);
os << " imports itself!\n";
Expand All @@ -266,7 +266,7 @@ void ABIDependencyEvaluator::reexposeImportedABI(ModuleDecl *module,

auto addToABIExportMap = [this](ModuleDecl *module, ModuleDecl *reexport) {
if (module == reexport) {
crashOnInvariantViolation([&](llvm::raw_string_ostream &os) {
crashOnInvariantViolation([&](raw_ostream &os) {
os << "expected module ";
printModule(reexport, os);
os << " to not re-export itself\n";
Expand Down Expand Up @@ -409,7 +409,7 @@ void ABIDependencyEvaluator::computeABIDependenciesForModule(
if (moduleIter != searchStack.end()) {
if (isFakeCycleThroughOverlay(moduleIter))
return;
crashOnInvariantViolation([&](llvm::raw_string_ostream &os) {
crashOnInvariantViolation([&](raw_ostream &os) {
os << "unexpected cycle in import graph!\n";
for (auto m : searchStack) {
printModule(m, os);
Expand Down Expand Up @@ -557,21 +557,6 @@ static void computeSwiftModuleTraceInfo(
const llvm::DenseMap<StringRef, ModuleDecl *> &pathToModuleDecl,
const DependencyTracker &depTracker, StringRef prebuiltCachePath,
std::vector<SwiftModuleTraceInfo> &traceInfo) {

SmallString<256> buffer;

std::string errMsg;
llvm::raw_string_ostream err(errMsg);

// FIXME: Use PrettyStackTrace instead.
auto errorUnexpectedPath =
[&pathToModuleDecl](llvm::raw_string_ostream &errStream) {
errStream << "The module <-> path mapping we have is:\n";
for (auto &m : pathToModuleDecl)
errStream << m.second->getName() << " <-> " << m.first << '\n';
llvm::report_fatal_error(errStream.str());
};

using namespace llvm::sys;

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

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

// Skip cached modules in the prebuilt cache. We will add the corresponding
Expand Down
4 changes: 2 additions & 2 deletions lib/IDE/SyntaxModel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1599,10 +1599,10 @@ class DocFieldParser {
if (!advanceIf('-') || !advanceIf(' '))
return None;

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

Expand Down
4 changes: 3 additions & 1 deletion lib/IRGen/CallEmission.h
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,9 @@ class CallEmission {
WitnessMetadata *witnessMetadata);
virtual Address getCalleeErrorSlot(SILType errorType, bool isCalleeAsync) = 0;

void addAttribute(unsigned Index, llvm::Attribute::AttrKind Attr);
void addFnAttribute(llvm::Attribute::AttrKind Attr);

void addParamAttribute(unsigned ParamIndex, llvm::Attribute::AttrKind Attr);

void emitToMemory(Address addr, const LoadableTypeInfo &substResultTI,
bool isOutlined);
Expand Down
6 changes: 2 additions & 4 deletions lib/IRGen/GenArchetype.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -518,8 +518,7 @@ MetadataResponse irgen::emitOpaqueTypeMetadataRef(IRGenFunction &IGF,
{request.get(IGF), genericArgs, descriptor, indexValue});
result->setDoesNotThrow();
result->setCallingConv(IGF.IGM.SwiftCC);
result->addAttribute(llvm::AttributeList::FunctionIndex,
llvm::Attribute::ReadOnly);
result->addFnAttr(llvm::Attribute::ReadOnly);
});
assert(result);

Expand Down Expand Up @@ -552,8 +551,7 @@ llvm::Value *irgen::emitOpaqueTypeWitnessTableRef(IRGenFunction &IGF,
{genericArgs, descriptor, indexValue});
result->setDoesNotThrow();
result->setCallingConv(IGF.IGM.SwiftCC);
result->addAttribute(llvm::AttributeList::FunctionIndex,
llvm::Attribute::ReadOnly);
result->addFnAttr(llvm::Attribute::ReadOnly);
});
assert(result);

Expand Down
6 changes: 2 additions & 4 deletions lib/IRGen/GenBuiltin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -603,10 +603,8 @@ if (Builtin.ID == BuiltinValueKind::id) { \
llvm::CallInst *call = IGF.Builder.CreateCall(fn,
{context, errorBuffer.getAddress()});
call->setCallingConv(IGF.IGM.SwiftCC);
call->addAttribute(llvm::AttributeList::FunctionIndex,
llvm::Attribute::NoUnwind);
call->addAttribute(llvm::AttributeList::FirstArgIndex + 1,
llvm::Attribute::ReadOnly);
call->addFnAttr(llvm::Attribute::NoUnwind);
call->addParamAttr(1, llvm::Attribute::ReadOnly);

auto attrs = call->getAttributes();
IGF.IGM.addSwiftSelfAttributes(attrs, 0);
Expand Down
Loading