Skip to content

[Basic] Include SmallVector.h for Clang <= 5 #60426

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 2 commits into from
Aug 10, 2022
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
8 changes: 8 additions & 0 deletions include/swift/Basic/LLVM.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,14 @@
// None.h includes an enumerator that is desired & cannot be forward declared
// without a definition of NoneType.
#include "llvm/ADT/None.h"
#if defined(__clang_major__) && __clang_major__ < 6
// Add this header as a workaround to prevent `too few template arguments for
// class template 'SmallVector'` on the buggy Clang 5 compiler (it doesn't
// merge template arguments correctly). Remove once the CentOS 7 job is
// replaced.
// rdar://98218902
#include "llvm/ADT/SmallVector.h"
#endif

// Don't pre-declare certain LLVM types in the runtime, which must
// not put things in namespace llvm for ODR reasons.
Expand Down
2 changes: 1 addition & 1 deletion lib/AST/RequirementMachine/ConcreteContraction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,7 @@ Optional<Type> ConcreteContraction::substTypeParameterRec(

// An unresolved DependentMemberType stores an identifier. Handle this
// by performing a name lookup into the base type.
SmallVector<TypeDecl *, 2> concreteDecls;
SmallVector<TypeDecl *> concreteDecls;
lookupConcreteNestedType(*substBaseType, memberType->getName(), concreteDecls);

auto *typeDecl = findBestConcreteNestedType(concreteDecls);
Expand Down
2 changes: 1 addition & 1 deletion lib/AST/Type.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -882,7 +882,7 @@ Type TypeBase::lookThroughAllOptionalTypes(SmallVectorImpl<Type> &optionals){
}

unsigned int TypeBase::getOptionalityDepth() {
SmallVector<Type, 4> types;
SmallVector<Type> types;
lookThroughAllOptionalTypes(types);
return types.size();
}
Expand Down
2 changes: 1 addition & 1 deletion lib/ClangImporter/ClangDerivedConformances.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ static ValueDecl *getEqualEqualOperator(NominalTypeDecl *decl) {
// If no member `func ==` was found, look for out-of-class definitions in the
// same module.
auto module = decl->getModuleContext();
llvm::SmallVector<ValueDecl *> nonMemberResults;
SmallVector<ValueDecl *> nonMemberResults;
module->lookupValue(id, NLKind::UnqualifiedLookup, nonMemberResults);
for (const auto &nonMember : nonMemberResults) {
if (isValid(nonMember))
Expand Down
2 changes: 1 addition & 1 deletion lib/DriverTool/swift_symbolgraph_extract_main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ int swift_symbolgraph_extract_main(ArrayRef<const char *> Args,
// don't need to print these errors.
CI.removeDiagnosticConsumer(&DiagPrinter);

SmallVector<ModuleDecl *, 8> Overlays;
SmallVector<ModuleDecl *> Overlays;
M->findDeclaredCrossImportOverlaysTransitive(Overlays);
for (const auto *OM : Overlays) {
auto CIM = CI.getASTContext().getModuleByName(OM->getNameStr());
Expand Down
4 changes: 2 additions & 2 deletions lib/IRGen/IRGenModule.h
Original file line number Diff line number Diff line change
Expand Up @@ -777,7 +777,7 @@ class IRGenModule {

#ifdef CHECK_RUNTIME_EFFECT_ANALYSIS
RuntimeEffect effectOfRuntimeFuncs = RuntimeEffect::NoEffect;
llvm::SmallVector<const char *> emittedRuntimeFuncs;
SmallVector<const char *> emittedRuntimeFuncs;

void registerRuntimeEffect(ArrayRef<RuntimeEffect> realtime,
const char *funcName);
Expand Down Expand Up @@ -1263,7 +1263,7 @@ class IRGenModule {
void emitLazyObjCProtocolDefinitions();
void emitLazyObjCProtocolDefinition(ProtocolDecl *proto);

llvm::SmallVector<llvm::MDNode *> UsedConditionals;
SmallVector<llvm::MDNode *> UsedConditionals;
void emitUsedConditionals();

void emitGlobalLists();
Expand Down
2 changes: 1 addition & 1 deletion lib/SIL/IR/SILArgument.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ bool SILPhiArgument::visitTransitiveIncomingPhiOperands(
worklist.initialize(this);

while (auto *argument = worklist.pop()) {
llvm::SmallVector<Operand *> operands;
SmallVector<Operand *> operands;
argument->getIncomingPhiOperands(operands);

for (auto *operand : operands) {
Expand Down
4 changes: 2 additions & 2 deletions lib/SILOptimizer/Transforms/SILMem2Reg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -919,7 +919,7 @@ void StackAllocationPromoter::fixPhiPredBlock(BlockSetVector &phiBlocks,

LLVM_DEBUG(llvm::dbgs() << "*** Found the definition: " << def.stored);

llvm::SmallVector<SILValue> vals;
SmallVector<SILValue> vals;
vals.push_back(def.stored);
if (shouldAddLexicalLifetime(asi)) {
vals.push_back(def.borrow);
Expand Down Expand Up @@ -964,7 +964,7 @@ void StackAllocationPromoter::propagateLiveness(
// If liveness has not been propagated, go over the incoming operands and mark
// any operand values that are proactivePhis as live
livePhis.insert(proactivePhi);
SmallVector<SILValue, 4> incomingPhiVals;
SmallVector<SILValue> incomingPhiVals;
proactivePhi->getIncomingPhiValues(incomingPhiVals);
for (auto &inVal : incomingPhiVals) {
auto *inPhi = dyn_cast<SILPhiArgument>(inVal);
Expand Down
2 changes: 1 addition & 1 deletion lib/Sema/BuilderTransform.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1355,7 +1355,7 @@ class ResultBuilderTransform
}
} else {
auto *elseBraceStmt = cast<BraceStmt>(elseStmt);
SmallVector<ASTNode, 4> elseBody;
SmallVector<ASTNode> elseBody;

std::tie(elseVar, unsupported) = transform(elseBraceStmt, elseBody);
if (unsupported) {
Expand Down
2 changes: 1 addition & 1 deletion lib/Sema/CSClosure.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ Expr *getVoidExpr(ASTContext &ctx, SourceLoc contextLoc = SourceLoc()) {
/// Find any type variable references inside of an AST node.
class TypeVariableRefFinder : public ASTWalker {
/// A stack of all closures the walker encountered so far.
SmallVector<DeclContext *, 2> ClosureDCs;
SmallVector<DeclContext *> ClosureDCs;

ConstraintSystem &CS;
ASTNode Parent;
Expand Down
2 changes: 1 addition & 1 deletion tools/swift-refactor/swift-refactor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -449,7 +449,7 @@ int main(int argc, char *argv[]) {
return 1;
}

SmallVector<std::unique_ptr<SourceEditConsumer>, 32> Consumers;
Copy link
Contributor

Choose a reason for hiding this comment

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

The default here would be quite a bit smaller, if it matters.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I believe the only place it's added to is below. So technically this could be 2 if we really cared, but given this is just a testing tool and not even remotely hot 🤷

SmallVector<std::unique_ptr<SourceEditConsumer>> Consumers;
if (!options::RewrittenOutputFile.empty() ||
options::DumpIn == options::DumpType::REWRITTEN) {
Consumers.emplace_back(new SourceEditOutputConsumer(
Expand Down