Skip to content

Commit 6847361

Browse files
authored
Merge pull request #22 from benlangmuir/update-51
[5.1] Update swift-5.1-branch
2 parents 0921902 + 9126c26 commit 6847361

File tree

242 files changed

+11819
-3592
lines changed

Some content is hidden

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

242 files changed

+11819
-3592
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,5 +20,5 @@ $ swift test
2020
The C++ code in the index requires `libdispatch`, but unlike Swift code, it cannot find it automatically on Linux. You can work around this by adding a search path manually.
2121

2222
```sh
23-
$ swift build -Xcxx -I<path_to_swift_toolchain>/usr/lib/swift
23+
$ swift build -Xcxx -I<path_to_swift_toolchain>/usr/lib/swift -Xcxx -I<path_to_swift_toolchain>/usr/lib/swift/Block
2424
```

Utilities/import-llvm

Lines changed: 28 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
#
55
# NOTE: We have slightly modified copies of some of the files, to reduce the
66
# dependency surface area, so if you run this to update the sources, please
7-
# examine the diffs to remove things that don't make sense.
7+
# examine the diffs to remove things that don't make sense and update 'llvm-patch.diff'.
88

99
import errno
1010
import optparse
@@ -19,7 +19,7 @@ ADT_imports = ['EpochTracker', 'iterator', 'iterator_range', 'Hashing', 'None',
1919
'Statistic', 'StringExtras', 'STLExtras', 'AllocatorList', 'Triple']
2020

2121
# ADT basic data structures.
22-
ADT_imports += ['APFloat', 'APInt', 'APSInt', 'ArrayRef', 'PointerIntPair', 'SetVector', 'StringRef', 'StringSwitch',
22+
ADT_imports += ['APFloat', 'APInt', 'APSInt', 'ArrayRef', 'bit', 'PointerIntPair', 'SetVector', 'StringRef', 'StringSwitch',
2323
'Twine', 'IntrusiveRefCntPtr', 'ilist', 'ilist_base', 'ilist_node', 'ilist_node_base',
2424
'ilist_node_options', 'ilist_iterator', 'simple_ilist', 'OptionSet', 'PointerUnion']
2525

@@ -35,11 +35,11 @@ ADT_imports += ['edit_distance']
3535
# Support types and infrastructure.
3636
Support_imports = [
3737
'AlignOf', 'Allocator', 'Atomic', 'CBindingWrapping', 'Casting', 'Capacity', 'CommandLine', 'Compiler',
38-
'Endian', 'Errno', 'ErrorHandling', 'Errc', 'ErrorOr', 'Error', 'Format',
38+
'Endian', 'Errno', 'ErrorHandling', 'Errc', 'ErrorOr', 'Error', 'Format', 'FormatAdapters',
3939
'ManagedStatic', 'MathExtras', 'Mutex', 'MutexGuard', 'Memory',
4040
'MemoryBuffer', 'PointerLikeTypeTraits', 'Recycler', 'SwapByteOrder',
4141
'Timer', 'TimeValue', 'Threading', 'Unicode', 'UniqueLock', 'Unix', 'WindowsError',
42-
'Valgrind', 'circular_raw_ostream', 'raw_ostream', 'type_traits', 'JSON']
42+
'Valgrind', 'circular_raw_ostream', 'raw_ostream', 'Signposts', 'type_traits', 'JSON']
4343

4444
# Stuff we don't want, but have to pull in.
4545
Support_imports += [
@@ -49,23 +49,24 @@ Support_imports += [
4949
'MemAlloc', 'Chrono', 'FormatProviders', 'FormatVariadic', 'FormatCommon',
5050
'FormatVariadicDetails', 'NativeFormatting', 'DJB', 'ReverseIteration', 'MD5',
5151
'SmallVectorMemoryBuffer', 'WithColor', 'Options', 'PrettyStackTrace', 'Watchdog',
52-
'TargetParser', 'ARMBuildAttributes', 'ARMTargetParser.def', 'AArch64TargetParser.def', 'X86TargetParser.def', 'LineIterator']
52+
'TargetParser', 'ARMBuildAttributes', 'ARMTargetParser', 'AArch64TargetParser',
53+
'ARMTargetParser.def', 'AArch64TargetParser.def', 'X86TargetParser.def', 'LineIterator']
5354

5455
# Dependencies from llvm-c needed by Support.
55-
C_imports = ['Types', 'DataTypes', 'Support', 'ErrorHandling']
56+
C_imports = ['Types', 'DataTypes', 'Support', 'Error', 'ErrorHandling']
5657

