diff options
author | Nikolas Klauser <nikolasklauser@berlin.de> | 2024-04-14 12:25:49 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-04-14 12:25:49 +0200 |
commit | ed06b847d4e77d0b81fa6b095366bb070db57846 (patch) | |
tree | 341e3da26ffe169228fa3ebe0741b0fcdad10447 /clang/lib/AST/DeclBase.cpp | |
parent | d48d6ba9477aa380cd5a71f899d3cb6d629f175b (diff) | |
download | llvm-ed06b847d4e77d0b81fa6b095366bb070db57846.zip llvm-ed06b847d4e77d0b81fa6b095366bb070db57846.tar.gz llvm-ed06b847d4e77d0b81fa6b095366bb070db57846.tar.bz2 |
Revert "[Clang] Reduce the size of Decl and classes derived from it" (#88654)
Reverts llvm/llvm-project#87361
On 32 bit platforms there is only a single bit available in the
`DeclCtx`, resulting in an assertion failure.
Diffstat (limited to 'clang/lib/AST/DeclBase.cpp')
-rw-r--r-- | clang/lib/AST/DeclBase.cpp | 31 |
1 files changed, 9 insertions, 22 deletions
diff --git a/clang/lib/AST/DeclBase.cpp b/clang/lib/AST/DeclBase.cpp index 8c83c71..66a727d 100644 --- a/clang/lib/AST/DeclBase.cpp +++ b/clang/lib/AST/DeclBase.cpp @@ -52,8 +52,6 @@ using namespace clang; -static_assert(sizeof(Decl) <= 32, "Decl grew beyond 32 bytes!"); - //===----------------------------------------------------------------------===// // Statistics //===----------------------------------------------------------------------===// @@ -132,7 +130,7 @@ const char *Decl::getDeclKindName() const { } void Decl::setInvalidDecl(bool Invalid) { - DeclCtxWithInvalidDeclAndHasAttrs.setInt(Invalid); + InvalidDecl = Invalid; assert(!isa<TagDecl>(this) || !cast<TagDecl>(this)->isCompleteDefinition()); if (!Invalid) { return; @@ -336,9 +334,7 @@ void PrettyStackTraceDecl::print(raw_ostream &OS) const { Decl::~Decl() = default; void Decl::setDeclContext(DeclContext *DC) { - auto InnerPtr = DeclCtxWithInvalidDeclAndHasAttrs.getPointer(); - InnerPtr.setPointer(DC); - DeclCtxWithInvalidDeclAndHasAttrs.setPointer(InnerPtr); + DeclCtx = DC; } void Decl::setLexicalDeclContext(DeclContext *DC) { @@ -368,16 +364,12 @@ void Decl::setLexicalDeclContext(DeclContext *DC) { void Decl::setDeclContextsImpl(DeclContext *SemaDC, DeclContext *LexicalDC, ASTContext &Ctx) { if (SemaDC == LexicalDC) { - auto InnerPtr = DeclCtxWithInvalidDeclAndHasAttrs.getPointer(); - InnerPtr.setPointer(SemaDC); - DeclCtxWithInvalidDeclAndHasAttrs.setPointer(InnerPtr); + DeclCtx = SemaDC; } else { auto *MDC = new (Ctx) Decl::MultipleDC(); MDC->SemanticDC = SemaDC; MDC->LexicalDC = LexicalDC; - auto InnerPtr = DeclCtxWithInvalidDeclAndHasAttrs.getPointer(); - InnerPtr.setPointer(MDC); - DeclCtxWithInvalidDeclAndHasAttrs.setPointer(InnerPtr); + DeclCtx = MDC; } } @@ -964,24 +956,19 @@ unsigned Decl::getIdentifierNamespaceForKind(Kind DeclKind) { } void Decl::setAttrsImpl(const AttrVec &attrs, ASTContext &Ctx) { - assert(!hasAttrs() && "Decl already contains attrs."); + assert(!HasAttrs && "Decl already contains attrs."); AttrVec &AttrBlank = Ctx.getDeclAttrs(this); assert(AttrBlank.empty() && "HasAttrs was wrong?"); AttrBlank = attrs; - auto InnerPtr = DeclCtxWithInvalidDeclAndHasAttrs.getPointer(); - InnerPtr.setInt(true); - DeclCtxWithInvalidDeclAndHasAttrs.setPointer(InnerPtr); + HasAttrs = true; } void Decl::dropAttrs() { - if (!hasAttrs()) - return; + if (!HasAttrs) return; - auto InnerPtr = DeclCtxWithInvalidDeclAndHasAttrs.getPointer(); - InnerPtr.setInt(false); - DeclCtxWithInvalidDeclAndHasAttrs.setPointer(InnerPtr); + HasAttrs = false; getASTContext().eraseDeclAttrs(this); } @@ -1009,7 +996,7 @@ void Decl::addAttr(Attr *A) { } const AttrVec &Decl::getAttrs() const { - assert(hasAttrs() && "No attrs to get!"); + assert(HasAttrs && "No attrs to get!"); return getASTContext().getDeclAttrs(this); } |