Skip to content

Commit 9bd3ed3

Browse files
authored
Merge pull request swiftlang#33731 from apple/master-rebranch
Merge master-rebranch into Swift master branch to support updating llvm-project update
2 parents ed5edb8 + e107182 commit 9bd3ed3

File tree

70 files changed

+403
-311
lines changed

Some content is hidden

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

70 files changed

+403
-311
lines changed

docs/Modules.rst

-10
Original file line numberDiff line numberDiff line change
@@ -441,10 +441,6 @@ Glossary
441441

442442
__ https://en.wikipedia.org/wiki/Name_mangling#C.2B.2B
443443

444-
module
445-
An entity containing the API for a library, to be `imported <import>` into
446-
a source file.
447-
448444
qualified name
449445
A multi-piece name like ``Foundation.NSWindow``, which names an entity
450446
within a particular context. This document is concerned with the case where
@@ -463,9 +459,3 @@ Glossary
463459
SIL
464460
"Swift Intermediate Language", a stable IR for the distribution of
465461
inlineable code.
466-
467-
468-
target
469-
A dynamic library, framework, plug-in, or application to be built.
470-
A natural LTO boundary, and roughly the same as what Xcode requires
471-
separate targets to build.

include/swift/AST/Builtins.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
#include "llvm/Support/ErrorHandling.h"
2727

2828
namespace llvm {
29-
enum class AtomicOrdering;
29+
enum class AtomicOrdering : unsigned;
3030
}
3131

