Skip to content

[rebranch] Various changes to get rebranch compiling after taking new clang branch #74851

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 15 commits into from
Jul 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion include/swift/AST/PluginRegistry.h
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ class CompilerPlugin {

/// Remove "on reconnect" callback.
void removeOnReconnect(std::function<void(void)> *fn) {
llvm::erase_value(onReconnect, fn);
llvm::erase(onReconnect, fn);
}

ArrayRef<std::function<void(void)> *> getOnReconnectCallbacks() {
Expand Down
1 change: 1 addition & 0 deletions include/swift/ClangImporter/ClangModule.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
#include "swift/Basic/Version.h"
#include "swift/ClangImporter/ClangImporter.h"
#include "clang/AST/ExternalASTSource.h"
#include "clang/Basic/ASTSourceDescriptor.h"
#include "clang/Basic/Module.h"

namespace clang {
Expand Down
2 changes: 1 addition & 1 deletion include/swift/ClangImporter/SwiftAbstractBasicReader.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ class DataStreamBasicReader
return clang::Selector();

unsigned numArgs = unsigned(numArgsPlusOne - 1);
SmallVector<clang::IdentifierInfo *, 4> chunks;
SmallVector<const clang::IdentifierInfo *, 4> chunks;
for (unsigned i = 0, e = std::max(numArgs, 1U); i != e; ++i)
chunks.push_back(asImpl().readIdentifier());

Expand Down
5 changes: 3 additions & 2 deletions include/swift/SIL/SILInstruction.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ namespace ilist_detail {
///
/// We need a custom base class to not clear the prev/next pointers when
/// removing an instruction from the list.
class SILInstructionListBase : public ilist_base<false> {
class SILInstructionListBase : public ilist_base<false, void> {
public:
/// Remove an instruction from the list.
///
Expand Down Expand Up @@ -96,7 +96,8 @@ template <> struct compute_node_options<::swift::SILInstruction> {
static const bool is_sentinel_tracking_explicit = false;
static const bool has_iterator_bits = false;
typedef void tag;
typedef ilist_node_base<enable_sentinel_tracking> node_base_type;
typedef void parent_ty;
typedef ilist_node_base<enable_sentinel_tracking, void> node_base_type;
typedef SILInstructionListBase list_base_type;
};
};
Expand Down
10 changes: 7 additions & 3 deletions lib/AST/ClangTypeConverter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,10 +75,14 @@ getClangBuiltinTypeFromKind(const clang::ASTContext &context,
case clang::BuiltinType::Id: \
return context.Id##Ty;
#include "clang/Basic/RISCVVTypes.def"
#define WASM_REF_TYPE(Name, MangedNameBase, Id, SingletonId, AS) \
#define WASM_REF_TYPE(Name, MangledNameBase, Id, SingletonId, AS) \
case clang::BuiltinType::Id: \
return context.SingletonId;
#include "clang/Basic/WebAssemblyReferenceTypes.def"
#define AMDGPU_TYPE(Name, Id, SingletonId) \
case clang::BuiltinType::Id: \
return context.SingletonId;
#include "clang/Basic/AMDGPUTypes.def"
}

// Not a valid BuiltinType.
Expand Down Expand Up @@ -891,8 +895,8 @@ ClangTypeConverter::getClangTemplateArguments(
auto templateParam = cast<clang::TemplateTypeParmDecl>(param);
// We must have found a defaulted parameter at the end of the list.
if (templateParam->getIndex() >= genericArgs.size()) {
templateArgs.push_back(
clang::TemplateArgument(templateParam->getDefaultArgument()));
templateArgs.push_back(clang::TemplateArgument(
templateParam->getDefaultArgument().getArgument()));
continue;
}

Expand Down
2 changes: 2 additions & 0 deletions lib/AST/NameLookup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@
#include "llvm/Support/Debug.h"
#include "llvm/Support/raw_ostream.h"

#include <deque>

#define DEBUG_TYPE "namelookup"

using namespace swift;
Expand Down
1 change: 0 additions & 1 deletion lib/AST/RequirementMachine/KnuthBendix.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@
#include "llvm/Support/Debug.h"
#include "llvm/Support/raw_ostream.h"
#include <algorithm>
#include <deque>
#include <vector>

#include "RewriteContext.h"
Expand Down
84 changes: 23 additions & 61 deletions lib/ClangImporter/ClangAdapter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -364,6 +364,7 @@ OmissionTypeName importer::getClangTypeNameForOmission(clang::ASTContext &ctx,
case clang::BuiltinType::Overload:
case clang::BuiltinType::PseudoObject:
case clang::BuiltinType::UnknownAny:
case clang::BuiltinType::UnresolvedTemplate:
return OmissionTypeName();

// FIXME: Types that can be mapped, but aren't yet.
Expand Down Expand Up @@ -407,87 +408,48 @@ OmissionTypeName importer::getClangTypeNameForOmission(clang::ASTContext &ctx,
case clang::BuiltinType::ObjCSel:
return OmissionTypeName();

// OpenCL types that don't have Swift equivalents.
case clang::BuiltinType::OCLImage1dRO:
case clang::BuiltinType::OCLImage1dRW:
case clang::BuiltinType::OCLImage1dWO:
case clang::BuiltinType::OCLImage1dArrayRO:
case clang::BuiltinType::OCLImage1dArrayRW:
case clang::BuiltinType::OCLImage1dArrayWO:
case clang::BuiltinType::OCLImage1dBufferRO:
case clang::BuiltinType::OCLImage1dBufferRW:
case clang::BuiltinType::OCLImage1dBufferWO:
case clang::BuiltinType::OCLImage2dRO:
case clang::BuiltinType::OCLImage2dRW:
case clang::BuiltinType::OCLImage2dWO:
case clang::BuiltinType::OCLImage2dArrayRO:
case clang::BuiltinType::OCLImage2dArrayRW:
case clang::BuiltinType::OCLImage2dArrayWO:
case clang::BuiltinType::OCLImage2dDepthRO:
case clang::BuiltinType::OCLImage2dDepthRW:
case clang::BuiltinType::OCLImage2dDepthWO:
case clang::BuiltinType::OCLImage2dArrayDepthRO:
case clang::BuiltinType::OCLImage2dArrayDepthRW:
case clang::BuiltinType::OCLImage2dArrayDepthWO:
case clang::BuiltinType::OCLImage2dMSAARO:
case clang::BuiltinType::OCLImage2dMSAARW:
case clang::BuiltinType::OCLImage2dMSAAWO:
case clang::BuiltinType::OCLImage2dArrayMSAARO:
case clang::BuiltinType::OCLImage2dArrayMSAARW:
case clang::BuiltinType::OCLImage2dArrayMSAAWO:
case clang::BuiltinType::OCLImage2dMSAADepthRO:
case clang::BuiltinType::OCLImage2dMSAADepthRW:
case clang::BuiltinType::OCLImage2dMSAADepthWO:
case clang::BuiltinType::OCLImage2dArrayMSAADepthRO:
case clang::BuiltinType::OCLImage2dArrayMSAADepthRW:
case clang::BuiltinType::OCLImage2dArrayMSAADepthWO:
case clang::BuiltinType::OCLImage3dRO:
case clang::BuiltinType::OCLImage3dRW:
case clang::BuiltinType::OCLImage3dWO:
case clang::BuiltinType::OCLSampler:
case clang::BuiltinType::OCLEvent:
case clang::BuiltinType::OCLClkEvent:
case clang::BuiltinType::OCLQueue:
case clang::BuiltinType::OCLReserveID:
case clang::BuiltinType::OCLIntelSubgroupAVCMcePayload:
case clang::BuiltinType::OCLIntelSubgroupAVCImePayload:
case clang::BuiltinType::OCLIntelSubgroupAVCRefPayload:
case clang::BuiltinType::OCLIntelSubgroupAVCSicPayload:
case clang::BuiltinType::OCLIntelSubgroupAVCMceResult:
case clang::BuiltinType::OCLIntelSubgroupAVCImeResult:
case clang::BuiltinType::OCLIntelSubgroupAVCRefResult:
case clang::BuiltinType::OCLIntelSubgroupAVCSicResult:
case clang::BuiltinType::OCLIntelSubgroupAVCImeResultSingleReferenceStreamout:
case clang::BuiltinType::OCLIntelSubgroupAVCImeResultDualReferenceStreamout:
case clang::BuiltinType::OCLIntelSubgroupAVCImeSingleReferenceStreamin:
case clang::BuiltinType::OCLIntelSubgroupAVCImeDualReferenceStreamin:
return OmissionTypeName();

// OpenMP types that don't have Swift equivalents.
case clang::BuiltinType::OMPArraySection:
case clang::BuiltinType::ArraySection:
case clang::BuiltinType::OMPArrayShaping:
case clang::BuiltinType::OMPIterator:
return OmissionTypeName();

// OpenCL builtin types that don't have Swift equivalents.
case clang::BuiltinType::OCLClkEvent:
case clang::BuiltinType::OCLEvent:
case clang::BuiltinType::OCLSampler:
case clang::BuiltinType::OCLQueue:
case clang::BuiltinType::OCLReserveID:
#define IMAGE_TYPE(Name, Id, ...) case clang::BuiltinType::Id:
#include "clang/Basic/OpenCLImageTypes.def"
#define EXT_OPAQUE_TYPE(Name, Id, ...) case clang::BuiltinType::Id:
#include "clang/Basic/OpenCLExtensionTypes.def"
return OmissionTypeName();

// ARM SVE builtin types that don't have Swift equivalents.
#define SVE_TYPE(Name, Id, ...) case clang::BuiltinType::Id:
#include "clang/Basic/AArch64SVEACLETypes.def"
return OmissionTypeName();

// PPC MMA builtin types that don't have Swift equivalents.
#define PPC_VECTOR_TYPE(Name, Id, Size) case clang::BuiltinType::Id:
#define PPC_VECTOR_TYPE(Name, Id, ...) case clang::BuiltinType::Id:
#include "clang/Basic/PPCTypes.def"
return OmissionTypeName();

// RISC-V V builtin types that don't have Swift equivalents.
#define RVV_TYPE(Name, Id, Size) case clang::BuiltinType::Id:
#define RVV_TYPE(Name, Id, ...) case clang::BuiltinType::Id:
#include "clang/Basic/RISCVVTypes.def"
return OmissionTypeName();

// WAM builtin types that don't have Swift equivalents.
#define WASM_TYPE(Name, Id, Size) case clang::BuiltinType::Id:
// WASM builtin types that don't have Swift equivalents.
#define WASM_TYPE(Name, Id, ...) case clang::BuiltinType::Id:
#include "clang/Basic/WebAssemblyReferenceTypes.def"
return OmissionTypeName();

// AMDGPU builtins that don't have Swift equivalents.
#define AMDGPU_TYPE(Name, Id, ...) case clang::BuiltinType::Id:
#include "clang/Basic/AMDGPUTypes.def"
return OmissionTypeName();
}
}

Expand Down
25 changes: 13 additions & 12 deletions lib/ClangImporter/ClangImporter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1510,18 +1510,18 @@ ClangImporter::create(ASTContext &ctx,
importer->Impl.objectAtIndexedSubscript
= clangContext.Selectors.getUnarySelector(
&clangContext.Idents.get("objectAtIndexedSubscript"));
clang::IdentifierInfo *setObjectAtIndexedSubscriptIdents[2] = {
&clangContext.Idents.get("setObject"),
&clangContext.Idents.get("atIndexedSubscript")
const clang::IdentifierInfo *setObjectAtIndexedSubscriptIdents[2] = {
&clangContext.Idents.get("setObject"),
&clangContext.Idents.get("atIndexedSubscript"),
};
importer->Impl.setObjectAtIndexedSubscript
= clangContext.Selectors.getSelector(2, setObjectAtIndexedSubscriptIdents);
importer->Impl.objectForKeyedSubscript
= clangContext.Selectors.getUnarySelector(
&clangContext.Idents.get("objectForKeyedSubscript"));
clang::IdentifierInfo *setObjectForKeyedSubscriptIdents[2] = {
&clangContext.Idents.get("setObject"),
&clangContext.Idents.get("forKeyedSubscript")
const clang::IdentifierInfo *setObjectForKeyedSubscriptIdents[2] = {
&clangContext.Idents.get("setObject"),
&clangContext.Idents.get("forKeyedSubscript"),
};
importer->Impl.setObjectForKeyedSubscript
= clangContext.Selectors.getSelector(2, setObjectForKeyedSubscriptIdents);
Expand Down Expand Up @@ -2882,7 +2882,7 @@ ClangImporter::Implementation::exportSelector(DeclName name,

clang::ASTContext &ctx = getClangASTContext();

SmallVector<clang::IdentifierInfo *, 8> pieces;
SmallVector<const clang::IdentifierInfo *, 8> pieces;
pieces.push_back(exportName(name.getBaseIdentifier()).getAsIdentifierInfo());

auto argNames = name.getArgumentNames();
Expand All @@ -2901,7 +2901,7 @@ ClangImporter::Implementation::exportSelector(DeclName name,

clang::Selector
ClangImporter::Implementation::exportSelector(ObjCSelector selector) {
SmallVector<clang::IdentifierInfo *, 4> pieces;
SmallVector<const clang::IdentifierInfo *, 4> pieces;
for (auto piece : selector.getSelectorPieces())
pieces.push_back(exportName(piece).getAsIdentifierInfo());
return getClangASTContext().Selectors.getSelector(selector.getNumArgs(),
Expand All @@ -2917,7 +2917,7 @@ isPotentiallyConflictingSetter(const clang::ObjCProtocolDecl *proto,
if (sel.getNumArgs() != 1)
return false;

clang::IdentifierInfo *setterID = sel.getIdentifierInfoForSlot(0);
const clang::IdentifierInfo *setterID = sel.getIdentifierInfoForSlot(0);
if (!setterID || !setterID->getName().starts_with("set"))
return false;

Expand Down Expand Up @@ -3951,11 +3951,12 @@ void ClangModuleUnit::lookupObjCMethods(
// Collect all of the Objective-C methods with this selector.
SmallVector<clang::ObjCMethodDecl *, 8> objcMethods;
auto &clangSema = owner.getClangSema();
clangSema.CollectMultipleMethodsInGlobalPool(clangSelector,
auto &clangObjc = clangSema.ObjC();
clangObjc.CollectMultipleMethodsInGlobalPool(clangSelector,
objcMethods,
/*InstanceFirst=*/true,
/*CheckTheOther=*/false);
clangSema.CollectMultipleMethodsInGlobalPool(clangSelector,
clangObjc.CollectMultipleMethodsInGlobalPool(clangSelector,
objcMethods,
/*InstanceFirst=*/false,
/*CheckTheOther=*/false);
Expand Down Expand Up @@ -7893,7 +7894,7 @@ bool importer::requiresCPlusPlus(const clang::Module *module) {
}

return llvm::any_of(module->Requirements, [](clang::Module::Requirement req) {
return req.first == "cplusplus";
return req.FeatureName == "cplusplus";
});
}

Expand Down
9 changes: 5 additions & 4 deletions lib/ClangImporter/ImportDecl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2237,7 +2237,7 @@ namespace {

// Unnamed bitfields are just for padding and should not
// inhibit creation of a memberwise initializer.
if (field->isUnnamedBitfield()) {
if (field->isUnnamedBitField()) {
hasUnreferenceableStorage = true;
continue;
}
Expand Down Expand Up @@ -3457,8 +3457,9 @@ namespace {
// parameters when the function template is instantiated, so do not
// import the function template if the template parameter has
// dependent default value.
auto defaultArgumentType = templateTypeParam->getDefaultArgument();
if (defaultArgumentType->isDependentType())
auto &defaultArgument =
templateTypeParam->getDefaultArgument().getArgument();
if (defaultArgument.isDependent())
return nullptr;
continue;
}
Expand Down Expand Up @@ -9212,7 +9213,7 @@ void ClangImporter::Implementation::loadAllMembersOfRecordDecl(

// Currently, we don't import unnamed bitfields.
if (isa<clang::FieldDecl>(m) &&
cast<clang::FieldDecl>(m)->isUnnamedBitfield())
cast<clang::FieldDecl>(m)->isUnnamedBitField())
continue;

// Make sure we always pull in record fields. Everything else had better
Expand Down
2 changes: 1 addition & 1 deletion lib/ClangImporter/ImportName.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1431,7 +1431,7 @@ bool NameImporter::hasErrorMethodNameCollision(
unsigned numArgs = selector.getNumArgs();
assert(numArgs > 0);

SmallVector<clang::IdentifierInfo *, 4> chunks;
SmallVector<const clang::IdentifierInfo *, 4> chunks;
for (unsigned i = 0, e = selector.getNumArgs(); i != e; ++i) {
chunks.push_back(selector.getIdentifierInfoForSlot(i));
}
Expand Down
Loading