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

@@ -13,7 +13,7 @@
#include "ASTReaderInternals.h"
#include "clang/Basic/FileManager.h"
#include "clang/Basic/OnDiskHashTable.h"
#include "clang/Lex/HeaderSearch.h"
#include "clang/Serialization/ASTBitCodes.h"
#include "clang/Serialization/GlobalModuleIndex.h"
#include "clang/Serialization/Module.h"
@@ -26,6 +26,7 @@
#include "llvm/Support/FileSystem.h"
#include "llvm/Support/LockFileManager.h"
#include "llvm/Support/MemoryBuffer.h"
#include "llvm/Support/OnDiskHashTable.h"
#include "llvm/Support/Path.h"
#include <cstdio>
using namespace clang;
@@ -71,20 +72,22 @@ public:
typedef StringRef external_key_type;
typedef StringRef internal_key_type;
typedef SmallVector<unsigned, 2> data_type;
typedef unsigned hash_value_type;
typedef unsigned offset_type;
static bool EqualKey(const internal_key_type& a, const internal_key_type& b) {
return a == b;
}
static unsigned ComputeHash(const internal_key_type& a) {
static hash_value_type ComputeHash(const internal_key_type& a) {
return llvm::HashString(a);
}
static std::pair<unsigned, unsigned>
ReadKeyDataLength(const unsigned char*& d) {
using namespace clang::io;
unsigned KeyLen = ReadUnalignedLE16(d);
unsigned DataLen = ReadUnalignedLE16(d);
using namespace llvm::support;
unsigned KeyLen = endian::readNext<uint16_t, little, unaligned>(d);
unsigned DataLen = endian::readNext<uint16_t, little, unaligned>(d);
return std::make_pair(KeyLen, DataLen);
}
@@ -101,11 +104,11 @@ public:
static data_type ReadData(const internal_key_type& k,
const unsigned char* d,
unsigned DataLen) {
using namespace clang::io;
using namespace llvm::support;
data_type Result;
while (DataLen > 0) {
unsigned ID = ReadUnalignedLE32(d);
unsigned ID = endian::readNext<uint32_t, little, unaligned>(d);
Result.push_back(ID);
DataLen -= 4;
}
@@ -114,15 +117,15 @@ public:
}
};
typedef OnDiskChainedHashTable<IdentifierIndexReaderTrait> IdentifierIndexTable;
typedef llvm::OnDiskIterableChainedHashTable<IdentifierIndexReaderTrait>
IdentifierIndexTable;
}
GlobalModuleIndex::GlobalModuleIndex(llvm::MemoryBuffer *Buffer,
GlobalModuleIndex::GlobalModuleIndex(std::unique_ptr<llvm::MemoryBuffer> Buffer,
llvm::BitstreamCursor Cursor)
: Buffer(Buffer), IdentifierIndex(),
NumIdentifierLookups(), NumIdentifierLookupHits()
{
: Buffer(std::move(Buffer)), IdentifierIndex(), NumIdentifierLookups(),
NumIdentifierLookupHits() {
// Read the global index.
bool InGlobalIndexBlock = false;
bool Done = false;
@@ -202,7 +205,12 @@ GlobalModuleIndex::GlobalModuleIndex(llvm::MemoryBuffer *Buffer,
assert(Idx == Record.size() && "More module info?");
// Record this module as an unresolved module.
UnresolvedModules[llvm::sys::path::stem(Modules[ID].FileName)] = ID;
// FIXME: this doesn't work correctly for module names containing path
// separators.
StringRef ModuleName = llvm::sys::path::stem(Modules[ID].FileName);
// Remove the -<hash of ModuleMapPath>
ModuleName = ModuleName.rsplit('-').first;
UnresolvedModules[ModuleName] = ID;
break;
}
@@ -210,16 +218,18 @@ GlobalModuleIndex::GlobalModuleIndex(llvm::MemoryBuffer *Buffer,
// Wire up the identifier index.
if (Record[0]) {
IdentifierIndex = IdentifierIndexTable::Create(
(const unsigned char *)Blob.data() + Record[0],
(const unsigned char *)Blob.data(),
IdentifierIndexReaderTrait());
(const unsigned char *)Blob.data() + Record[0],
(const unsigned char *)Blob.data() + sizeof(uint32_t),
(const unsigned char *)Blob.data(), IdentifierIndexReaderTrait());
}
break;
}
}
}
GlobalModuleIndex::~GlobalModuleIndex() { }
GlobalModuleIndex::~GlobalModuleIndex() {
delete static_cast<IdentifierIndexTable *>(IdentifierIndex);
}
std::pair<GlobalModuleIndex *, GlobalModuleIndex::ErrorCode>
GlobalModuleIndex::readIndex(StringRef Path) {
@@ -228,10 +238,11 @@ GlobalModuleIndex::readIndex(StringRef Path) {
IndexPath += Path;
llvm::sys::path::append(IndexPath, IndexFileName);
llvm::OwningPtr<llvm::MemoryBuffer> Buffer;
if (llvm::MemoryBuffer::getFile(IndexPath.c_str(), Buffer) !=
llvm::errc::success)
return std::make_pair((GlobalModuleIndex *)0, EC_NotFound);
llvm::ErrorOr<std::unique_ptr<llvm::MemoryBuffer>> BufferOrErr =
llvm::MemoryBuffer::getFile(IndexPath.c_str());
if (!BufferOrErr)
return std::make_pair(nullptr, EC_NotFound);
std::unique_ptr<llvm::MemoryBuffer> Buffer = std::move(BufferOrErr.get());
/// \brief The bitstream reader from which we'll read the AST file.
llvm::BitstreamReader Reader((const unsigned char *)Buffer->getBufferStart(),
@@ -245,10 +256,11 @@ GlobalModuleIndex::readIndex(StringRef Path) {
Cursor.Read(8) != 'C' ||
Cursor.Read(8) != 'G' ||
Cursor.Read(8) != 'I') {
return std::make_pair((GlobalModuleIndex *)0, EC_IOError);
return std::make_pair(nullptr, EC_IOError);
}
return std::make_pair(new GlobalModuleIndex(Buffer.take(), Cursor), EC_None);
return std::make_pair(new GlobalModuleIndex(std::move(Buffer), Cursor),
EC_None);
}
void
@@ -306,7 +318,7 @@ bool GlobalModuleIndex::lookupIdentifier(StringRef Name, HitSet &Hits) {
bool GlobalModuleIndex::loadedModuleFile(ModuleFile *File) {
// Look for the module in the global module index based on the module name.
StringRef Name = llvm::sys::path::stem(File->FileName);
StringRef Name = File->ModuleName;
llvm::StringMap<unsigned>::iterator Known = UnresolvedModules.find(Name);
if (Known == UnresolvedModules.end()) {
return true;
@@ -341,6 +353,19 @@ void GlobalModuleIndex::printStats() {
std::fprintf(stderr, "\n");
}
void GlobalModuleIndex::dump() {
llvm::errs() << "*** Global Module Index Dump:\n";
llvm::errs() << "Module files:\n";
for (auto &MI : Modules) {
llvm::errs() << "** " << MI.FileName << "\n";
if (MI.File)
MI.File->dump();
else
llvm::errs() << "\n";
}
llvm::errs() << "\n";
}
//----------------------------------------------------------------------------//
// Global module index writer.
//----------------------------------------------------------------------------//
@@ -411,7 +436,7 @@ static void emitBlockID(unsigned ID, const char *Name,
Stream.EmitRecord(llvm::bitc::BLOCKINFO_CODE_SETBID, Record);
// Emit the block name if present.
if (Name == 0 || Name[0] == 0) return;
if (!Name || Name[0] == 0) return;
Record.clear();
while (*Name)
Record.push_back(*Name++);
@@ -458,8 +483,8 @@ namespace {
unsigned DataLen) {
// The first bit indicates whether this identifier is interesting.
// That's all we care about.
using namespace clang::io;
unsigned RawID = ReadUnalignedLE32(d);
using namespace llvm::support;
unsigned RawID = endian::readNext<uint32_t, little, unaligned>(d);
bool IsInteresting = RawID & 0x01;
return std::make_pair(k, IsInteresting);
}
@@ -468,19 +493,17 @@ namespace {
bool GlobalModuleIndexBuilder::loadModuleFile(const FileEntry *File) {
// Open the module file.
OwningPtr<llvm::MemoryBuffer> Buffer;
std::string ErrorStr;
Buffer.reset(FileMgr.getBufferForFile(File, &ErrorStr, /*isVolatile=*/true));
auto Buffer = FileMgr.getBufferForFile(File, /*isVolatile=*/true);
if (!Buffer) {
return true;
}
// Initialize the input stream
llvm::BitstreamReader InStreamFile;
llvm::BitstreamCursor InStream;
InStreamFile.init((const unsigned char *)Buffer->getBufferStart(),
(const unsigned char *)Buffer->getBufferEnd());
InStream.init(InStreamFile);
InStreamFile.init((const unsigned char *)(*Buffer)->getBufferStart(),
(const unsigned char *)(*Buffer)->getBufferEnd());
llvm::BitstreamCursor InStream(InStreamFile);
// Sniff for the signature.
if (InStream.Read(8) != 'C' ||
@@ -565,6 +588,10 @@ bool GlobalModuleIndexBuilder::loadModuleFile(const FileEntry *File) {
off_t StoredSize = (off_t)Record[Idx++];
time_t StoredModTime = (time_t)Record[Idx++];
// Skip the stored signature.
// FIXME: we could read the signature out of the import and validate it.
Idx++;
// Retrieve the imported file name.
unsigned Length = Record[Idx++];
SmallString<128> ImportedFile(Record.begin() + Idx,
@@ -590,12 +617,13 @@ bool GlobalModuleIndexBuilder::loadModuleFile(const FileEntry *File) {
// Handle the identifier table
if (State == ASTBlock && Code == IDENTIFIER_TABLE && Record[0] > 0) {
typedef OnDiskChainedHashTable<InterestingASTIdentifierLookupTrait>
InterestingIdentifierTable;
llvm::OwningPtr<InterestingIdentifierTable>
Table(InterestingIdentifierTable::Create(
(const unsigned char *)Blob.data() + Record[0],
(const unsigned char *)Blob.data()));
typedef llvm::OnDiskIterableChainedHashTable<
InterestingASTIdentifierLookupTrait> InterestingIdentifierTable;
std::unique_ptr<InterestingIdentifierTable> Table(
InterestingIdentifierTable::Create(
(const unsigned char *)Blob.data() + Record[0],
(const unsigned char *)Blob.data() + sizeof(uint32_t),
(const unsigned char *)Blob.data()));
for (InterestingIdentifierTable::data_iterator D = Table->data_begin(),
DEnd = Table->data_end();
D != DEnd; ++D) {
@@ -623,17 +651,21 @@ public:
typedef StringRef key_type_ref;
typedef SmallVector<unsigned, 2> data_type;
typedef const SmallVector<unsigned, 2> &data_type_ref;
typedef unsigned hash_value_type;
typedef unsigned offset_type;
static unsigned ComputeHash(key_type_ref Key) {
static hash_value_type ComputeHash(key_type_ref Key) {
return llvm::HashString(Key);
}
std::pair<unsigned,unsigned>
EmitKeyDataLength(raw_ostream& Out, key_type_ref Key, data_type_ref Data) {
using namespace llvm::support;
endian::Writer<little> LE(Out);
unsigned KeyLen = Key.size();
unsigned DataLen = Data.size() * 4;
clang::io::Emit16(Out, KeyLen);
clang::io::Emit16(Out, DataLen);
LE.write<uint16_t>(KeyLen);
LE.write<uint16_t>(DataLen);
return std::make_pair(KeyLen, DataLen);
}
@@ -643,8 +675,9 @@ public:
void EmitData(raw_ostream& Out, key_type_ref Key, data_type_ref Data,
unsigned DataLen) {
using namespace llvm::support;
for (unsigned I = 0, N = Data.size(); I != N; ++I)
clang::io::Emit32(Out, Data[I]);
endian::Writer<little>(Out).write<uint32_t>(Data[I]);
}
};
@@ -692,7 +725,7 @@ void GlobalModuleIndexBuilder::writeIndex(llvm::BitstreamWriter &Stream) {
// Write the identifier -> module file mapping.
{
OnDiskChainedHashTableGenerator<IdentifierIndexWriterTrait> Generator;
llvm::OnDiskChainedHashTableGenerator<IdentifierIndexWriterTrait> Generator;
IdentifierIndexWriterTrait Trait;
// Populate the hash table.
@@ -706,9 +739,10 @@ void GlobalModuleIndexBuilder::writeIndex(llvm::BitstreamWriter &Stream) {
SmallString<4096> IdentifierTable;
uint32_t BucketOffset;
{
using namespace llvm::support;
llvm::raw_svector_ostream Out(IdentifierTable);
// Make sure that no bucket is at offset 0
clang::io::Emit32(Out, 0);
endian::Writer<little>(Out).write<uint32_t>(0);
BucketOffset = Generator.Emit(Out, Trait);
}
@@ -756,7 +790,7 @@ GlobalModuleIndex::writeIndex(FileManager &FileMgr, StringRef Path) {
GlobalModuleIndexBuilder Builder(FileMgr);
// Load each of the module files.
llvm::error_code EC;
std::error_code EC;
for (llvm::sys::fs::directory_iterator D(Path, EC), DEnd;
D != DEnd && !EC;
D.increment(EC)) {
@@ -807,13 +841,12 @@ GlobalModuleIndex::writeIndex(FileManager &FileMgr, StringRef Path) {
return EC_IOError;
// Remove the old index file. It isn't relevant any more.
bool OldIndexExisted;
llvm::sys::fs::remove(IndexPath.str(), OldIndexExisted);
llvm::sys::fs::remove(IndexPath.str());
// Rename the newly-written index file to the proper name.
if (llvm::sys::fs::rename(IndexTmpPath.str(), IndexPath.str())) {
// Rename failed; just remove the
llvm::sys::fs::remove(IndexTmpPath.str(), OldIndexExisted);
llvm::sys::fs::remove(IndexTmpPath.str());
return EC_IOError;
}
@@ -835,7 +868,7 @@ namespace {
End = Idx.key_end();
}
virtual StringRef Next() {
StringRef Next() override {
if (Current == End)
return StringRef();