Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: llvm/llvm-project
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: main
Choose a base ref
...
head repository: llvm/llvm-project
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: users/mizvekov/ast-type-provide-inline-defs
Choose a head ref
  • 5 commits
  • 179 files changed
  • 1 contributor

Commits on Aug 22, 2025

  1. meat and potatoes

    mizvekov committed Aug 22, 2025
    Configuration menu
    Copy the full SHA
    6560866 View commit details
    Browse the repository at this point in the history

Commits on Aug 23, 2025

  1. [clang] AST: fix getAs canonicalization of leaf types

    Before this patch, the application of getAs and castAs on a leaf type
    would always produce a canonical type, which is undesirable because
    some of these types can be sugared.
    
    The user expectation is that getAs only removes top level sugar nodes, leaving
    all the type sugar on the returned node, but it had an optimization intended
    for type nodes with no sugar: for these, we can skip the expensive traversal
    of the top level sugar with a simple canonicalization followed by dyn_cast.
    
    The problem is that the concept of leaf type does not map well to what is
    correct to apply this optimization to.
    
    This patch replaces the concept of leaf types with 'always canonical' types,
    and only applies the canonicalization strategy on them.
    
    In order to avoid the performance regression this would cause, as most current
    users do not care about type sugar, this patch also replaces all of these uses
    with alternative cast functions which operate through canonicalization.
    
    * Introduces castAs variants to complement the getAsTagDecl and derived
      variants.
    * Introduces getAsEnumDecl and castAsEnumDecl, complementing the current set, so
      that all TagDecls are covered.
    * Introduces getAsCanonical and castAsCanonical, for faster casting when only
      the canonical type is desired.
    
    The getAsTagDecl and related functions are not provided inline, because
    of the circular dependencies that would involve. So this patch causes a
    small overall performance regression:
    <img width="1461" height="18" alt="image" src="https://github.com/user-attachments/assets/061dfb14-9506-4623-91ec-0f02f585d1dd" />
    
    This will be fixed in a later patch, bringing the whole thing back to a positive
    performance improvement overall:
    <img width="1462" height="18" alt="image" src="https://github.com/user-attachments/assets/c237e68f-f696-44f4-acc6-a7c7ba5b0976" />
    mizvekov committed Aug 23, 2025
    Configuration menu
    Copy the full SHA
    bdda18b View commit details
    Browse the repository at this point in the history
  2. [clang] NFC: rename clang/include/clang/AST/Type.h to TypeBase.h

    This is a preparatory patch, to be able to provide inline definitions
    for `Type` functions which depend on `Decl{,CXX}.h`. As the latter also
    depends on `Type.h`, this would not be possible without some reorganizing.
    
    Splitting this rename into its own patch allows git to track this as a rename,
    and preserve all git history, and not force any code reformatting.
    
    A later NFC patch will reintroduce `Type.h` as redirection to `TypeBase.h`,
    rewriting most places back to directly including `Type.h` instead of `TypeBase.h`,
    leaving only a handful of places where this is necessary.
    
    Then yet a later patch will exploit this by making more stuff inline.
    mizvekov committed Aug 23, 2025
    Configuration menu
    Copy the full SHA
    7742ecd View commit details
    Browse the repository at this point in the history
  3. [clang] NFC: reintroduce clang/include/clang/AST/Type.h

    This reintroduces `Type.h`, having earlier been renamed to `TypeBase.h`,
    as a redirection to `TypeBase.h`, and redirects most users to include the
    former instead.
    
    This is a preparatory patch for being able to provide inline definitions
    for `Type` methods which would otherwise cause a circular dependency with
    `Decl{,CXX}.h`.
    
    Doing these operations into their own NFC patch helps the git rename
    detection logic work, preserving the history.
    
    This patch makes clang just a little slower to build (~0.17%), just
    because it makes more code indirectly include `DeclCXX.h`.
    mizvekov committed Aug 23, 2025
    Configuration menu
    Copy the full SHA
    ae2c34d View commit details
    Browse the repository at this point in the history
  4. [clang] NFC: Provide inline definitions for {get,cast}TagDecl and fri…

    …ends
    
    This is a small performance improvement:
    
    This helps recover the performance lost in #155028, reversing it
    into a small positive instead.
    mizvekov committed Aug 23, 2025
    Configuration menu
    Copy the full SHA
    8978115 View commit details
    Browse the repository at this point in the history
Loading