aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/Frontend
diff options
context:
space:
mode:
authorChuanqi Xu <yedeng.yd@linux.alibaba.com>2024-04-25 13:53:22 +0800
committerGitHub <noreply@github.com>2024-04-25 13:53:22 +0800
commitc2a98fdeb3aede1a8db492a6ea30f4fa85b60edc (patch)
tree6e0ee26c5d104d9ccae7d76477afce5e19aef98e /clang/lib/Frontend
parentfd5f06eb6d8d8b05846c8d7bd2431079ef707b37 (diff)
downloadllvm-c2a98fdeb3aede1a8db492a6ea30f4fa85b60edc.zip
llvm-c2a98fdeb3aede1a8db492a6ea30f4fa85b60edc.tar.gz
llvm-c2a98fdeb3aede1a8db492a6ea30f4fa85b60edc.tar.bz2
[NFC] Move DeclID from serialization/ASTBitCodes.h to AST/DeclID.h (#89873)
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.
Diffstat (limited to 'clang/lib/Frontend')
-rw-r--r--clang/lib/Frontend/ASTUnit.cpp4
-rw-r--r--clang/lib/Frontend/FrontendAction.cpp6
-rw-r--r--clang/lib/Frontend/MultiplexConsumer.cpp3
3 files changed, 6 insertions, 7 deletions
diff --git a/clang/lib/Frontend/ASTUnit.cpp b/clang/lib/Frontend/ASTUnit.cpp
index 3610a08..361331d 100644
--- a/clang/lib/Frontend/ASTUnit.cpp
+++ b/clang/lib/Frontend/ASTUnit.cpp
@@ -1067,7 +1067,7 @@ public:
std::vector<Decl *> takeTopLevelDecls() { return std::move(TopLevelDecls); }
- std::vector<serialization::DeclID> takeTopLevelDeclIDs() {
+ std::vector<DeclID> takeTopLevelDeclIDs() {
return std::move(TopLevelDeclIDs);
}
@@ -1101,7 +1101,7 @@ public:
private:
unsigned Hash = 0;
std::vector<Decl *> TopLevelDecls;
- std::vector<serialization::DeclID> TopLevelDeclIDs;
+ std::vector<DeclID> TopLevelDeclIDs;
llvm::SmallVector<ASTUnit::StandaloneDiagnostic, 4> PreambleDiags;
};
diff --git a/clang/lib/Frontend/FrontendAction.cpp b/clang/lib/Frontend/FrontendAction.cpp
index b7c9967..91ce16e 100644
--- a/clang/lib/Frontend/FrontendAction.cpp
+++ b/clang/lib/Frontend/FrontendAction.cpp
@@ -80,7 +80,7 @@ public:
if (Previous)
Previous->TypeRead(Idx, T);
}
- void DeclRead(serialization::DeclID ID, const Decl *D) override {
+ void DeclRead(DeclID ID, const Decl *D) override {
if (Previous)
Previous->DeclRead(ID, D);
}
@@ -102,7 +102,7 @@ public:
bool DeletePrevious)
: DelegatingDeserializationListener(Previous, DeletePrevious) {}
- void DeclRead(serialization::DeclID ID, const Decl *D) override {
+ void DeclRead(DeclID ID, const Decl *D) override {
llvm::outs() << "PCH DECL: " << D->getDeclKindName();
if (const NamedDecl *ND = dyn_cast<NamedDecl>(D)) {
llvm::outs() << " - ";
@@ -128,7 +128,7 @@ public:
: DelegatingDeserializationListener(Previous, DeletePrevious), Ctx(Ctx),
NamesToCheck(NamesToCheck) {}
- void DeclRead(serialization::DeclID ID, const Decl *D) override {
+ void DeclRead(DeclID ID, const Decl *D) override {
if (const NamedDecl *ND = dyn_cast<NamedDecl>(D))
if (NamesToCheck.find(ND->getNameAsString()) != NamesToCheck.end()) {
unsigned DiagID
diff --git a/clang/lib/Frontend/MultiplexConsumer.cpp b/clang/lib/Frontend/MultiplexConsumer.cpp
index 744ea70..9e885c8 100644
--- a/clang/lib/Frontend/MultiplexConsumer.cpp
+++ b/clang/lib/Frontend/MultiplexConsumer.cpp
@@ -52,8 +52,7 @@ void MultiplexASTDeserializationListener::TypeRead(
Listeners[i]->TypeRead(Idx, T);
}
-void MultiplexASTDeserializationListener::DeclRead(
- serialization::DeclID ID, const Decl *D) {
+void MultiplexASTDeserializationListener::DeclRead(DeclID ID, const Decl *D) {
for (size_t i = 0, e = Listeners.size(); i != e; ++i)
Listeners[i]->DeclRead(ID, D);
}