Skip to content

Commit

Permalink
Update Swift master-next for upstream llvm.org changes.
Browse files Browse the repository at this point in the history
  • Loading branch information
adrian-prantl committed Oct 21, 2019
1 parent 299b461 commit 468b74b
Show file tree
Hide file tree
Showing 9 changed files with 48 additions and 24 deletions.
6 changes: 4 additions & 2 deletions include/swift/ABI/TrailingObjects.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@
#ifndef SWIFT_ABI_TRAILINGOBJECTS_H
#define SWIFT_ABI_TRAILINGOBJECTS_H

#include "llvm/Support/Alignment.h"
#include "llvm/Support/AlignOf.h"
#include "llvm/Support/Compiler.h"
#include "llvm/Support/MathExtras.h"
Expand Down Expand Up @@ -175,7 +176,7 @@ class TrailingObjectsImpl<Align, BaseTy, TopTrailingObj, PrevTy, NextTy,

if (requiresRealignment())
return reinterpret_cast<const NextTy *>(
llvm::alignAddr(Ptr, alignof(NextTy)));
llvm::alignAddr(Ptr, llvm::Align(alignof(NextTy))));
else
return reinterpret_cast<const NextTy *>(Ptr);
}
Expand All @@ -189,7 +190,8 @@ class TrailingObjectsImpl<Align, BaseTy, TopTrailingObj, PrevTy, NextTy,
Obj, TrailingObjectsBase::OverloadToken<PrevTy>());

if (requiresRealignment())
return reinterpret_cast<NextTy *>(llvm::alignAddr(Ptr, alignof(NextTy)));
return reinterpret_cast<NextTy *>(
llvm::alignAddr(Ptr, llvm::Align(alignof(NextTy))));
else
return reinterpret_cast<NextTy *>(Ptr);
}
Expand Down
1 change: 1 addition & 0 deletions include/swift/ABI/TypeIdentity.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#define SWIFT_ABI_TYPEIDENTITY_H

#include "swift/Basic/LLVM.h"
#include <llvm/ADT/StringRef.h>

