aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/AST/DeclBase.cpp
diff options
context:
space:
mode:
authorChuanqi Xu <yedeng.yd@linux.alibaba.com>2024-06-04 16:10:03 +0800
committerChuanqi Xu <yedeng.yd@linux.alibaba.com>2024-06-04 16:10:38 +0800
commitcb60667b6e762aa172b6ad06332465d69f0fd803 (patch)
tree1335e3b3df0c165f8ea71a8517d717558eab0720 /clang/lib/AST/DeclBase.cpp
parent842333750288a033cd7c4ca0c132d38a1982c187 (diff)
downloadllvm-cb60667b6e762aa172b6ad06332465d69f0fd803.zip
llvm-cb60667b6e762aa172b6ad06332465d69f0fd803.tar.gz
llvm-cb60667b6e762aa172b6ad06332465d69f0fd803.tar.bz2
Revert "[serialization] no transitive decl change (#92083)"
This reverts commit d8ec452db016f359feeec28994f6560b30b49824. This fails on LLDB macOS CI. See https://github.com/llvm/llvm-project/pull/92083 for details.
Diffstat (limited to 'clang/lib/AST/DeclBase.cpp')
-rw-r--r--clang/lib/AST/DeclBase.cpp39
1 files changed, 7 insertions, 32 deletions
diff --git a/clang/lib/AST/DeclBase.cpp b/clang/lib/AST/DeclBase.cpp
index f1a54f0..ffb2219 100644
--- a/clang/lib/AST/DeclBase.cpp
+++ b/clang/lib/AST/DeclBase.cpp
@@ -74,17 +74,18 @@ void *Decl::operator new(std::size_t Size, const ASTContext &Context,
GlobalDeclID ID, std::size_t Extra) {
// Allocate an extra 8 bytes worth of storage, which ensures that the
// resulting pointer will still be 8-byte aligned.
- static_assert(sizeof(uint64_t) >= alignof(Decl), "Decl won't be misaligned");
+ static_assert(sizeof(unsigned) * 2 >= alignof(Decl),
+ "Decl won't be misaligned");
void *Start = Context.Allocate(Size + Extra + 8);
void *Result = (char*)Start + 8;
- uint64_t *PrefixPtr = (uint64_t *)Result - 1;
+ unsigned *PrefixPtr = (unsigned *)Result - 2;
- *PrefixPtr = ID.get();
+ // Zero out the first 4 bytes; this is used to store the owning module ID.
+ PrefixPtr[0] = 0;
- // We leave the upper 16 bits to store the module IDs. 48 bits should be
- // sufficient to store a declaration ID.
- assert(*PrefixPtr < llvm::maskTrailingOnes<uint64_t>(48));
+ // Store the global declaration ID in the second 4 bytes.
+ PrefixPtr[1] = ID.get();
return Result;
}
@@ -110,28 +111,6 @@ void *Decl::operator new(std::size_t Size, const ASTContext &Ctx,
return ::operator new(Size + Extra, Ctx);
}
-GlobalDeclID Decl::getGlobalID() const {
- if (!isFromASTFile())
- return GlobalDeclID();
- // See the comments in `Decl::operator new` for details.
- uint64_t ID = *((const uint64_t *)this - 1);
- return GlobalDeclID(ID & llvm::maskTrailingOnes<uint64_t>(48));
-}
-
-unsigned Decl::getOwningModuleID() const {
- if (!isFromASTFile())
- return 0;
-
- uint64_t ID = *((const uint64_t *)this - 1);
- return ID >> 48;
-}
-
-void Decl::setOwningModuleID(unsigned ID) {
- assert(isFromASTFile() && "Only works on a deserialized declaration");
- uint64_t *IDAddress = (uint64_t *)this - 1;
- *IDAddress |= (uint64_t)ID << 48;
-}
-
Module *Decl::getOwningModuleSlow() const {
assert(isFromASTFile() && "Not from AST file?");
return getASTContext().getExternalSource()->getModule(getOwningModuleID());
@@ -2185,7 +2164,3 @@ DependentDiagnostic *DependentDiagnostic::Create(ASTContext &C,
return DD;
}
-
-unsigned DeclIDBase::getLocalDeclIndex() const {
- return ID & llvm::maskTrailingOnes<DeclID>(32);
-}