-
Notifications
You must be signed in to change notification settings - Fork 13.8k
[NFC] Move DeclID from serialization/ASTBitCodes.h to AST/DeclID.h #89873
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
Conversation
@llvm/pr-subscribers-clang-modules @llvm/pr-subscribers-clang Author: Chuanqi Xu (ChuanqiXu9) ChangesPreviously, the DeclID is defined in serialization/ASTBitCodes.h under clang::serialization namespace. However, actually the DeclID is not purely used in serialization part. The DeclID is already widely used in AST and all around the clang project via classes like This patch moves the DeclID class family to a new header Patch is 93.07 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/89873.diff 31 Files Affected:
diff --git a/clang/include/clang/AST/ASTContext.h b/clang/include/clang/AST/ASTContext.h
index d5ed20ff50157d..ecec9bfcf30079 100644
--- a/clang/include/clang/AST/ASTContext.h
+++ b/clang/include/clang/AST/ASTContext.h
@@ -455,7 +455,7 @@ class ASTContext : public RefCountedBase<ASTContext> {
/// initialization of another module).
struct PerModuleInitializers {
llvm::SmallVector<Decl*, 4> Initializers;
- llvm::SmallVector<Decl::DeclID, 4> LazyInitializers;
+ llvm::SmallVector<DeclID, 4> LazyInitializers;
void resolve(ASTContext &Ctx);
};
@@ -1059,7 +1059,7 @@ class ASTContext : public RefCountedBase<ASTContext> {
/// or an ImportDecl nominating another module that has initializers.
void addModuleInitializer(Module *M, Decl *Init);
- void addLazyModuleInitializers(Module *M, ArrayRef<Decl::DeclID> IDs);
+ void addLazyModuleInitializers(Module *M, ArrayRef<DeclID> IDs);
/// Get the initializations to perform when importing a module, if any.
ArrayRef<Decl*> getModuleInitializers(Module *M);
diff --git a/clang/include/clang/AST/DeclBase.h b/clang/include/clang/AST/DeclBase.h
index d8cafc3d81526e..474e51c1df6d68 100644
--- a/clang/include/clang/AST/DeclBase.h
+++ b/clang/include/clang/AST/DeclBase.h
@@ -15,6 +15,7 @@
#include "clang/AST/ASTDumperUtils.h"
#include "clang/AST/AttrIterator.h"
+#include "clang/AST/DeclID.h"
#include "clang/AST/DeclarationName.h"
#include "clang/AST/SelectorLocationsKind.h"
#include "clang/Basic/IdentifierTable.h"
@@ -239,9 +240,6 @@ class alignas(8) Decl {
ModulePrivate
};
- /// An ID number that refers to a declaration in an AST file.
- using DeclID = uint32_t;
-
protected:
/// The next declaration within the same lexical
/// DeclContext. These pointers form the linked list that is
diff --git a/clang/include/clang/AST/DeclID.h b/clang/include/clang/AST/DeclID.h
new file mode 100644
index 00000000000000..37e40e198f2776
--- /dev/null
+++ b/clang/include/clang/AST/DeclID.h
@@ -0,0 +1,175 @@
+//===--- DeclID.h - ID number for deserialized declarations ----*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+//
+// This file defines DeclID class family to describe the deserialized
+// declarations. The DeclID is widely used in AST via LazyDeclPtr, or calls to
+// `ExternalASTSource::getExternalDecl`. It will be helpful for type safety to
+// require the use of `DeclID` to explicit.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_CLANG_AST_DECLID_H
+#define LLVM_CLANG_AST_DECLID_H
+
+namespace clang {
+
+/// Predefined declaration IDs.
+///
+/// These declaration IDs correspond to predefined declarations in the AST
+/// context, such as the NULL declaration ID. Such declarations are never
+/// actually serialized, since they will be built by the AST context when
+/// it is created.
+enum PredefinedDeclIDs {
+ /// The NULL declaration.
+ PREDEF_DECL_NULL_ID = 0,
+
+ /// The translation unit.
+ PREDEF_DECL_TRANSLATION_UNIT_ID = 1,
+
+ /// The Objective-C 'id' type.
+ PREDEF_DECL_OBJC_ID_ID = 2,
+
+ /// The Objective-C 'SEL' type.
+ PREDEF_DECL_OBJC_SEL_ID = 3,
+
+ /// The Objective-C 'Class' type.
+ PREDEF_DECL_OBJC_CLASS_ID = 4,
+
+ /// The Objective-C 'Protocol' type.
+ PREDEF_DECL_OBJC_PROTOCOL_ID = 5,
+
+ /// The signed 128-bit integer type.
+ PREDEF_DECL_INT_128_ID = 6,
+
+ /// The unsigned 128-bit integer type.
+ PREDEF_DECL_UNSIGNED_INT_128_ID = 7,
+
+ /// The internal 'instancetype' typedef.
+ PREDEF_DECL_OBJC_INSTANCETYPE_ID = 8,
+
+ /// The internal '__builtin_va_list' typedef.
+ PREDEF_DECL_BUILTIN_VA_LIST_ID = 9,
+
+ /// The internal '__va_list_tag' struct, if any.
+ PREDEF_DECL_VA_LIST_TAG = 10,
+
+ /// The internal '__builtin_ms_va_list' typedef.
+ PREDEF_DECL_BUILTIN_MS_VA_LIST_ID = 11,
+
+ /// The predeclared '_GUID' struct.
+ PREDEF_DECL_BUILTIN_MS_GUID_ID = 12,
+
+ /// The extern "C" context.
+ PREDEF_DECL_EXTERN_C_CONTEXT_ID = 13,
+
+ /// The internal '__make_integer_seq' template.
+ PREDEF_DECL_MAKE_INTEGER_SEQ_ID = 14,
+
+ /// The internal '__NSConstantString' typedef.
+ PREDEF_DECL_CF_CONSTANT_STRING_ID = 15,
+
+ /// The internal '__NSConstantString' tag type.
+ PREDEF_DECL_CF_CONSTANT_STRING_TAG_ID = 16,
+
+ /// The internal '__type_pack_element' template.
+ PREDEF_DECL_TYPE_PACK_ELEMENT_ID = 17,
+};
+
+/// The number of declaration IDs that are predefined.
+///
+/// For more information about predefined declarations, see the
+/// \c PredefinedDeclIDs type and the PREDEF_DECL_*_ID constants.
+const unsigned int NUM_PREDEF_DECL_IDS = 18;
+
+/// An ID number that refers to a declaration in an AST file.
+///
+/// The ID numbers of declarations are consecutive (in order of
+/// discovery), with values below NUM_PREDEF_DECL_IDS being reserved.
+/// At the start of a chain of precompiled headers, declaration ID 1 is
+/// used for the translation unit declaration.
+using DeclID = uint32_t;
+
+class LocalDeclID {
+public:
+ explicit LocalDeclID(DeclID ID) : ID(ID) {}
+
+ DeclID get() const { return ID; }
+
+private:
+ DeclID ID;
+};
+
+/// Wrapper class for DeclID. This is helpful to not mix the use of LocalDeclID
+/// and GlobalDeclID to improve the type safety.
+class GlobalDeclID {
+public:
+ GlobalDeclID() : ID(PREDEF_DECL_NULL_ID) {}
+ explicit GlobalDeclID(DeclID ID) : ID(ID) {}
+
+ DeclID get() const { return ID; }
+
+ explicit operator DeclID() const { return ID; }
+
+ friend bool operator==(const GlobalDeclID &LHS, const GlobalDeclID &RHS) {
+ return LHS.ID == RHS.ID;
+ }
+ friend bool operator!=(const GlobalDeclID &LHS, const GlobalDeclID &RHS) {
+ return LHS.ID != RHS.ID;
+ }
+ // We may sort the global decl ID.
+ friend bool operator<(const GlobalDeclID &LHS, const GlobalDeclID &RHS) {
+ return LHS.ID < RHS.ID;
+ }
+ friend bool operator>(const GlobalDeclID &LHS, const GlobalDeclID &RHS) {
+ return LHS.ID > RHS.ID;
+ }
+ friend bool operator<=(const GlobalDeclID &LHS, const GlobalDeclID &RHS) {
+ return LHS.ID <= RHS.ID;
+ }
+ friend bool operator>=(const GlobalDeclID &LHS, const GlobalDeclID &RHS) {
+ return LHS.ID >= RHS.ID;
+ }
+
+private:
+ DeclID ID;
+};
+
+/// A helper iterator adaptor to convert the iterators to `SmallVector<DeclID>`
+/// to the iterators to `SmallVector<GlobalDeclID>`.
+class GlobalDeclIDIterator
+ : public llvm::iterator_adaptor_base<GlobalDeclIDIterator, const DeclID *,
+ std::forward_iterator_tag,
+ GlobalDeclID> {
+public:
+ GlobalDeclIDIterator() : iterator_adaptor_base(nullptr) {}
+
+ GlobalDeclIDIterator(const DeclID *ID) : iterator_adaptor_base(ID) {}
+
+ value_type operator*() const { return GlobalDeclID(*I); }
+
+ bool operator==(const GlobalDeclIDIterator &RHS) const { return I == RHS.I; }
+};
+
+/// A helper iterator adaptor to convert the iterators to
+/// `SmallVector<GlobalDeclID>` to the iterators to `SmallVector<DeclID>`.
+class DeclIDIterator
+ : public llvm::iterator_adaptor_base<DeclIDIterator, const GlobalDeclID *,
+ std::forward_iterator_tag, DeclID> {
+public:
+ DeclIDIterator() : iterator_adaptor_base(nullptr) {}
+
+ DeclIDIterator(const GlobalDeclID *ID) : iterator_adaptor_base(ID) {}
+
+ value_type operator*() const { return DeclID(*I); }
+
+ bool operator==(const DeclIDIterator &RHS) const { return I == RHS.I; }
+};
+
+} // namespace clang
+
+#endif
diff --git a/clang/include/clang/AST/DeclTemplate.h b/clang/include/clang/AST/DeclTemplate.h
index 231bda44a9fcfd..0c95459a6ab186 100644
--- a/clang/include/clang/AST/DeclTemplate.h
+++ b/clang/include/clang/AST/DeclTemplate.h
@@ -797,7 +797,7 @@ class RedeclarableTemplateDecl : public TemplateDecl,
///
/// The first value in the array is the number of specializations/partial
/// specializations that follow.
- Decl::DeclID *LazySpecializations = nullptr;
+ DeclID *LazySpecializations = nullptr;
/// The set of "injected" template arguments used within this
/// template.
diff --git a/clang/include/clang/AST/ExternalASTSource.h b/clang/include/clang/AST/ExternalASTSource.h
index eee8d6b6c6ef11..d0ee8ce6365a97 100644
--- a/clang/include/clang/AST/ExternalASTSource.h
+++ b/clang/include/clang/AST/ExternalASTSource.h
@@ -99,7 +99,7 @@ class ExternalASTSource : public RefCountedBase<ExternalASTSource> {
/// passes back decl sets as VisibleDeclaration objects.
///
/// The default implementation of this method is a no-op.
- virtual Decl *GetExternalDecl(Decl::DeclID ID);
+ virtual Decl *GetExternalDecl(DeclID ID);
/// Resolve a selector ID into a selector.
///
@@ -579,7 +579,7 @@ using LazyDeclStmtPtr =
/// A lazy pointer to a declaration.
using LazyDeclPtr =
- LazyOffsetPtr<Decl, Decl::DeclID, &ExternalASTSource::GetExternalDecl>;
+ LazyOffsetPtr<Decl, DeclID, &ExternalASTSource::GetExternalDecl>;
/// A lazy pointer to a set of CXXCtorInitializers.
using LazyCXXCtorInitializersPtr =
diff --git a/clang/include/clang/Frontend/ASTUnit.h b/clang/include/clang/Frontend/ASTUnit.h
index a2c1b25dd22476..163e87cd3df3ac 100644
--- a/clang/include/clang/Frontend/ASTUnit.h
+++ b/clang/include/clang/Frontend/ASTUnit.h
@@ -241,7 +241,7 @@ class ASTUnit {
/// A list of the serialization ID numbers for each of the top-level
/// declarations parsed within the precompiled preamble.
- std::vector<serialization::DeclID> TopLevelDeclsInPreamble;
+ std::vector<DeclID> TopLevelDeclsInPreamble;
/// Whether we should be caching code-completion results.
bool ShouldCacheCodeCompletionResults : 1;
diff --git a/clang/include/clang/Frontend/MultiplexConsumer.h b/clang/include/clang/Frontend/MultiplexConsumer.h
index 7f8d2858b3863e..6a82c0dd8cec24 100644
--- a/clang/include/clang/Frontend/MultiplexConsumer.h
+++ b/clang/include/clang/Frontend/MultiplexConsumer.h
@@ -35,7 +35,7 @@ class MultiplexASTDeserializationListener : public ASTDeserializationListener {
void IdentifierRead(serialization::IdentID ID, IdentifierInfo *II) override;
void MacroRead(serialization::MacroID ID, MacroInfo *MI) override;
void TypeRead(serialization::TypeIdx Idx, QualType T) override;
- void DeclRead(serialization::DeclID ID, const Decl *D) override;
+ void DeclRead(DeclID ID, const Decl *D) override;
void SelectorRead(serialization::SelectorID iD, Selector Sel) override;
void MacroDefinitionRead(serialization::PreprocessedEntityID,
MacroDefinitionRecord *MD) override;
diff --git a/clang/include/clang/Sema/MultiplexExternalSemaSource.h b/clang/include/clang/Sema/MultiplexExternalSemaSource.h
index 993c9b1daa309b..da3204863a4157 100644
--- a/clang/include/clang/Sema/MultiplexExternalSemaSource.h
+++ b/clang/include/clang/Sema/MultiplexExternalSemaSource.h
@@ -65,7 +65,7 @@ class MultiplexExternalSemaSource : public ExternalSemaSource {
/// Resolve a declaration ID into a declaration, potentially
/// building a new declaration.
- Decl *GetExternalDecl(Decl::DeclID ID) override;
+ Decl *GetExternalDecl(DeclID ID) override;
/// Complete the redeclaration chain if it's been extended since the
/// previous generation of the AST source.
diff --git a/clang/include/clang/Serialization/ASTBitCodes.h b/clang/include/clang/Serialization/ASTBitCodes.h
index dcfa4ac0c19677..42e09a2bf6344d 100644
--- a/clang/include/clang/Serialization/ASTBitCodes.h
+++ b/clang/include/clang/Serialization/ASTBitCodes.h
@@ -17,6 +17,7 @@
#ifndef LLVM_CLANG_SERIALIZATION_ASTBITCODES_H
#define LLVM_CLANG_SERIALIZATION_ASTBITCODES_H
+#include "clang/AST/DeclID.h"
#include "clang/AST/DeclarationName.h"
#include "clang/AST/Type.h"
#include "clang/Basic/IdentifierTable.h"
@@ -59,92 +60,6 @@ const unsigned VERSION_MINOR = 1;
/// and start at 1. 0 is reserved for NULL.
using IdentifierID = uint32_t;
-/// An ID number that refers to a declaration in an AST file.
-///
-/// The ID numbers of declarations are consecutive (in order of
-/// discovery), with values below NUM_PREDEF_DECL_IDS being reserved.
-/// At the start of a chain of precompiled headers, declaration ID 1 is
-/// used for the translation unit declaration.
-///
-/// FIXME: Merge with Decl::DeclID
-using DeclID = uint32_t;
-
-class LocalDeclID {
-public:
- explicit LocalDeclID(DeclID ID) : ID(ID) {}
-
- DeclID get() const { return ID; }
-
-private:
- DeclID ID;
-};
-
-/// Wrapper class for DeclID. This is helpful to not mix the use of LocalDeclID
-/// and GlobalDeclID to improve the type safety.
-class GlobalDeclID {
-public:
- GlobalDeclID() : ID(0) {}
- explicit GlobalDeclID(DeclID ID) : ID(ID) {}
-
- DeclID get() const { return ID; }
-
- explicit operator DeclID() const { return ID; }
-
- friend bool operator==(const GlobalDeclID &LHS, const GlobalDeclID &RHS) {
- return LHS.ID == RHS.ID;
- }
- friend bool operator!=(const GlobalDeclID &LHS, const GlobalDeclID &RHS) {
- return LHS.ID != RHS.ID;
- }
- // We may sort the global decl ID.
- friend bool operator<(const GlobalDeclID &LHS, const GlobalDeclID &RHS) {
- return LHS.ID < RHS.ID;
- }
- friend bool operator>(const GlobalDeclID &LHS, const GlobalDeclID &RHS) {
- return LHS.ID > RHS.ID;
- }
- friend bool operator<=(const GlobalDeclID &LHS, const GlobalDeclID &RHS) {
- return LHS.ID <= RHS.ID;
- }
- friend bool operator>=(const GlobalDeclID &LHS, const GlobalDeclID &RHS) {
- return LHS.ID >= RHS.ID;
- }
-
-private:
- DeclID ID;
-};
-
-/// A helper iterator adaptor to convert the iterators to `SmallVector<DeclID>`
-/// to the iterators to `SmallVector<GlobalDeclID>`.
-class GlobalDeclIDIterator
- : public llvm::iterator_adaptor_base<GlobalDeclIDIterator, const DeclID *,
- std::forward_iterator_tag,
- GlobalDeclID> {
-public:
- GlobalDeclIDIterator() : iterator_adaptor_base(nullptr) {}
-
- GlobalDeclIDIterator(const DeclID *ID) : iterator_adaptor_base(ID) {}
-
- value_type operator*() const { return GlobalDeclID(*I); }
-
- bool operator==(const GlobalDeclIDIterator &RHS) const { return I == RHS.I; }
-};
-
-/// A helper iterator adaptor to convert the iterators to
-/// `SmallVector<GlobalDeclID>` to the iterators to `SmallVector<DeclID>`.
-class DeclIDIterator
- : public llvm::iterator_adaptor_base<DeclIDIterator, const GlobalDeclID *,
- std::forward_iterator_tag, DeclID> {
-public:
- DeclIDIterator() : iterator_adaptor_base(nullptr) {}
-
- DeclIDIterator(const GlobalDeclID *ID) : iterator_adaptor_base(ID) {}
-
- value_type operator*() const { return DeclID(*I); }
-
- bool operator==(const DeclIDIterator &RHS) const { return I == RHS.I; }
-};
-
/// An ID number that refers to a type in an AST file.
///
/// The ID of a type is partitioned into two parts: the lower
@@ -1238,74 +1153,6 @@ enum SpecialTypeIDs {
/// The number of special type IDs.
const unsigned NumSpecialTypeIDs = 8;
-/// Predefined declaration IDs.
-///
-/// These declaration IDs correspond to predefined declarations in the AST
-/// context, such as the NULL declaration ID. Such declarations are never
-/// actually serialized, since they will be built by the AST context when
-/// it is created.
-enum PredefinedDeclIDs {
- /// The NULL declaration.
- PREDEF_DECL_NULL_ID = 0,
-
- /// The translation unit.
- PREDEF_DECL_TRANSLATION_UNIT_ID = 1,
-
- /// The Objective-C 'id' type.
- PREDEF_DECL_OBJC_ID_ID = 2,
-
- /// The Objective-C 'SEL' type.
- PREDEF_DECL_OBJC_SEL_ID = 3,
-
- /// The Objective-C 'Class' type.
- PREDEF_DECL_OBJC_CLASS_ID = 4,
-
- /// The Objective-C 'Protocol' type.
- PREDEF_DECL_OBJC_PROTOCOL_ID = 5,
-
- /// The signed 128-bit integer type.
- PREDEF_DECL_INT_128_ID = 6,
-
- /// The unsigned 128-bit integer type.
- PREDEF_DECL_UNSIGNED_INT_128_ID = 7,
-
- /// The internal 'instancetype' typedef.
- PREDEF_DECL_OBJC_INSTANCETYPE_ID = 8,
-
- /// The internal '__builtin_va_list' typedef.
- PREDEF_DECL_BUILTIN_VA_LIST_ID = 9,
-
- /// The internal '__va_list_tag' struct, if any.
- PREDEF_DECL_VA_LIST_TAG = 10,
-
- /// The internal '__builtin_ms_va_list' typedef.
- PREDEF_DECL_BUILTIN_MS_VA_LIST_ID = 11,
-
- /// The predeclared '_GUID' struct.
- PREDEF_DECL_BUILTIN_MS_GUID_ID = 12,
-
- /// The extern "C" context.
- PREDEF_DECL_EXTERN_C_CONTEXT_ID = 13,
-
- /// The internal '__make_integer_seq' template.
- PREDEF_DECL_MAKE_INTEGER_SEQ_ID = 14,
-
- /// The internal '__NSConstantString' typedef.
- PREDEF_DECL_CF_CONSTANT_STRING_ID = 15,
-
- /// The internal '__NSConstantString' tag type.
- PREDEF_DECL_CF_CONSTANT_STRING_TAG_ID = 16,
-
- /// The internal '__type_pack_element' template.
- PREDEF_DECL_TYPE_PACK_ELEMENT_ID = 17,
-};
-
-/// The number of declaration IDs that are predefined.
-///
-/// For more information about predefined declarations, see the
-/// \c PredefinedDeclIDs type and the PREDEF_DECL_*_ID constants.
-const unsigned int NUM_PREDEF_DECL_IDS = 18;
-
/// Record of updates for a declaration that was modified after
/// being deserialized. This can occur within DECLTYPES_BLOCK_ID.
const unsigned int DECL_UPDATES = 49;
@@ -2231,9 +2078,9 @@ template <> struct DenseMapInfo<clang::serialization::DeclarationNameKey> {
}
};
-template <> struct DenseMapInfo<clang::serialization::GlobalDeclID> {
- using DeclID = clang::serialization::DeclID;
- using GlobalDeclID = clang::serialization::GlobalDeclID;
+template <> struct DenseMapInfo<clang::GlobalDeclID> {
+ using DeclID = clang::DeclID;
+ using GlobalDeclID = clang::GlobalDeclID;
static GlobalDeclID getEmptyKey() {
return GlobalDeclID(DenseMapInfo<DeclID>::getEmptyKey());
diff --git a/clang/include/clang/Serialization/ASTDeserializationListener.h b/clang/include/clang/Serialization/ASTDeserializationListener.h
index f3a01a4b973158..bb039558f7f73f 100644
--- a/clang/include/clang/Serialization/ASTDeserializationListener.h
+++ b/clang/include/clang/Serialization/ASTDeserializationListener.h
@@ -44,7 +44,7 @@ class ASTDeserializationListener {
/// unqualified.
virtual void TypeRead(serialization::TypeIdx Idx, QualType T) { }
/// A decl was deserialized from the AST file.
- virtual void DeclRead(serialization::DeclID ID, const Decl *D) { }
+ virtual void DeclRead(DeclID ID, const Decl *D) {}
/// A selector was read from the AST file.
virtual void SelectorRead(serialization::SelectorID iD, Selector Sel) {}
/// A macro definition was read from the AST file.
diff --git a/clang/include/clang/Serialization/ASTReader.h b/clang/include/clang/Serialization/ASTReader.h
index ed917aa1642293..65e2bcb990c312 100644
--- a/clang/include/clang/Serialization/ASTReader.h
+++ b/clang/include/clang/Serialization/ASTReader.h
@@ -501,10 +501,7 @@ class ASTReader
/// = I + 1 has already been loaded.
llvm::PagedVector<Decl *> DeclsLoaded;
- static_assert(std::is_same_v<serialization::DeclID, Decl::DeclID>);
-
- using GlobalDeclMapType =
- ContinuousRangeMap<serialization::GlobalDeclID, ModuleFile *, 4>;
+ using GlobalDeclMapType = ContinuousRangeMap<GlobalDeclID, ModuleFile *, 4>;
/// Mapping from global declaration IDs to the module in which the
/// declaration resides.
@@ -512,16 +509,15 @@ class ASTReader
using FileOffset = std::pair<ModuleFile *, uint64_t>;
using FileOffsetsTy = SmallVector<FileOffset, 2>;
- using DeclUpdateOffsetsMap =
- llvm::DenseMap<serialization::GlobalDeclID, FileOffsetsTy>;
+ using DeclUpdateOffsetsMap = llvm::DenseMap<GlobalDeclID, FileOffsetsTy>;
/// Declarations that have modifications residing in a later file
/// in the chain.
DeclUpdateOffsetsMap DeclUpdateOffsets;
- using DelayedNamespaceOffsetMapTy = llvm::DenseMap<
- serialization::GlobalDeclID,
- std::pair</*LexicalOffset*/ uint64_t, /*VisibleOffset*/ uint64_t>>;
+ using DelayedNamespaceOffsetMapTy =
+ llvm::DenseMap<GlobalDeclID, std::pair</*LexicalOffset*/ uint64_t,
+ /*VisibleOffset*/ uint64_t>>;
/// Mapping from global declaration ...
[truncated]
|
Previously, the DeclID is defined in serialization/ASTBitCodes.h under clang::serialization namespace. However, actually the DeclID is not purely used in serialization part. The DeclID is already widely used in AST and all around the clang project via classes like `LazyPtrDecl` or calling `ExternalASTSource::getExernalDecl()`. All such uses are via the raw underlying type of `DeclID` as `uint32_t`. This is not pretty good. This patch moves the DeclID class family to a new header `AST/DeclID.h` so that the whole project can use the wrapped class `DeclID`, `GlobalDeclID` and `LocalDeclID` instead of the raw underlying type. This can improve the readability and the type safety.
There were a number of upstream LLVM changes to `DeclID` in order to separate "local" and "global" IDs: llvm/llvm-project@07b1177 llvm/llvm-project@b8e3b2a llvm/llvm-project@b467c6b llvm/llvm-project#89873 llvm/llvm-project@d86cc73 llvm/llvm-project@8af8602 ... and probably more. This likely needs further cleaning up to not use `DeclID` at all.
There were a number of upstream LLVM changes to `DeclID` in order to separate "local" and "global" IDs: llvm/llvm-project@07b1177 llvm/llvm-project@b8e3b2a llvm/llvm-project@b467c6b llvm/llvm-project#89873 llvm/llvm-project@d86cc73 llvm/llvm-project@8af8602 ... and probably more. This likely needs further cleaning up to not use `DeclID` at all.
There were a number of upstream LLVM changes to `DeclID` in order to separate "local" and "global" IDs: llvm/llvm-project@07b1177 llvm/llvm-project@b8e3b2a llvm/llvm-project@b467c6b llvm/llvm-project#89873 llvm/llvm-project@d86cc73 llvm/llvm-project@8af8602 ... and probably more. This likely needs further cleaning up to not use `DeclID` at all.
Previously, the DeclID is defined in serialization/ASTBitCodes.h under clang::serialization namespace. However, actually the DeclID is not purely used in serialization part. The DeclID is already widely used in AST and all around the clang project via classes like
LazyPtrDecl
or callingExternalASTSource::getExernalDecl()
. All such uses are via the raw underlying type ofDeclID
asuint32_t
. This is not pretty good.This patch moves the DeclID class family to a new header
AST/DeclID.h
so that the whole project can use the wrapped classDeclID
,GlobalDeclID
andLocalDeclID
instead of the raw underlying type. This can improve the readability and the type safety.