Skip to content

Commit a59fa46

Browse files
authored
Merge pull request #60426 from bnbarham/include-smallvec
[Basic] Include SmallVector.h for Clang <= 5
2 parents cfe5566 + 6de34f3 commit a59fa46

File tree

11 files changed

+20
-12
lines changed

11 files changed

+20
-12
lines changed

include/swift/Basic/LLVM.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,14 @@
2525
// None.h includes an enumerator that is desired & cannot be forward declared
2626
// without a definition of NoneType.
2727
#include "llvm/ADT/None.h"
28+
#if defined(__clang_major__) && __clang_major__ < 6
29+
// Add this header as a workaround to prevent `too few template arguments for
30+
// class template 'SmallVector'` on the buggy Clang 5 compiler (it doesn't
31+
// merge template arguments correctly). Remove once the CentOS 7 job is
32+
// replaced.
33+
// rdar://98218902
34+
#include "llvm/ADT/SmallVector.h"
35+
#endif
2836

2937
// Don't pre-declare certain LLVM types in the runtime, which must
3038
// not put things in namespace llvm for ODR reasons.

lib/AST/RequirementMachine/ConcreteContraction.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -301,7 +301,7 @@ Optional<Type> ConcreteContraction::substTypeParameterRec(
301301

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

307307
auto *typeDecl = findBestConcreteNestedType(concreteDecls);

lib/AST/Type.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -882,7 +882,7 @@ Type TypeBase::lookThroughAllOptionalTypes(SmallVectorImpl<Type> &optionals){
882882
}
883883

884884
unsigned int TypeBase::getOptionalityDepth() {
885-
SmallVector<Type, 4> types;
885+
SmallVector<Type> types;
886886
lookThroughAllOptionalTypes(types);
887887
return types.size();
888888
}

lib/ClangImporter/ClangDerivedConformances.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ static ValueDecl *getEqualEqualOperator(NominalTypeDecl *decl) {
8888
// If no member `func ==` was found, look for out-of-class definitions in the
8989
// same module.
9090
auto module = decl->getModuleContext();
91-
llvm::SmallVector<ValueDecl *> nonMemberResults;
91+
SmallVector<ValueDecl *> nonMemberResults;
9292
module->lookupValue(id, NLKind::UnqualifiedLookup, nonMemberResults);
9393
for (const auto &nonMember : nonMemberResults) {
9494
if (isValid(nonMember))

lib/DriverTool/swift_symbolgraph_extract_main.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,7 @@ int swift_symbolgraph_extract_main(ArrayRef<const char *> Args,
241241
// don't need to print these errors.
242242
CI.removeDiagnosticConsumer(&DiagPrinter);
243243

244-
SmallVector<ModuleDecl *, 8> Overlays;
244+
SmallVector<ModuleDecl *> Overlays;
245245
M->findDeclaredCrossImportOverlaysTransitive(Overlays);
246246
for (const auto *OM : Overlays) {
247247
auto CIM = CI.getASTContext().getModuleByName(OM->getNameStr());

lib/IRGen/IRGenModule.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -777,7 +777,7 @@ class IRGenModule {
777777

778778
#ifdef CHECK_RUNTIME_EFFECT_ANALYSIS
779779
RuntimeEffect effectOfRuntimeFuncs = RuntimeEffect::NoEffect;
780-
llvm::SmallVector<const char *> emittedRuntimeFuncs;
780+
SmallVector<const char *> emittedRuntimeFuncs;
781781

782782
void registerRuntimeEffect(ArrayRef<RuntimeEffect> realtime,
783783
const char *funcName);
@@ -1263,7 +1263,7 @@ class IRGenModule {
12631263
void emitLazyObjCProtocolDefinitions();
12641264
void emitLazyObjCProtocolDefinition(ProtocolDecl *proto);
12651265

1266-
llvm::SmallVector<llvm::MDNode *> UsedConditionals;
1266+
SmallVector<llvm::MDNode *> UsedConditionals;
12671267
void emitUsedConditionals();
12681268

12691269
void emitGlobalLists();

lib/SIL/IR/SILArgument.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,7 @@ bool SILPhiArgument::visitTransitiveIncomingPhiOperands(
236236
worklist.initialize(this);
237237

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

242242
for (auto *operand : operands) {

lib/SILOptimizer/Transforms/SILMem2Reg.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -919,7 +919,7 @@ void StackAllocationPromoter::fixPhiPredBlock(BlockSetVector &phiBlocks,
919919

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

922-
llvm::SmallVector<SILValue> vals;
922+
SmallVector<SILValue> vals;
923923
vals.push_back(def.stored);
924924
if (shouldAddLexicalLifetime(asi)) {
925925
vals.push_back(def.borrow);
@@ -964,7 +964,7 @@ void StackAllocationPromoter::propagateLiveness(
964964
// If liveness has not been propagated, go over the incoming operands and mark
965965
// any operand values that are proactivePhis as live
966966
livePhis.insert(proactivePhi);
967-
SmallVector<SILValue, 4> incomingPhiVals;
967+
SmallVector<SILValue> incomingPhiVals;
968968
proactivePhi->getIncomingPhiValues(incomingPhiVals);
969969
for (auto &inVal : incomingPhiVals) {
970970
auto *inPhi = dyn_cast<SILPhiArgument>(inVal);

lib/Sema/BuilderTransform.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1348,7 +1348,7 @@ class ResultBuilderTransform
13481348
}
13491349
} else {
13501350
auto *elseBraceStmt = cast<BraceStmt>(elseStmt);
1351-
SmallVector<ASTNode, 4> elseBody;
1351+
SmallVector<ASTNode> elseBody;
13521352

13531353
std::tie(elseVar, unsupported) = transform(elseBraceStmt, elseBody);
13541354
if (unsupported) {

lib/Sema/CSClosure.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ Expr *getVoidExpr(ASTContext &ctx, SourceLoc contextLoc = SourceLoc()) {
4040
/// Find any type variable references inside of an AST node.
4141
class TypeVariableRefFinder : public ASTWalker {
4242
/// A stack of all closures the walker encountered so far.
43-
SmallVector<DeclContext *, 2> ClosureDCs;
43+
SmallVector<DeclContext *> ClosureDCs;
4444

4545
ConstraintSystem &CS;
4646
ASTNode Parent;

tools/swift-refactor/swift-refactor.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -449,7 +449,7 @@ int main(int argc, char *argv[]) {
449449
return 1;
450450
}
451451

452-
SmallVector<std::unique_ptr<SourceEditConsumer>, 32> Consumers;
452+
SmallVector<std::unique_ptr<SourceEditConsumer>> Consumers;
453453
if (!options::RewrittenOutputFile.empty() ||
454454
options::DumpIn == options::DumpType::REWRITTEN) {
455455
Consumers.emplace_back(new SourceEditOutputConsumer(

0 commit comments

Comments
 (0)