From d86cc73bbfd9a22d9a0d498d72c9b2ee235128e9 Mon Sep 17 00:00:00 2001 From: Chuanqi Xu Date: Thu, 25 Apr 2024 11:43:13 +0800 Subject: [NFC] [Serialization] Avoid using DeclID directly as much as possible This patch tries to remove all the direct use of DeclID except the real low level reading and writing. All the use of DeclID is converted to the use of LocalDeclID or GlobalDeclID. This is helpful to increase the readability and type safety. --- clang/lib/Frontend/ASTUnit.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'clang/lib/Frontend/ASTUnit.cpp') diff --git a/clang/lib/Frontend/ASTUnit.cpp b/clang/lib/Frontend/ASTUnit.cpp index 361331d..2f75313e 100644 --- a/clang/lib/Frontend/ASTUnit.cpp +++ b/clang/lib/Frontend/ASTUnit.cpp @@ -1067,7 +1067,7 @@ public: std::vector takeTopLevelDecls() { return std::move(TopLevelDecls); } - std::vector takeTopLevelDeclIDs() { + std::vector takeTopLevelDeclIDs() { return std::move(TopLevelDeclIDs); } @@ -1101,7 +1101,7 @@ public: private: unsigned Hash = 0; std::vector TopLevelDecls; - std::vector TopLevelDeclIDs; + std::vector TopLevelDeclIDs; llvm::SmallVector PreambleDiags; }; @@ -1471,7 +1471,9 @@ void ASTUnit::RealizeTopLevelDeclsFromPreamble() { for (const auto TopLevelDecl : TopLevelDeclsInPreamble) { // Resolve the declaration ID to an actual declaration, possibly // deserializing the declaration in the process. - if (Decl *D = Source.GetExternalDecl(TopLevelDecl)) + // + // FIMXE: We shouldn't convert a LocalDeclID to GlobalDeclID directly. + if (Decl *D = Source.GetExternalDecl(GlobalDeclID(TopLevelDecl.get()))) Resolved.push_back(D); } TopLevelDeclsInPreamble.clear(); -- cgit v1.1