-
Notifications
You must be signed in to change notification settings - Fork 18.1k
[serialization] No transitive type change #92511
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 2 commits
e8f756e
57cfb2b
7dad94d
1263691
381d513
011abc2
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -26,6 +26,7 @@ | |
| #include "clang/Serialization/SourceLocationEncoding.h" | ||
| #include "llvm/ADT/DenseMapInfo.h" | ||
| #include "llvm/Bitstream/BitCodes.h" | ||
| #include "llvm/Support/MathExtras.h" | ||
| #include <cassert> | ||
| #include <cstdint> | ||
|
|
||
|
|
@@ -59,7 +60,7 @@ const unsigned VERSION_MINOR = 1; | |
| /// | ||
| /// The ID numbers of identifiers are consecutive (in order of discovery) | ||
| /// and start at 1. 0 is reserved for NULL. | ||
| using IdentifierID = uint32_t; | ||
| using IdentifierID = uint64_t; | ||
|
|
||
| /// The number of predefined identifier IDs. | ||
| const unsigned int NUM_PREDEF_IDENT_IDS = 1; | ||
|
|
@@ -70,38 +71,53 @@ using DeclID = DeclIDBase::DeclID; | |
|
|
||
| /// An ID number that refers to a type in an AST file. | ||
| /// | ||
| /// The ID of a type is partitioned into two parts: the lower | ||
| /// The ID of a type is partitioned into three parts: | ||
| /// - the lower | ||
| /// three bits are used to store the const/volatile/restrict | ||
| /// qualifiers (as with QualType) and the upper bits provide a | ||
| /// type index. The type index values are partitioned into two | ||
| /// qualifiers (as with QualType). | ||
| /// - the upper 29 bits provide a type index in the corresponding | ||
|
ilya-biryukov marked this conversation as resolved.
Outdated
|
||
| /// module file. | ||
| /// - the upper 32 bits provide a module file index. | ||
| /// | ||
| /// The type index values are partitioned into two | ||
| /// sets. The values below NUM_PREDEF_TYPE_IDs are predefined type | ||
| /// IDs (based on the PREDEF_TYPE_*_ID constants), with 0 as a | ||
| /// placeholder for "no type". Values from NUM_PREDEF_TYPE_IDs are | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. NIT: maybe explain in a comment that predefined types always have a module file index of 0 (i.e. do not belong to any module file)?
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done |
||
| /// other types that have serialized representations. | ||
| using TypeID = uint32_t; | ||
| using TypeID = uint64_t; | ||
|
|
||
| /// A type index; the type ID with the qualifier bits removed. | ||
| /// Keep structure alignment 32-bit since the blob is assumed as 32-bit | ||
|
ilya-biryukov marked this conversation as resolved.
|
||
| /// aligned. | ||
| class TypeIdx { | ||
| uint32_t ModuleFileIndex = 0; | ||
| uint32_t Idx = 0; | ||
|
|
||
| public: | ||
| TypeIdx() = default; | ||
| explicit TypeIdx(uint32_t index) : Idx(index) {} | ||
| explicit TypeIdx(uint32_t Idx) : ModuleFileIndex(0), Idx(Idx) {} | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could we explicitly pass 0 to the ModuleFileIndex instead? It's very uncommon to have defaulted parameters at the start of the parameter list rather than at the end.
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done. |
||
|
|
||
| explicit TypeIdx(uint32_t ModuleFileIdx, uint32_t Idx) | ||
| : ModuleFileIndex(ModuleFileIdx), Idx(Idx) {} | ||
|
|
||
| uint32_t getModuleFileIndex() const { return ModuleFileIndex; } | ||
|
|
||
| uint32_t getIndex() const { return Idx; } | ||
| uint64_t getValue() const { return ((uint64_t)ModuleFileIndex << 32) | Idx; } | ||
|
|
||
| TypeID asTypeID(unsigned FastQuals) const { | ||
| if (Idx == uint32_t(-1)) | ||
| return TypeID(-1); | ||
|
|
||
| return (Idx << Qualifiers::FastWidth) | FastQuals; | ||
| unsigned Index = (Idx << Qualifiers::FastWidth) | FastQuals; | ||
| return ((uint64_t)ModuleFileIndex << 32) | Index; | ||
| } | ||
|
|
||
| static TypeIdx fromTypeID(TypeID ID) { | ||
| if (ID == TypeID(-1)) | ||
| return TypeIdx(-1); | ||
|
|
||
| return TypeIdx(ID >> Qualifiers::FastWidth); | ||
| return TypeIdx(ID >> 32, (ID & llvm::maskTrailingOnes<TypeID>(32)) >> | ||
| Qualifiers::FastWidth); | ||
| } | ||
| }; | ||
|
|
||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.