3232
namespace swift {

include/swift/AST/ClangNode.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,8 @@ class ClangNode {
4949
template <typename T>
5050
using Box = detail::ClangNodeBox<T>;
5151

52-
llvm::PointerUnion4<Box<clang::Decl>, Box<clang::MacroInfo>,
53-
Box<clang::ModuleMacro>, Box<clang::Module>> Ptr;
52+
llvm::PointerUnion<Box<clang::Decl>, Box<clang::MacroInfo>,
53+
Box<clang::ModuleMacro>, Box<clang::Module>> Ptr;
5454

5555
public:
5656
ClangNode() = default;

include/swift/AST/ExtInfo.h

+2-1
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030

3131
namespace clang {
3232
class Type;
33+
class ASTContext;
3334
} // namespace clang
3435

3536
namespace swift {
@@ -77,7 +78,7 @@ class ClangTypeInfo {
7778
/// Use the ClangModuleLoader to print the Clang type as a string.
7879
void printType(ClangModuleLoader *cml, llvm::raw_ostream &os) const;
7980

80-
void dump(llvm::raw_ostream &os) const;
81+
void dump(llvm::raw_ostream &os, const clang::ASTContext &ctx) const;
8182
};
8283

8384
// MARK: - FunctionTypeRepresentation

include/swift/AST/PrettyStackTrace.h

+5-2
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626

2727
namespace clang {
2828
class Type;
29+
class ASTContext;
2930
}
3031

3132
namespace swift {
@@ -141,11 +142,13 @@ class PrettyStackTraceType : public llvm::PrettyStackTraceEntry {
141142
/// PrettyStackTraceClangType - Observe that we are processing a
142143
/// specific Clang type.
143144
class PrettyStackTraceClangType : public llvm::PrettyStackTraceEntry {
145+
const clang::ASTContext &Context;
144146
const clang::Type *TheType;
145147
const char *Action;
146148
public:
147-
PrettyStackTraceClangType(const char *action, const clang::Type *type)
148-
: TheType(type), Action(action) {}
149+
PrettyStackTraceClangType(clang::ASTContext &ctx,
150+
const char *action, const clang::Type *type)
151+
: Context(ctx), TheType(type), Action(action) {}
149152
virtual void print(llvm::raw_ostream &OS) const override;
150153
};
151154

include/swift/AST/SimpleRequest.h

+1
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
#include "swift/Basic/TypeID.h"
2525
#include "llvm/ADT/Hashing.h"
2626
#include "llvm/ADT/STLExtras.h"
27+
#include "llvm/Support/Error.h"
2728
#include <tuple>
2829
#include <type_traits>
2930

include/swift/AST/SourceFile.h

+5-3
Original file line numberDiff line numberDiff line change
@@ -692,9 +692,11 @@ struct DenseMapInfo<swift::SourceFile::ImportedModuleDesc> {
692692
StringRefDMI::getTombstoneKey());
693693
}
694694
static inline unsigned getHashValue(const ImportedModuleDesc &import) {
695-
return combineHashValue(ImportedModuleDMI::getHashValue(import.module),
696-
combineHashValue(ImportOptionsDMI::getHashValue(import.importOptions),
697-
StringRefDMI::getHashValue(import.filename)));
695+
return detail::combineHashValue(
696+
ImportedModuleDMI::getHashValue(import.module),
697+
detail::combineHashValue(
698+
ImportOptionsDMI::getHashValue(import.importOptions),
699+
StringRefDMI::getHashValue(import.filename)));
698700
}
699701
static bool isEqual(const ImportedModuleDesc &a,
700702
const ImportedModuleDesc &b) {

include/swift/Basic/STLExtras.h

-45
Original file line numberDiff line numberDiff line change
@@ -69,51 +69,6 @@ struct function_traits<R (T::*)(Args...) const> {
6969
using argument_types = std::tuple<Args...>;
7070
};
7171

72-
} // end namespace swift
73-
74-
#if !defined(swiftCore_EXPORTS)
75-
namespace llvm {
76-
77-
/// @{
78-
79-
/// An STL-style algorithm similar to std::for_each that applies a second
80-
/// functor between every pair of elements.
81-
///
82-
/// This provides the control flow logic to, for example, print a
83-
/// comma-separated list:
84-
/// \code
85-
/// interleave(names.begin(), names.end(),
86-
/// [&](StringRef name) { OS << name; },
87-
/// [&] { OS << ", "; });
88-
/// \endcode
89-
template <typename ForwardIterator, typename UnaryFunctor,
90-
typename NullaryFunctor>
91-
inline void interleave(ForwardIterator begin, ForwardIterator end,
92-
UnaryFunctor each_fn,
93-
NullaryFunctor between_fn) {
94-
if (begin == end)
95-
return;
96-
each_fn(*begin);
97-
++begin;
98-
for (; begin != end; ++begin) {
99-
between_fn();
100-
each_fn(*begin);
101-
}
102-
}
103-
104-
template <typename Container, typename UnaryFunctor, typename NullaryFunctor>
105-
inline void interleave(const Container &c, UnaryFunctor each_fn,
106-
NullaryFunctor between_fn) {
107-
interleave(c.begin(), c.end(), each_fn, between_fn);
108-
}
109-
110-
/// @}
111-
112-
} // end namespace llvm
113-
#endif
114-
115-
namespace swift {
116-
11772
/// @{
11873

11974
/// The equivalent of std::for_each, but for two lists at once.

include/swift/ClangImporter/ClangModule.h

+3-3
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
#include "swift/AST/FileUnit.h"
2020
#include "swift/ClangImporter/ClangImporter.h"
2121
#include "clang/AST/ExternalASTSource.h"
22+
#include "clang/Basic/Module.h"
2223

2324
namespace clang {
2425
class ASTContext;
@@ -37,7 +38,7 @@ class ClangModuleUnit final : public LoadedFile {
3738
llvm::PointerIntPair<ModuleDecl *, 1, bool> overlayModule;
3839
mutable Optional<ArrayRef<ModuleDecl::ImportedModule>> importedModulesForLookup;
3940
/// The metadata of the underlying Clang module.
40-
clang::ExternalASTSource::ASTSourceDescriptor ASTSourceDescriptor;
41+
clang::ASTSourceDescriptor ASTSourceDescriptor;
4142

4243
public:
4344
/// True if the given Module contains an imported Clang module unit.
@@ -115,8 +116,7 @@ class ClangModuleUnit final : public LoadedFile {
115116

116117
/// Returns the ASTSourceDescriptor of the associated Clang module if one
117118
/// exists.
118-
Optional<clang::ExternalASTSource::ASTSourceDescriptor>
119-
getASTSourceDescriptor() const;
119+
Optional<clang::ASTSourceDescriptor> getASTSourceDescriptor() const;
120120

121121
virtual StringRef getModuleDefiningPath() const override;
122122

include/swift/Frontend/FrontendInputsAndOutputs.h

+1
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
#include "swift/Basic/SupplementaryOutputPaths.h"
1818
#include "swift/Frontend/InputFile.h"
1919
#include "llvm/ADT/Hashing.h"
20+
#include "llvm/ADT/StringMap.h"
2021

2122
#include <string>
2223
#include <vector>

include/swift/Parse/ParsedRawSyntaxNode.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -98,8 +98,8 @@ class ParsedRawSyntaxNode {
9898
assert(DeferredToken.NumTrailingTrivia == numTrailingTrivia &&
9999
"numLeadingTrivia is too large value!");
100100
}
101-
ParsedRawSyntaxNode(ParsedRawSyntaxNode &other) = delete;
102-
ParsedRawSyntaxNode &operator=(ParsedRawSyntaxNode &other) = delete;
101+
ParsedRawSyntaxNode(const ParsedRawSyntaxNode &other) = delete;
102+
ParsedRawSyntaxNode &operator=(const ParsedRawSyntaxNode &other) = delete;
103103

104104
public:
105105
ParsedRawSyntaxNode()

include/swift/SIL/SILLocation.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ class SILLocation {
6565
using type = Pattern;
6666
};
6767

68-
using ASTNodeTy = llvm::PointerUnion4<Stmt *, Expr *, Decl *, Pattern *>;
68+
using ASTNodeTy = llvm::PointerUnion<Stmt *, Expr *, Decl *, Pattern *>;
6969

7070
public:
7171
enum LocationKind : unsigned {

include/swift/SIL/SILNode.h

+1
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919

2020
#include "llvm/Support/Compiler.h"
2121
#include "llvm/ADT/DenseMapInfo.h"
22+
#include "llvm/Support/PointerLikeTypeTraits.h"
2223
#include "swift/Basic/InlineBitfield.h"
2324
#include "swift/Basic/LLVM.h"
2425
#include <type_traits>

include/swift/SILOptimizer/Analysis/DominanceAnalysis.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ class SILInstruction;
2424
class DominanceAnalysis : public FunctionAnalysisBase<DominanceInfo> {
2525
protected:
2626
virtual void verify(DominanceInfo *DI) const override {
27-
if (DI->getRoots().empty())
27+
if (DI->roots().empty())
2828
return;
2929
DI->verify();
3030
}
@@ -52,7 +52,7 @@ class DominanceAnalysis : public FunctionAnalysisBase<DominanceInfo> {
5252
class PostDominanceAnalysis : public FunctionAnalysisBase<PostDominanceInfo> {
5353
protected:
5454
virtual void verify(PostDominanceInfo *PDI) const override {
55-
if (PDI->getRoots().empty())
55+
if (PDI->roots().empty())
5656
return;
5757
PDI->verify();
5858
}

include/swift/Subsystems.h

+1
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
#include <memory>
3030

3131
namespace llvm {
32+
class raw_pwrite_stream;
3233
class GlobalVariable;
3334
class MemoryBuffer;
3435
class Module;

lib/AST/ASTDumper.cpp

+3-1
Original file line numberDiff line numberDiff line change
@@ -3781,7 +3781,9 @@ namespace {
37813781
if (!T->getClangTypeInfo().empty()) {
37823782
std::string s;
37833783
llvm::raw_string_ostream os(s);
3784-
T->getClangTypeInfo().dump(os);
3784+
auto &ctx = T->getASTContext().getClangModuleLoader()
3785+
->getClangASTContext();
3786+
T->getClangTypeInfo().dump(os, ctx);
37853787
printField("clang_type", os.str());
37863788
}
37873789
printAnyFunctionParams(T->getParams(), "input");

lib/AST/ASTPrinter.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@
4848
#include "clang/AST/Decl.h"
4949
#include "clang/AST/DeclObjC.h"
5050
#include "clang/Basic/Module.h"
51+
#include "clang/Basic/SourceManager.h"
5152
#include "llvm/ADT/StringSwitch.h"
5253
#include "llvm/Support/Compiler.h"
5354
#include "llvm/Support/ConvertUTF.h"

lib/AST/Builtins.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -1747,12 +1747,12 @@ Type IntrinsicTypeDecoder::decodeImmediate() {
17471747
IITDescriptor D = Table.front();
17481748
Table = Table.slice(1);
17491749
switch (D.Kind) {
1750+
case IITDescriptor::BFloat:
17501751
case IITDescriptor::MMX:
17511752
case IITDescriptor::Metadata:
17521753
case IITDescriptor::ExtendArgument:
17531754
case IITDescriptor::TruncArgument:
17541755
case IITDescriptor::HalfVecArgument:
1755-
case IITDescriptor::ScalableVecArgument:
17561756
case IITDescriptor::VarArg:
17571757
case IITDescriptor::Token:
17581758
case IITDescriptor::VecElementArgument:
@@ -1781,7 +1781,7 @@ Type IntrinsicTypeDecoder::decodeImmediate() {
17811781
case IITDescriptor::Vector: {
17821782
Type eltType = decodeImmediate();
17831783
if (!eltType) return Type();
1784-
return makeVector(eltType, D.Vector_Width);
1784+
return makeVector(eltType, D.Vector_Width.Min);
17851785
}
17861786

17871787
// A pointer to an immediate type.

lib/AST/Decl.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@
5959
#include "swift/Demangling/ManglingMacros.h"
6060

6161
#include "clang/Basic/CharInfo.h"
62+
#include "clang/Basic/Module.h"
6263
#include "clang/AST/Attr.h"
6364
#include "clang/AST/DeclObjC.h"
6465

lib/AST/Expr.cpp

+7-8
Original file line numberDiff line numberDiff line change
@@ -833,16 +833,15 @@ APInt BuiltinIntegerWidth::parse(StringRef text, unsigned radix, bool negate,
833833
static APFloat getFloatLiteralValue(bool IsNegative, StringRef Text,
834834
const llvm::fltSemantics &Semantics) {
835835
APFloat Val(Semantics);
836-
llvm::Expected<APFloat::opStatus> MaybeRes =
837-
Val.convertFromString(Text, llvm::APFloat::rmNearestTiesToEven);
838-
assert(MaybeRes && *MaybeRes != APFloat::opInvalidOp &&
839-
"Sema didn't reject invalid number");
840-
(void)MaybeRes;
836+
auto Res =
837+
Val.convertFromString(Text, llvm::APFloat::rmNearestTiesToEven);
838+
assert(Res && "Sema didn't reject invalid number");
839+
consumeError(Res.takeError());
841840
if (IsNegative) {
842841
auto NegVal = APFloat::getZero(Semantics, /*negative*/ true);
843-
auto Res = NegVal.subtract(Val, llvm::APFloat::rmNearestTiesToEven);
844-
assert(Res != APFloat::opInvalidOp && "Sema didn't reject invalid number");
845-
(void)Res;
842+
Res = NegVal.subtract(Val, llvm::APFloat::rmNearestTiesToEven);
843+
assert(Res && "Sema didn't reject invalid number");
844+
consumeError(Res.takeError());
846845
return NegVal;
847846
}
848847
return Val;

lib/AST/ExtInfo.cpp

+7-8
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,10 @@ static void assertIsFunctionType(const clang::Type *type) {
2323
#ifndef NDEBUG
2424
if (!(type->isFunctionPointerType() || type->isBlockPointerType() ||
2525
type->isFunctionReferenceType())) {
26-
llvm::SmallString<256> buf;
27-
llvm::raw_svector_ostream os(buf);
28-
os << "Expected a Clang function type wrapped in a pointer type or "
29-
<< "a block pointer type but found:\n";
30-
type->dump(os);
31-
llvm_unreachable(os.str().data());
26+
llvm::errs() << "Expected a Clang function type wrapped in a pointer type "
27+
<< "or a block pointer type but found:\n";
28+
type->dump();
29+
llvm_unreachable("\nUnexpected Clang type when creating ExtInfo!");
3230
}
3331
#endif
3432
}
@@ -57,9 +55,10 @@ void ClangTypeInfo::printType(ClangModuleLoader *cml,
5755
cml->printClangType(type, os);
5856
}
5957

60-
void ClangTypeInfo::dump(llvm::raw_ostream &os) const {
58+
void ClangTypeInfo::dump(llvm::raw_ostream &os,
59+
const clang::ASTContext &ctx) const {
6160
if (type) {
62-
type->dump(os);
61+
type->dump(os, ctx);
6362
} else {
6463
os << "<nullptr>";
6564
}

lib/AST/PrettyStackTrace.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ void PrettyStackTraceClangType::print(llvm::raw_ostream &out) const {
217217
out << "NULL clang type!\n";
218218
return;
219219
}
220-
TheType->dump(out);
220+
TheType->dump(out, Context);
221221
}
222222

223223
void PrettyStackTraceTypeRepr::print(llvm::raw_ostream &out) const {

0 commit comments

Comments
 (0)