diff options
author | dim <dim@FreeBSD.org> | 2011-02-27 01:32:10 +0000 |
---|---|---|
committer | dim <dim@FreeBSD.org> | 2011-02-27 01:32:10 +0000 |
commit | b951d621be1d00a520871c689c1cd687b6aa3ae6 (patch) | |
tree | 5c342f2374324ffec4626f558d9aa49f323f90b4 /contrib/llvm/tools/clang/lib/Serialization/ASTReader.cpp | |
parent | 4004d6a3076e94bd23e681411c43682267a202fe (diff) | |
parent | a0fb00f9837bd0d2e5948f16f6a6b82a7a628f51 (diff) | |
download | FreeBSD-src-b951d621be1d00a520871c689c1cd687b6aa3ae6.zip FreeBSD-src-b951d621be1d00a520871c689c1cd687b6aa3ae6.tar.gz |
Update llvm/clang to trunk r126547.
There are several bugfixes in this update, but the most important one is
to ensure __start_ and __stop_ symbols for linker sets and kernel module
metadata are always emitted in object files:
http://llvm.org/bugs/show_bug.cgi?id=9292
Before this fix, if you compiled kernel modules with clang, they would
not be properly processed by kldxref, and if they had any dependencies,
the kernel would fail to load those. Another problem occurred when
attempting to mount a tmpfs filesystem, which would result in 'operation
not supported by device'.
Diffstat (limited to 'contrib/llvm/tools/clang/lib/Serialization/ASTReader.cpp')
-rw-r--r-- | contrib/llvm/tools/clang/lib/Serialization/ASTReader.cpp | 128 |
1 files changed, 120 insertions, 8 deletions
diff --git a/contrib/llvm/tools/clang/lib/Serialization/ASTReader.cpp b/contrib/llvm/tools/clang/lib/Serialization/ASTReader.cpp index ce87b11..c3953ba 100644 --- a/contrib/llvm/tools/clang/lib/Serialization/ASTReader.cpp +++ b/contrib/llvm/tools/clang/lib/Serialization/ASTReader.cpp @@ -97,8 +97,9 @@ PCHValidator::ReadLanguageOptions(const LangOptions &LangOpts) { diag::warn_pch_lax_vector_conversions); PARSE_LANGOPT_IMPORTANT(AltiVec, diag::warn_pch_altivec); PARSE_LANGOPT_IMPORTANT(Exceptions, diag::warn_pch_exceptions); - PARSE_LANGOPT_IMPORTANT(SjLjExceptions, diag::warn_pch_sjlj_exceptions); PARSE_LANGOPT_IMPORTANT(ObjCExceptions, diag::warn_pch_objc_exceptions); + PARSE_LANGOPT_IMPORTANT(CXXExceptions, diag::warn_pch_cxx_exceptions); + PARSE_LANGOPT_IMPORTANT(SjLjExceptions, diag::warn_pch_sjlj_exceptions); PARSE_LANGOPT_IMPORTANT(MSBitfields, diag::warn_pch_ms_bitfields); PARSE_LANGOPT_IMPORTANT(NeXTRuntime, diag::warn_pch_objc_runtime); PARSE_LANGOPT_IMPORTANT(Freestanding, diag::warn_pch_freestanding); @@ -243,14 +244,15 @@ FindMacro(const PCHPredefinesBlocks &Buffers, llvm::StringRef MacroDef) { bool PCHValidator::ReadPredefinesBuffer(const PCHPredefinesBlocks &Buffers, llvm::StringRef OriginalFileName, - std::string &SuggestedPredefines) { + std::string &SuggestedPredefines, + FileManager &FileMgr) { // We are in the context of an implicit include, so the predefines buffer will // have a #include entry for the PCH file itself (as normalized by the // preprocessor initialization). Find it and skip over it in the checking // below. llvm::SmallString<256> PCHInclude; PCHInclude += "#include \""; - PCHInclude += NormalizeDashIncludePath(OriginalFileName); + PCHInclude += NormalizeDashIncludePath(OriginalFileName, FileMgr); PCHInclude += "\"\n"; std::pair<llvm::StringRef,llvm::StringRef> Split = llvm::StringRef(PP.getPredefines()).split(PCHInclude.str()); @@ -960,7 +962,8 @@ bool ASTReader::CheckPredefinesBuffers() { if (Listener) return Listener->ReadPredefinesBuffer(PCHPredefinesBuffers, ActualOriginalFileName, - SuggestedPredefines); + SuggestedPredefines, + FileMgr); return false; } @@ -2799,8 +2802,9 @@ bool ASTReader::ParseLanguageOptions( PARSE_LANGOPT(LaxVectorConversions); PARSE_LANGOPT(AltiVec); PARSE_LANGOPT(Exceptions); - PARSE_LANGOPT(SjLjExceptions); PARSE_LANGOPT(ObjCExceptions); + PARSE_LANGOPT(CXXExceptions); + PARSE_LANGOPT(SjLjExceptions); PARSE_LANGOPT(MSBitfields); PARSE_LANGOPT(NeXTRuntime); PARSE_LANGOPT(Freestanding); @@ -4476,8 +4480,7 @@ void ASTReader::ReadDeclarationNameInfo(PerFileData &F, void ASTReader::ReadQualifierInfo(PerFileData &F, QualifierInfo &Info, const RecordData &Record, unsigned &Idx) { - Info.NNS = ReadNestedNameSpecifier(Record, Idx); - Info.NNSRange = ReadSourceRange(F, Record, Idx); + Info.QualifierLoc = ReadNestedNameSpecifierLoc(F, Record, Idx); unsigned NumTPLists = Record[Idx++]; Info.NumTemplParamLists = NumTPLists; if (NumTPLists) { @@ -4726,6 +4729,13 @@ ASTReader::ReadNestedNameSpecifier(const RecordData &Record, unsigned &Idx) { break; } + case NestedNameSpecifier::NamespaceAlias: { + NamespaceAliasDecl *Alias + = cast<NamespaceAliasDecl>(GetDecl(Record[Idx++])); + NNS = NestedNameSpecifier::Create(*Context, Prev, Alias); + break; + } + case NestedNameSpecifier::TypeSpec: case NestedNameSpecifier::TypeSpecWithTemplate: { const Type *T = GetType(Record[Idx++]).getTypePtrOrNull(); @@ -4748,6 +4758,109 @@ ASTReader::ReadNestedNameSpecifier(const RecordData &Record, unsigned &Idx) { return NNS; } +NestedNameSpecifierLoc +ASTReader::ReadNestedNameSpecifierLoc(PerFileData &F, const RecordData &Record, + unsigned &Idx) { + unsigned N = Record[Idx++]; + NestedNameSpecifier *NNS = 0, *Prev = 0; + llvm::SmallVector<char, 32> LocationData; + for (unsigned I = 0; I != N; ++I) { + NestedNameSpecifier::SpecifierKind Kind + = (NestedNameSpecifier::SpecifierKind)Record[Idx++]; + switch (Kind) { + case NestedNameSpecifier::Identifier: { + // Nested-name-specifier + IdentifierInfo *II = GetIdentifierInfo(Record, Idx); + NNS = NestedNameSpecifier::Create(*Context, Prev, II); + + // Location information + SourceRange Range = ReadSourceRange(F, Record, Idx); + unsigned RawStart = Range.getBegin().getRawEncoding(); + unsigned RawEnd = Range.getEnd().getRawEncoding(); + LocationData.append(reinterpret_cast<char*>(&RawStart), + reinterpret_cast<char*>(&RawStart) +sizeof(unsigned)); + LocationData.append(reinterpret_cast<char*>(&RawEnd), + reinterpret_cast<char*>(&RawEnd) + sizeof(unsigned)); + break; + } + + case NestedNameSpecifier::Namespace: { + // Nested-name-specifier + NamespaceDecl *NS = cast<NamespaceDecl>(GetDecl(Record[Idx++])); + NNS = NestedNameSpecifier::Create(*Context, Prev, NS); + + // Location information + SourceRange Range = ReadSourceRange(F, Record, Idx); + unsigned RawStart = Range.getBegin().getRawEncoding(); + unsigned RawEnd = Range.getEnd().getRawEncoding(); + LocationData.append(reinterpret_cast<char*>(&RawStart), + reinterpret_cast<char*>(&RawStart) +sizeof(unsigned)); + LocationData.append(reinterpret_cast<char*>(&RawEnd), + reinterpret_cast<char*>(&RawEnd) + sizeof(unsigned)); + break; + } + + case NestedNameSpecifier::NamespaceAlias: { + // Nested-name-specifier + NamespaceAliasDecl *Alias + = cast<NamespaceAliasDecl>(GetDecl(Record[Idx++])); + NNS = NestedNameSpecifier::Create(*Context, Prev, Alias); + + // Location information + SourceRange Range = ReadSourceRange(F, Record, Idx); + unsigned RawStart = Range.getBegin().getRawEncoding(); + unsigned RawEnd = Range.getEnd().getRawEncoding(); + LocationData.append(reinterpret_cast<char*>(&RawStart), + reinterpret_cast<char*>(&RawStart) +sizeof(unsigned)); + LocationData.append(reinterpret_cast<char*>(&RawEnd), + reinterpret_cast<char*>(&RawEnd) + sizeof(unsigned)); + + break; + } + + case NestedNameSpecifier::TypeSpec: + case NestedNameSpecifier::TypeSpecWithTemplate: { + // Nested-name-specifier + bool Template = Record[Idx++]; + TypeSourceInfo *T = GetTypeSourceInfo(F, Record, Idx); + if (!T) + return NestedNameSpecifierLoc(); + NNS = NestedNameSpecifier::Create(*Context, Prev, Template, + T->getType().getTypePtr()); + + // Location information. + SourceLocation ColonColonLoc = ReadSourceLocation(F, Record, Idx); + unsigned RawLocation = ColonColonLoc.getRawEncoding(); + void *OpaqueTypeData = T->getTypeLoc().getOpaqueData(); + LocationData.append(reinterpret_cast<char*>(&OpaqueTypeData), + (reinterpret_cast<char*>(&OpaqueTypeData) + + sizeof(void *))); + LocationData.append(reinterpret_cast<char*>(&RawLocation), + (reinterpret_cast<char*>(&RawLocation) + + sizeof(unsigned))); + break; + } + + case NestedNameSpecifier::Global: { + // Nested-name-specifier + NNS = NestedNameSpecifier::GlobalSpecifier(*Context); + + SourceLocation ColonColonLoc = ReadSourceLocation(F, Record, Idx); + unsigned RawLocation = ColonColonLoc.getRawEncoding(); + LocationData.append(reinterpret_cast<char*>(&RawLocation), + (reinterpret_cast<char*>(&RawLocation) + + sizeof(unsigned))); + break; + } + } + Prev = NNS; + } + + void *Mem = Context->Allocate(LocationData.size(), llvm::alignOf<void*>()); + memcpy(Mem, LocationData.data(), LocationData.size()); + return NestedNameSpecifierLoc(NNS, Mem); +} + SourceRange ASTReader::ReadSourceRange(PerFileData &F, const RecordData &Record, unsigned &Idx) { @@ -4932,4 +5045,3 @@ ASTReader::PerFileData::~PerFileData() { delete static_cast<HeaderFileInfoLookupTable *>(HeaderFileInfoTable); delete static_cast<ASTSelectorLookupTable *>(SelectorLookupTable); } - |