diff options
author | Chuanqi Xu <yedeng.yd@linux.alibaba.com> | 2024-06-07 11:19:55 +0800 |
---|---|---|
committer | Chuanqi Xu <yedeng.yd@linux.alibaba.com> | 2024-06-07 11:29:09 +0800 |
commit | 4f70c5ec4a57e84642fa0772536f120cd9c75edb (patch) | |
tree | a65c42f97bfdecdf79cb153b1d5760c7e7141865 /clang/lib/AST/DeclBase.cpp | |
parent | 222e0a042c1c7c3b1aec7557bcb60d1543c1737a (diff) | |
download | llvm-4f70c5ec4a57e84642fa0772536f120cd9c75edb.zip llvm-4f70c5ec4a57e84642fa0772536f120cd9c75edb.tar.gz llvm-4f70c5ec4a57e84642fa0772536f120cd9c75edb.tar.bz2 |
Revert "[serialization] no transitive decl change (#92083)"
This reverts commit 5c104879c1a98eeb845c03e7c45206bd48e88f0c.
The ArmV7 bot is complaining the change breaks the alignment.
Diffstat (limited to 'clang/lib/AST/DeclBase.cpp')
-rw-r--r-- | clang/lib/AST/DeclBase.cpp | 40 |
1 files changed, 7 insertions, 33 deletions
diff --git a/clang/lib/AST/DeclBase.cpp b/clang/lib/AST/DeclBase.cpp index 7f1ed9c..1e9c879 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,29 +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 &= llvm::maskTrailingOnes<uint64_t>(48); - *IDAddress |= (uint64_t)ID << 48; -} - Module *Decl::getOwningModuleSlow() const { assert(isFromASTFile() && "Not from AST file?"); return getASTContext().getExternalSource()->getModule(getOwningModuleID()); @@ -2185,7 +2163,3 @@ DependentDiagnostic *DependentDiagnostic::Create(ASTContext &C, return DD; } - -unsigned DeclIDBase::getLocalDeclIndex() const { - return ID & llvm::maskTrailingOnes<DeclID>(32); -} |