Fix a few more cases of ArrayRef problems.

This is another problem (like 5356cc3) exposed by building with a newer
version of Clang. Construct a temporary SmallVector when needed to create
an ArrayRef.
This commit is contained in:
Bob Wilson
2016-10-10 08:29:01 -07:00
parent 1a18c9417c
commit 8ac3815cb1

View File

@@ -3757,7 +3757,14 @@ static void writeDeclCommentTable(
DeclCommentTableWriter Writer(GroupContext); DeclCommentTableWriter Writer(GroupContext);
ArrayRef<const FileUnit *> files = SF ? SF : M->getFiles(); ArrayRef<const FileUnit *> files;
SmallVector<const FileUnit *, 1> Scratch;
if (SF) {
Scratch.push_back(SF);
files = llvm::makeArrayRef(Scratch);
} else {
files = M->getFiles();
}
for (auto nextFile : files) { for (auto nextFile : files) {
Writer.resetSourceOrder(); Writer.resetSourceOrder();
const_cast<FileUnit *>(nextFile)->walk(Writer); const_cast<FileUnit *>(nextFile)->walk(Writer);
@@ -3923,7 +3930,14 @@ void Serializer::writeAST(ModuleOrSourceFile DC) {
Optional<DeclID> entryPointClassID; Optional<DeclID> entryPointClassID;
ArrayRef<const FileUnit *> files = SF ? SF : M->getFiles(); ArrayRef<const FileUnit *> files;
SmallVector<const FileUnit *, 1> Scratch;
if (SF) {
Scratch.push_back(SF);
files = llvm::makeArrayRef(Scratch);
} else {
files = M->getFiles();
}
for (auto nextFile : files) { for (auto nextFile : files) {
if (nextFile->hasEntryPoint()) if (nextFile->hasEntryPoint())
entryPointClassID = addDeclRef(nextFile->getMainClass()); entryPointClassID = addDeclRef(nextFile->getMainClass());