namespace swift {
template <class> class TargetTypeContextDescriptor;
Expand Down
3 changes: 1 addition & 2 deletions include/swift/Basic/Statistic.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,7 @@

#define SWIFT_FUNC_STAT_NAMED(DEBUG_TYPE) \
do { \
static llvm::Statistic FStat = \
{DEBUG_TYPE, __func__, __func__, {0}, {false}}; \
static llvm::Statistic FStat = {DEBUG_TYPE, __func__, __func__}; \
++FStat; \
} while (0)

Expand Down
6 changes: 4 additions & 2 deletions lib/AST/ASTContext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -509,7 +509,8 @@ static ModuleDecl *createBuiltinModule(ASTContext &ctx) {

inline ASTContext::Implementation &ASTContext::getImpl() const {
auto pointer = reinterpret_cast<char*>(const_cast<ASTContext*>(this));
auto offset = llvm::alignAddr((void*)sizeof(*this), alignof(Implementation));
auto offset = llvm::alignAddr((void *)sizeof(*this),
llvm::Align(alignof(Implementation)));
return *reinterpret_cast<Implementation*>(pointer + offset);
}

Expand All @@ -528,7 +529,8 @@ ASTContext *ASTContext::get(LangOptions &langOpts,
auto size = llvm::alignTo(sizeof(ASTContext) + sizeof(Implementation), align);
auto mem = AlignedAlloc(size, align);
auto impl = reinterpret_cast<void*>((char*)mem + sizeof(ASTContext));
impl = reinterpret_cast<void*>(llvm::alignAddr(impl,alignof(Implementation)));
impl = reinterpret_cast<void *>(
llvm::alignAddr(impl, llvm::Align(alignof(Implementation))));
new (impl) Implementation();
return new (mem) ASTContext(langOpts, SearchPathOpts, SourceMgr, Diags);
}
Expand Down
4 changes: 2 additions & 2 deletions lib/Basic/Statistic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -418,7 +418,7 @@ UnifiedStatsReporter::publishAlwaysOnStatsToLLVM() {
auto &C = getFrontendCounters();
#define FRONTEND_STATISTIC(TY, NAME) \
do { \
static Statistic Stat = {#TY, #NAME, #NAME, {0}, {false}}; \
static Statistic Stat = {#TY, #NAME, #NAME}; \
Stat += (C).NAME; \
} while (0);
#include "swift/Basic/Statistics.def"
Expand All @@ -428,7 +428,7 @@ UnifiedStatsReporter::publishAlwaysOnStatsToLLVM() {
auto &C = getDriverCounters();
#define DRIVER_STATISTIC(NAME) \
do { \
static Statistic Stat = {"Driver", #NAME, #NAME, {0}, {false}}; \
static Statistic Stat = {"Driver", #NAME, #NAME}; \
Stat += (C).NAME; \
} while (0);
#include "swift/Basic/Statistics.def"
Expand Down
2 changes: 1 addition & 1 deletion lib/ClangImporter/ImportName.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1845,7 +1845,7 @@ const InheritedNameSet *NameImporter::getAllPropertyNames(
llvm::BumpPtrAllocator &alloc = scratch.getAllocator();
known = allProperties.insert({
std::pair<const clang::ObjCInterfaceDecl *, char>(classDecl, forInstance),
llvm::make_unique<InheritedNameSet>(parentSet, alloc) }).first;
std::make_unique<InheritedNameSet>(parentSet, alloc) }).first;

// Local function to add properties from the given set.
auto addProperties = [&](clang::DeclContext::decl_range members) {
Expand Down
4 changes: 2 additions & 2 deletions lib/IRGen/GenCall.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -205,8 +205,8 @@ void irgen::addByvalArgumentAttributes(IRGenModule &IGM,
unsigned argIndex, Alignment align) {
llvm::AttrBuilder b;
b.addAttribute(llvm::Attribute::ByVal);
b.addAttribute(llvm::Attribute::getWithAlignment(IGM.LLVMContext,
align.getValue()));
b.addAttribute(llvm::Attribute::getWithAlignment(
IGM.LLVMContext, llvm::Align(align.getValue())));
attrs = attrs.addAttributes(IGM.LLVMContext,
argIndex + llvm::AttributeList::FirstArgIndex, b);
}
Expand Down
45 changes: 32 additions & 13 deletions lib/Serialization/ModuleFile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1411,14 +1411,21 @@ ModuleFile::readDeclUSRsTable(ArrayRef<uint64_t> fields, StringRef blobData) {
}

bool ModuleFile::readDeclLocsBlock(llvm::BitstreamCursor &cursor) {
cursor.EnterSubBlock(DECL_LOCS_BLOCK_ID);
if (llvm::Error Err = cursor.EnterSubBlock(CONTROL_BLOCK_ID)) {
consumeError(std::move(Err));
return false;
}

SmallVector<uint64_t, 4> scratch;
StringRef blobData;

while (!cursor.AtEndOfStream()) {
auto entry = cursor.advance();
switch (entry.Kind) {
Expected<llvm::BitstreamEntry> entry = cursor.advance();
if (!entry) {
consumeError(entry.takeError());
return false;
}
switch (entry->Kind) {
case llvm::BitstreamEntry::EndBlock:
return true;

Expand All @@ -1433,9 +1440,13 @@ bool ModuleFile::readDeclLocsBlock(llvm::BitstreamCursor &cursor) {

case llvm::BitstreamEntry::Record:
scratch.clear();
unsigned kind = cursor.readRecord(entry.ID, scratch, &blobData);

switch (kind) {
Expected<unsigned> kind =
cursor.readRecord(entry->ID, scratch, &blobData);
if (!kind) {
consumeError(kind.takeError());
return false;
}
switch (*kind) {
case decl_locs_block::BASIC_DECL_LOCS:
BasicDeclLocsData = blobData;
break;
Expand Down Expand Up @@ -1467,20 +1478,28 @@ bool ModuleFile::readModuleSourceInfoIfPresent() {
}

SmallVector<uint64_t, 64> scratch;
llvm::BitstreamEntry topLevelEntry;

bool hasValidControlBlock = false;
ValidationInfo info;
unsigned kind = llvm::BitstreamEntry::Error;

while (!infoCursor.AtEndOfStream()) {
topLevelEntry = infoCursor.advance(AF_DontPopBlockAtEnd);
if (topLevelEntry.Kind != llvm::BitstreamEntry::SubBlock)
Expected<llvm::BitstreamEntry> topLevelEntry =
infoCursor.advance(AF_DontPopBlockAtEnd);
if (!topLevelEntry) {
consumeError(topLevelEntry.takeError());
return false;
}
kind = topLevelEntry->Kind;
if (kind != llvm::BitstreamEntry::SubBlock)
break;

switch (topLevelEntry.ID) {
switch (topLevelEntry->ID) {
case CONTROL_BLOCK_ID: {
infoCursor.EnterSubBlock(CONTROL_BLOCK_ID);

if (llvm::Error Err = infoCursor.EnterSubBlock(CONTROL_BLOCK_ID)) {
consumeError(std::move(Err));
return false;
}
info = validateControlBlock(infoCursor, scratch,
{SWIFTSOURCEINFO_VERSION_MAJOR,
SWIFTSOURCEINFO_VERSION_MINOR},
Expand Down Expand Up @@ -1509,7 +1528,7 @@ bool ModuleFile::readModuleSourceInfoIfPresent() {
}
}

if (topLevelEntry.Kind != llvm::BitstreamEntry::EndBlock)
if (kind != llvm::BitstreamEntry::EndBlock)
return false;

return true;
Expand Down
1 change: 1 addition & 0 deletions tools/SourceKit/lib/SwiftLang/CodeCompletion.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#include "swift/IDE/CodeCompletion.h"
#include "llvm/ADT/DenseMap.h"
#include "llvm/ADT/Optional.h"
#include "llvm/ADT/StringMap.h"

namespace SourceKit {
namespace CodeCompletion {
Expand Down

0 comments on commit 468b74b

Please sign in to comment.