5758
# Support data structures.
5859
Support_imports += ['YAMLParser', 'YAMLTraits']
5960

6061
# Source files to exclude.
61-
Support_source_excludes = set(['Host'])
62+
Support_source_excludes = set([])
6263

6364
llvm_srcroot = None
64-
sourcekit_srcroot = None
65+
indexstoredb_srcroot = None
6566

6667
def note(msg):
6768
msg = msg.replace(llvm_srcroot, "<LLVM>")
68-
msg = msg.replace(sourcekit_srcroot, "<INDEXSTOREDB>")
69+
msg = msg.replace(indexstoredb_srcroot, "<INDEXSTOREDB>")
6970
print >>sys.stderr, "note: %s" % (msg,)
7071

7172
def mkdir_p(path):
@@ -133,32 +134,32 @@ def main():
133134
if len(args) != 1:
134135
parser.error("unexpected number of arguments")
135136

136-
global llvm_srcroot, sourcekit_srcroot
137+
global llvm_srcroot, indexstoredb_srcroot
137138
llvm_srcroot, = args
138-
sourcekit_srcroot = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
139+
indexstoredb_srcroot = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
139140

140141
def import_header(dir, name):
141142
src = os.path.join(llvm_srcroot, 'include', 'llvm', dir, name)
142143
if os.path.exists(src):
143-
dst = os.path.join(sourcekit_srcroot, 'include', 'llvm', dir, name)
144+
dst = os.path.join(indexstoredb_srcroot, 'include', 'llvm', dir, name)
144145
mkdir_p(os.path.dirname(dst))
145146
copyfile(src, dst)
146147

147148
def import_c_header(name):
148149
src = os.path.join(llvm_srcroot, 'include', 'llvm-c', name)
149150
if os.path.exists(src):
150-
dst = os.path.join(sourcekit_srcroot, 'include', 'llvm-c', name)
151+
dst = os.path.join(indexstoredb_srcroot, 'include', 'llvm-c', name)
151152
mkdir_p(os.path.dirname(dst))
152153
copyfile(src, dst)
153154

154155
def import_source(dir, name):
155156
src = os.path.join(llvm_srcroot, 'lib', dir, name)
156157
if os.path.exists(src):
157-
dst = os.path.join(sourcekit_srcroot, 'lib', 'LLVMSupport', dir, name)
158+
dst = os.path.join(indexstoredb_srcroot, 'lib', 'LLVMSupport', dir, name)
158159
mkdir_p(os.path.dirname(dst))
159160
copyfile(src, dst)
160161

161-
print "note: importing from %r to %r" % (llvm_srcroot, sourcekit_srcroot)
162+
print "note: importing from %r to %r" % (llvm_srcroot, indexstoredb_srcroot)
162163

163164
for name in ADT_imports:
164165
import_header('ADT', name+'.h')
@@ -175,6 +176,8 @@ def main():
175176
import_source('Support', name+'.cpp')
176177
import_source('Support', os.path.join('Unix', name+'.h'))
177178
import_source('Support', os.path.join('Unix', name+'.inc'))
179+
import_source('Support', os.path.join('Windows', name+'.h'))
180+
import_source('Support', os.path.join('Windows', name+'.inc'))
178181

179182
for name in C_imports:
180183
import_c_header(name + '.h')
@@ -183,17 +186,23 @@ def main():
183186
print "Adding prefix header includes"
184187

185188
base_dirs = [
186-
os.path.join(sourcekit_srcroot, 'include', 'llvm'),
187-
os.path.join(sourcekit_srcroot, 'include', 'llvm-c'),
188-
os.path.join(sourcekit_srcroot, 'lib', 'LLVMSupport'),
189+
os.path.join(indexstoredb_srcroot, 'include', 'llvm'),
190+
os.path.join(indexstoredb_srcroot, 'include', 'llvm-c'),
191+
os.path.join(indexstoredb_srcroot, 'lib', 'LLVMSupport'),
189192
]
190193

191-
include_dir = os.path.join(sourcekit_srcroot, 'include')
194+
include_dir = os.path.join(indexstoredb_srcroot, 'include')
192195

193196
for base in base_dirs:
194197
for root, dirs, files in os.walk(base):
195198
for file in files:
196199
maybe_add_prefix(os.path.join(root, file), include_dir)
197200

201+
print ""
202+
print "Applying patch"
203+
204+
patch_path = os.path.join(indexstoredb_srcroot, 'Utilities', 'llvm-patch.diff'),
205+
subprocess.call("patch -p1 < '%s'" % patch_path, shell=True)
206+
198207
if __name__ == '__main__':
199208
main()

