NetBSD re-synchronization of the source tree

This brings our tree to NetBSD 7.0, as found on -current on the
10-10-2015.

This updates:
 - LLVM to 3.6.1
 - GCC to GCC 5.1
 - Replace minix/commands/zdump with usr.bin/zdump
 - external/bsd/libelf has moved to /external/bsd/elftoolchain/
 - Import ctwm
 - Drop sprintf from libminc

Change-Id: I149836ac18e9326be9353958bab9b266efb056f0
This commit is contained in:
2015-10-15 17:01:16 +02:00
parent 8933525b85
commit 0a6a1f1d05
32425 changed files with 2998623 additions and 1342348 deletions

View File

@@ -11,13 +11,14 @@
// modules for the ASTReader.
//
//===----------------------------------------------------------------------===//
#include "clang/Lex/HeaderSearch.h"
#include "clang/Lex/ModuleMap.h"
#include "clang/Serialization/GlobalModuleIndex.h"
#include "clang/Serialization/ModuleManager.h"
#include "llvm/Support/MemoryBuffer.h"
#include "llvm/Support/Path.h"
#include "llvm/Support/raw_ostream.h"
#include "llvm/Support/system_error.h"
#include <system_error>
#ifndef NDEBUG
#include "llvm/Support/GraphWriter.h"
@@ -32,22 +33,23 @@ ModuleFile *ModuleManager::lookup(StringRef Name) {
if (Entry)
return lookup(Entry);
return 0;
return nullptr;
}
ModuleFile *ModuleManager::lookup(const FileEntry *File) {
llvm::DenseMap<const FileEntry *, ModuleFile *>::iterator Known
= Modules.find(File);
if (Known == Modules.end())
return 0;
return nullptr;
return Known->second;
}
llvm::MemoryBuffer *ModuleManager::lookupBuffer(StringRef Name) {
std::unique_ptr<llvm::MemoryBuffer>
ModuleManager::lookupBuffer(StringRef Name) {
const FileEntry *Entry = FileMgr.getFile(Name, /*openFile=*/false,
/*cacheFailure=*/false);
return InMemoryBuffers[Entry];
return std::move(InMemoryBuffers[Entry]);
}
ModuleManager::AddModuleResult
@@ -55,13 +57,23 @@ ModuleManager::addModule(StringRef FileName, ModuleKind Type,
SourceLocation ImportLoc, ModuleFile *ImportedBy,
unsigned Generation,
off_t ExpectedSize, time_t ExpectedModTime,
ASTFileSignature ExpectedSignature,
std::function<ASTFileSignature(llvm::BitstreamReader &)>
ReadSignature,
ModuleFile *&Module,
std::string &ErrorStr) {
Module = 0;
Module = nullptr;
// Look for the file entry. This only fails if the expected size or
// modification time differ.
const FileEntry *Entry;
if (Type == MK_ExplicitModule) {
// If we're not expecting to pull this file out of the module cache, it
// might have a different mtime due to being moved across filesystems in
// a distributed build. The size must still match, though. (As must the
// contents, but we can't check that.)
ExpectedModTime = 0;
}
if (lookupModuleFile(FileName, ExpectedSize, ExpectedModTime, Entry)) {
ErrorStr = "module file out of date";
return OutOfDate;
@@ -86,29 +98,70 @@ ModuleManager::addModule(StringRef FileName, ModuleKind Type,
NewModule = true;
ModuleEntry = New;
New->InputFilesValidationTimestamp = 0;
if (New->Kind == MK_ImplicitModule) {
std::string TimestampFilename = New->getTimestampFilename();
vfs::Status Status;
// A cached stat value would be fine as well.
if (!FileMgr.getNoncachedStatValue(TimestampFilename, Status))
New->InputFilesValidationTimestamp =
Status.getLastModificationTime().toEpochTime();
}
// Load the contents of the module
if (llvm::MemoryBuffer *Buffer = lookupBuffer(FileName)) {
if (std::unique_ptr<llvm::MemoryBuffer> Buffer = lookupBuffer(FileName)) {
// The buffer was already provided for us.
assert(Buffer && "Passed null buffer");
New->Buffer.reset(Buffer);
New->Buffer = std::move(Buffer);
} else {
// Open the AST file.
llvm::error_code ec;
llvm::ErrorOr<std::unique_ptr<llvm::MemoryBuffer>> Buf(
(std::error_code()));
if (FileName == "-") {
ec = llvm::MemoryBuffer::getSTDIN(New->Buffer);
if (ec)
ErrorStr = ec.message();
} else
New->Buffer.reset(FileMgr.getBufferForFile(FileName, &ErrorStr));
if (!New->Buffer)
Buf = llvm::MemoryBuffer::getSTDIN();
} else {
// Leave the FileEntry open so if it gets read again by another
// ModuleManager it must be the same underlying file.
// FIXME: Because FileManager::getFile() doesn't guarantee that it will
// give us an open file, this may not be 100% reliable.
Buf = FileMgr.getBufferForFile(New->File,
/*IsVolatile=*/false,
/*ShouldClose=*/false);
}
if (!Buf) {
ErrorStr = Buf.getError().message();
return Missing;
}
New->Buffer = std::move(*Buf);
}
// Initialize the stream
New->StreamFile.init((const unsigned char *)New->Buffer->getBufferStart(),
(const unsigned char *)New->Buffer->getBufferEnd());
}
if (ExpectedSignature) {
if (NewModule)
ModuleEntry->Signature = ReadSignature(ModuleEntry->StreamFile);
else
assert(ModuleEntry->Signature == ReadSignature(ModuleEntry->StreamFile));
if (ModuleEntry->Signature != ExpectedSignature) {
ErrorStr = ModuleEntry->Signature ? "signature mismatch"
: "could not read module signature";
if (NewModule) {
// Remove the module file immediately, since removeModules might try to
// invalidate the file cache for Entry, and that is not safe if this
// module is *itself* up to date, but has an out-of-date importer.
Modules.erase(Entry);
Chain.pop_back();
delete ModuleEntry;
}
return OutOfDate;
}
}
if (ImportedBy) {
ModuleEntry->ImportedBy.insert(ImportedBy);
@@ -124,24 +177,10 @@ ModuleManager::addModule(StringRef FileName, ModuleKind Type,
return NewModule? NewlyLoaded : AlreadyLoaded;
}
namespace {
/// \brief Predicate that checks whether a module file occurs within
/// the given set.
class IsInModuleFileSet : public std::unary_function<ModuleFile *, bool> {
llvm::SmallPtrSet<ModuleFile *, 4> &Removed;
public:
IsInModuleFileSet(llvm::SmallPtrSet<ModuleFile *, 4> &Removed)
: Removed(Removed) { }
bool operator()(ModuleFile *MF) const {
return Removed.count(MF);
}
};
}
void ModuleManager::removeModules(ModuleIterator first, ModuleIterator last,
ModuleMap *modMap) {
void ModuleManager::removeModules(
ModuleIterator first, ModuleIterator last,
llvm::SmallPtrSetImpl<ModuleFile *> &LoadedSuccessfully,
ModuleMap *modMap) {
if (first == last)
return;
@@ -149,22 +188,29 @@ void ModuleManager::removeModules(ModuleIterator first, ModuleIterator last,
llvm::SmallPtrSet<ModuleFile *, 4> victimSet(first, last);
// Remove any references to the now-destroyed modules.
IsInModuleFileSet checkInSet(victimSet);
for (unsigned i = 0, n = Chain.size(); i != n; ++i) {
Chain[i]->ImportedBy.remove_if(checkInSet);
Chain[i]->ImportedBy.remove_if([&](ModuleFile *MF) {
return victimSet.count(MF);
});
}
// Delete the modules and erase them from the various structures.
for (ModuleIterator victim = first; victim != last; ++victim) {
Modules.erase((*victim)->File);
FileMgr.invalidateCache((*victim)->File);
if (modMap) {
StringRef ModuleName = llvm::sys::path::stem((*victim)->FileName);
StringRef ModuleName = (*victim)->ModuleName;
if (Module *mod = modMap->findModule(ModuleName)) {
mod->setASTFile(0);
mod->setASTFile(nullptr);
}
}
// Files that didn't make it through ReadASTCore successfully will be
// rebuilt (or there was an error). Invalidate them so that we can load the
// new files that will be renamed over the old ones.
if (LoadedSuccessfully.count(*victim) == 0)
FileMgr.invalidateCache((*victim)->File);
delete *victim;
}
@@ -172,12 +218,13 @@ void ModuleManager::removeModules(ModuleIterator first, ModuleIterator last,
Chain.erase(first, last);
}
void ModuleManager::addInMemoryBuffer(StringRef FileName,
llvm::MemoryBuffer *Buffer) {
const FileEntry *Entry = FileMgr.getVirtualFile(FileName,
Buffer->getBufferSize(), 0);
InMemoryBuffers[Entry] = Buffer;
void
ModuleManager::addInMemoryBuffer(StringRef FileName,
std::unique_ptr<llvm::MemoryBuffer> Buffer) {
const FileEntry *Entry =
FileMgr.getVirtualFile(FileName, Buffer->getBufferSize(), 0);
InMemoryBuffers[Entry] = std::move(Buffer);
}
ModuleManager::VisitState *ModuleManager::allocateVisitState() {
@@ -185,7 +232,7 @@ ModuleManager::VisitState *ModuleManager::allocateVisitState() {
if (FirstVisitState) {
VisitState *Result = FirstVisitState;
FirstVisitState = FirstVisitState->NextState;
Result->NextState = 0;
Result->NextState = nullptr;
return Result;
}
@@ -194,7 +241,7 @@ ModuleManager::VisitState *ModuleManager::allocateVisitState() {
}
void ModuleManager::returnVisitState(VisitState *State) {
assert(State->NextState == 0 && "Visited state is in list?");
assert(State->NextState == nullptr && "Visited state is in list?");
State->NextState = FirstVisitState;
FirstVisitState = State;
}
@@ -223,7 +270,7 @@ void ModuleManager::moduleFileAccepted(ModuleFile *MF) {
}
ModuleManager::ModuleManager(FileManager &FileMgr)
: FileMgr(FileMgr), GlobalIndex(), FirstVisitState(0) { }
: FileMgr(FileMgr), GlobalIndex(), FirstVisitState(nullptr) {}
ModuleManager::~ModuleManager() {
for (unsigned i = 0, e = Chain.size(); i != e; ++i)
@@ -234,7 +281,7 @@ ModuleManager::~ModuleManager() {
void
ModuleManager::visit(bool (*Visitor)(ModuleFile &M, void *UserData),
void *UserData,
llvm::SmallPtrSet<ModuleFile *, 4> *ModuleFilesHit) {
llvm::SmallPtrSetImpl<ModuleFile *> *ModuleFilesHit) {
// If the visitation order vector is the wrong size, recompute the order.
if (VisitOrder.size() != Chain.size()) {
unsigned N = size();
@@ -283,7 +330,7 @@ ModuleManager::visit(bool (*Visitor)(ModuleFile &M, void *UserData),
assert(VisitOrder.size() == N && "Visitation order is wrong?");
delete FirstVisitState;
FirstVisitState = 0;
FirstVisitState = nullptr;
}
VisitState *State = allocateVisitState();
@@ -385,16 +432,19 @@ bool ModuleManager::lookupModuleFile(StringRef FileName,
off_t ExpectedSize,
time_t ExpectedModTime,
const FileEntry *&File) {
File = FileMgr.getFile(FileName, /*openFile=*/false, /*cacheFailure=*/false);
// Open the file immediately to ensure there is no race between stat'ing and
// opening the file.
File = FileMgr.getFile(FileName, /*openFile=*/true, /*cacheFailure=*/false);
if (!File && FileName != "-") {
return false;
}
if ((ExpectedSize && ExpectedSize != File->getSize()) ||
(ExpectedModTime && ExpectedModTime != File->getModificationTime())) {
(ExpectedModTime && ExpectedModTime != File->getModificationTime()))
// Do not destroy File, as it may be referenced. If we need to rebuild it,
// it will be destroyed by removeModules.
return true;
}
return false;
}
@@ -434,7 +484,7 @@ namespace llvm {
}
std::string getNodeLabel(ModuleFile *M, const ModuleManager&) {
return llvm::sys::path::stem(M->FileName);
return M->ModuleName;
}
};
}