[all-commits] [llvm/llvm-project] e6ec7c: [Clang][AST] Move NamespaceDecl bits to DeclContex...

Krystian Stasiowski via All-commits all-commits at lists.llvm.org
Mon Jul 15 10:58:17 PDT 2024


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: e6ec7c8f74d1be778f4ddf794d0e2fb63b0dc3be
      https://github.com/llvm/llvm-project/commit/e6ec7c8f74d1be778f4ddf794d0e2fb63b0dc3be
  Author: Krystian Stasiowski <sdkrystian at gmail.com>
  Date:   2024-07-15 (Mon, 15 Jul 2024)

  Changed paths:
    M clang-tools-extra/clang-tidy/bugprone/ForwardDeclarationNamespaceCheck.cpp
    M clang/include/clang/AST/Decl.h
    M clang/include/clang/AST/DeclBase.h
    M clang/lib/AST/ASTContext.cpp
    M clang/lib/AST/DeclBase.cpp
    M clang/lib/AST/DeclCXX.cpp
    M clang/lib/AST/ItaniumMangle.cpp
    M clang/lib/AST/JSONNodeDumper.cpp
    M clang/lib/AST/TextNodeDumper.cpp
    M clang/lib/Sema/SemaCodeComplete.cpp
    M clang/lib/Sema/SemaLookup.cpp
    M clang/lib/Serialization/ASTReaderDecl.cpp
    M clang/lib/Serialization/ASTWriterDecl.cpp
    M clang/tools/libclang/CXIndexDataConsumer.cpp

  Log Message:
  -----------
  [Clang][AST] Move NamespaceDecl bits to DeclContext (#98567)

Currently, `NamespaceDecl` has a member `AnonOrFirstNamespaceAndFlags`
which stores a few pieces of data:
- a bit indicating whether the namespace was declared `inline`, and
- a bit indicating whether the namespace was declared as a
_nested-namespace-definition_, and
- a pointer a `NamespaceDecl` that either stores:
- a pointer to the first declaration of that namespace if the
declaration is no the first declaration, or
- a pointer to the unnamed namespace that inhabits the namespace
otherwise.

`Redeclarable` already stores a pointer to the first declaration of an
entity, so it's unnecessary to store this in `NamespaceDecl`.
`DeclContext` has 8 bytes in which various bitfields can be stored for a
declaration, so it's not necessary to store these in `NamespaceDecl`
either. We only need to store a pointer to the unnamed namespace that
inhabits the first declaration of a namespace. This patch moves the two
bits currently stored in `NamespaceDecl` to `DeclContext`, and only
stores a pointer to the unnamed namespace that inhabits a namespace in
the first declaration of that namespace. Since `getOriginalNamespace`
always returns the same `NamespaceDecl` as `getFirstDecl`, this function
is removed to avoid confusion.



To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications


More information about the All-commits mailing list