Utilities/llvm-patch.diff

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
diff --git a/lib/LLVMSupport/Support/AArch64TargetParser.cpp b/lib/LLVMSupport/Support/AArch64TargetParser.cpp
2+
index faf8385c..8772d213 100644
3+
--- a/lib/LLVMSupport/Support/AArch64TargetParser.cpp
4+
+++ b/lib/LLVMSupport/Support/AArch64TargetParser.cpp
5+
@@ -31,7 +31,7 @@ unsigned AArch64::getDefaultFPU(StringRef CPU, AArch64::ArchKind AK) {
6+
return StringSwitch<unsigned>(CPU)
7+
#define AARCH64_CPU_NAME(NAME, ID, DEFAULT_FPU, IS_DEFAULT, DEFAULT_EXT) \
8+
.Case(NAME, ARM::DEFAULT_FPU)
9+
-#include "../../include/llvm/Support/AArch64TargetParser.def"
10+
+#include "llvm/Support/AArch64TargetParser.def"
11+
.Default(ARM::FK_INVALID);
12+
}
13+
14+
@@ -44,7 +44,7 @@ unsigned AArch64::getDefaultExtensions(StringRef CPU, AArch64::ArchKind AK) {
15+
.Case(NAME, AArch64ARCHNames[static_cast<unsigned>(ArchKind::ID)] \
16+
.ArchBaseExtensions | \
17+
DEFAULT_EXT)
18+
-#include "../../include/llvm/Support/AArch64TargetParser.def"
19+
+#include "llvm/Support/AArch64TargetParser.def"
20+
.Default(AArch64::AEK_INVALID);
21+
}
22+
23+
@@ -55,7 +55,7 @@ AArch64::ArchKind AArch64::getCPUArchKind(StringRef CPU) {
24+
return StringSwitch<AArch64::ArchKind>(CPU)
25+
#define AARCH64_CPU_NAME(NAME, ID, DEFAULT_FPU, IS_DEFAULT, DEFAULT_EXT) \
26+
.Case(NAME, ArchKind::ID)
27+
-#include "../../include/llvm/Support/AArch64TargetParser.def"
28+
+#include "llvm/Support/AArch64TargetParser.def"
29+
.Default(ArchKind::INVALID);
30+
}
31+
32+
--- a/include/llvm/Support/YAMLTraits.h
33+
+++ b/include/llvm/Support/YAMLTraits.h
34+
@@ -18,7 +18,6 @@
35+
#include "llvm/Support/AlignOf.h"
36+
#include "llvm/Support/Allocator.h"
37+
#include "llvm/Support/Endian.h"
38+
-#include "llvm/Support/Regex.h"
39+
#include "llvm/Support/SourceMgr.h"
40+
#include "llvm/Support/YAMLParser.h"
41+
#include "llvm/Support/raw_ostream.h"

include/IndexStoreDB/Core/Symbol.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
#include "llvm/ADT/StringRef.h"
2424
#include "llvm/ADT/SmallVector.h"
2525
#include "llvm/Support/DataTypes.h"
26-
#include "llvm/Support/TimeValue.h"
26+
#include "llvm/Support/Chrono.h"
2727
#include <memory>
2828
#include <string>
2929

@@ -224,20 +224,20 @@ class SymbolRelation {
224224
class TimestampedPath {
225225
std::string Path;
226226
std::string ModuleName;
227-
llvm::sys::TimeValue ModificationTime;
227+
llvm::sys::TimePoint<> ModificationTime;
228228
unsigned sysrootPrefixLength = 0;
229229
bool IsSystem;
230230

231231
public:
232-
TimestampedPath(StringRef Path, llvm::sys::TimeValue ModificationTime, StringRef moduleName, bool isSystem, CanonicalFilePathRef sysroot = {})
232+
TimestampedPath(StringRef Path, llvm::sys::TimePoint<> ModificationTime, StringRef moduleName, bool isSystem, CanonicalFilePathRef sysroot = {})
233233
: Path(Path), ModuleName(moduleName), ModificationTime(ModificationTime), IsSystem(isSystem) {
234234
if (sysroot.contains(CanonicalFilePathRef::getAsCanonicalPath(Path))) {
235235
sysrootPrefixLength = sysroot.getPath().size();
236236
}
237237
}
238238

239239
const std::string &getPathString() const { return Path; }
240-
llvm::sys::TimeValue getModificationTime() const { return ModificationTime; }
240+
llvm::sys::TimePoint<> getModificationTime() const { return ModificationTime; }
241241
const std::string &getModuleName() const { return ModuleName; }
242242
unsigned isSystem() const { return IsSystem; }
243243
StringRef getPathWithoutSysroot() const {

include/IndexStoreDB/Database/Database.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,15 @@
1515

1616
#include "IndexStoreDB/Database/IDCode.h"
1717
#include "IndexStoreDB/Support/LLVM.h"
18+
#include "IndexStoreDB/Support/Visibility.h"
1819
#include <memory>
1920

2021
namespace IndexStoreDB {
2122
namespace db {
2223
class Database;
2324
typedef std::shared_ptr<Database> DatabaseRef;
2425

25-
class LLVM_EXPORT Database {
26+
class INDEXSTOREDB_EXPORT Database {
2627
public:
2728
static DatabaseRef create(StringRef dbPath, bool readonly, Optional<size_t> initialDBSize, std::string &error);
2829
~Database();
@@ -43,7 +44,7 @@ class LLVM_EXPORT Database {
4344
static const unsigned DATABASE_FORMAT_VERSION;
4445
};
4546

46-
LLVM_EXPORT IDCode makeIDCodeFromString(StringRef name);
47+
INDEXSTOREDB_EXPORT IDCode makeIDCodeFromString(StringRef name);
4748

4849
} // namespace db
4950
} // namespace IndexStoreDB

include/IndexStoreDB/Database/DatabaseError.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,14 @@
1313
#ifndef INDEXSTOREDB_SKDATABASE_DATABASEERROR_H
1414
#define INDEXSTOREDB_SKDATABASE_DATABASEERROR_H
1515

16-
#include "llvm/Support/Compiler.h"
16+
#include "IndexStoreDB/Support/Visibility.h"
1717
#include <string>
1818
#include <stdexcept>
1919

2020
namespace IndexStoreDB {
2121
namespace db {
2222

23-
class LLVM_EXPORT DatabaseError : public std::runtime_error {
23+
class INDEXSTOREDB_EXPORT DatabaseError : public std::runtime_error {
2424
protected:
2525
const int _code;
2626

@@ -51,7 +51,7 @@ class LLVM_EXPORT DatabaseError : public std::runtime_error {
5151
///
5252
/// @see http://symas.com/mdb/doc/group__errors.html#ga0a83370402a060c9175100d4bbfb9f25
5353
///
54-
class LLVM_EXPORT MapFullError final : public DatabaseError {
54+
class INDEXSTOREDB_EXPORT MapFullError final : public DatabaseError {
5555
virtual void _anchor();
5656
public:
5757
using DatabaseError::DatabaseError;

include/IndexStoreDB/Database/ImportTransaction.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ namespace db {
2424
class Database;
2525
typedef std::shared_ptr<Database> DatabaseRef;
2626

27-
class LLVM_EXPORT ImportTransaction {
27+
class INDEXSTOREDB_EXPORT ImportTransaction {
2828
public:
2929
explicit ImportTransaction(DatabaseRef dbase);
3030
~ImportTransaction();
@@ -48,13 +48,13 @@ class LLVM_EXPORT ImportTransaction {
4848
std::unique_ptr<Implementation> Impl;
4949
};
5050

51-
class LLVM_EXPORT UnitDataImport {
51+
class INDEXSTOREDB_EXPORT UnitDataImport {
5252
ImportTransaction &Import;
5353
std::string UnitName;
5454
CanonicalFilePath MainFile;
5555
CanonicalFilePath OutFile;
5656
CanonicalFilePath Sysroot;
57-
llvm::sys::TimeValue ModTime;
57+
llvm::sys::TimePoint<> ModTime;
5858
Optional<bool> IsSystem;
5959
Optional<SymbolProviderKind> SymProviderKind;
6060
std::string Target;
@@ -75,7 +75,7 @@ class LLVM_EXPORT UnitDataImport {
7575
std::vector<UnitInfo::Provider> ProviderDepends;
7676

7777
public:
78-
UnitDataImport(ImportTransaction &import, StringRef unitName, llvm::sys::TimeValue modTime);
78+
UnitDataImport(ImportTransaction &import, StringRef unitName, llvm::sys::TimePoint<> modTime);
7979
~UnitDataImport();
8080

8181
IDCode getUnitCode() const { return UnitCode; }

include/IndexStoreDB/Database/ReadTransaction.h

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ namespace db {
2626
class Database;
2727
typedef std::shared_ptr<Database> DatabaseRef;
2828

29-
class LLVM_EXPORT ReadTransaction {
29+
class INDEXSTOREDB_EXPORT ReadTransaction {
3030
public:
3131
explicit ReadTransaction(DatabaseRef dbase);
3232
~ReadTransaction();
@@ -45,13 +45,16 @@ class LLVM_EXPORT ReadTransaction {
4545
bool getProviderFileReferences(IDCode provider,
4646
llvm::function_ref<bool(TimestampedPath path)> receiver);
4747
bool getProviderFileCodeReferences(IDCode provider,
48-
llvm::function_ref<bool(IDCode pathCode, IDCode unitCode, llvm::sys::TimeValue modTime, IDCode moduleNameCode, bool isSystem)> receiver);
48+
llvm::function_ref<bool(IDCode pathCode, IDCode unitCode, llvm::sys::TimePoint<> modTime, IDCode moduleNameCode, bool isSystem)> receiver);
4949
/// Returns all provider-file associations. Intended for debugging purposes.
50-
bool foreachProviderAndFileCodeReference(llvm::function_ref<bool(IDCode provider, IDCode pathCode, IDCode unitCode, llvm::sys::TimeValue modTime, IDCode moduleNameCode, bool isSystem)> receiver);
50+
bool foreachProviderAndFileCodeReference(llvm::function_ref<bool(IDCode provider, IDCode pathCode, IDCode unitCode, llvm::sys::TimePoint<> modTime, IDCode moduleNameCode, bool isSystem)> receiver);
5151

5252
/// Returns USR codes in batches.
5353
bool foreachUSROfGlobalSymbolKind(SymbolKind symKind, llvm::function_ref<bool(ArrayRef<IDCode> usrCodes)> receiver);
5454

55+
/// Returns USR codes in batches.
56+
bool foreachUSROfGlobalUnitTestSymbol(llvm::function_ref<bool(ArrayRef<IDCode> usrCodes)> receiver);
57+
5558
/// Returns USR codes in batches.
5659
bool findUSRsWithNameContaining(StringRef pattern,
5760
bool anchorStart, bool anchorEnd,

include/IndexStoreDB/Database/UnitInfo.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
#include "llvm/ADT/ArrayRef.h"
1919
#include "llvm/ADT/Hashing.h"
2020
#include "llvm/ADT/StringRef.h"
21-
#include "llvm/Support/TimeValue.h"
21+
#include "llvm/Support/Chrono.h"
2222

2323
namespace IndexStoreDB {
2424
namespace db {
@@ -38,7 +38,7 @@ struct UnitInfo {
3838

3939
StringRef UnitName;
4040
IDCode UnitCode;
41-
llvm::sys::TimeValue ModTime;
41+
llvm::sys::TimePoint<> ModTime;
4242
IDCode OutFileCode;
4343
IDCode MainFileCode;
4444
IDCode SysrootCode;

include/IndexStoreDB/Index/IndexStoreLibraryProvider.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
#define INDEXSTOREDB_INDEX_SYMBOLDATAPROVIDER_H
1515

1616
#include "IndexStoreDB/Support/LLVM.h"
17+
#include "IndexStoreDB/Support/Visibility.h"
1718
#include "llvm/ADT/StringRef.h"
1819
#include <memory>
1920

@@ -29,7 +30,7 @@ namespace index {
2930
using IndexStoreLibrary = ::indexstore::IndexStoreLibrary;
3031
using IndexStoreLibraryRef = ::indexstore::IndexStoreLibraryRef;
3132

32-
class LLVM_EXPORT IndexStoreLibraryProvider {
33+
class INDEXSTOREDB_EXPORT IndexStoreLibraryProvider {
3334
public:
3435
virtual ~IndexStoreLibraryProvider() {}
3536

@@ -41,12 +42,12 @@ class LLVM_EXPORT IndexStoreLibraryProvider {
4142
};
4243

4344
/// A simple library provider that can be used if libIndexStore is linked to your binary.
44-
class LLVM_EXPORT GlobalIndexStoreLibraryProvider: public IndexStoreLibraryProvider {
45+
class INDEXSTOREDB_EXPORT GlobalIndexStoreLibraryProvider: public IndexStoreLibraryProvider {
4546
public:
4647
IndexStoreLibraryRef getLibraryForStorePath(StringRef storePath) override;
4748
};
4849

49-
LLVM_EXPORT IndexStoreLibraryRef loadIndexStoreLibrary(std::string dylibPath,
50+
INDEXSTOREDB_EXPORT IndexStoreLibraryRef loadIndexStoreLibrary(std::string dylibPath,
5051
std::string &error);
5152

5253
} // namespace index

0 commit comments

Comments
 (0)