-
Notifications
You must be signed in to change notification settings - Fork 14.8k
Comparing changes
Open a pull request
base repository: llvm/llvm-project
base: main
head repository: llvm/llvm-project
compare: users/mizvekov/ast-type-provide-inline-defs
- 5 commits
- 179 files changed
- 1 contributor
Commits on Aug 22, 2025
-
Configuration menu - View commit details
-
Copy full SHA for 6560866 - Browse repository at this point
Copy the full SHA 6560866View commit details
Commits on Aug 23, 2025
-
[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" />
Configuration menu - View commit details
-
Copy full SHA for bdda18b - Browse repository at this point
Copy the full SHA bdda18bView commit details -
[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.
Configuration menu - View commit details
-
Copy full SHA for 7742ecd - Browse repository at this point
Copy the full SHA 7742ecdView commit details -
[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`.
Configuration menu - View commit details
-
Copy full SHA for ae2c34d - Browse repository at this point
Copy the full SHA ae2c34dView commit details -
[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.
Configuration menu - View commit details
-
Copy full SHA for 8978115 - Browse repository at this point
Copy the full SHA 8978115View commit details
This comparison is taking too long to generate.
Unfortunately it looks like we can’t render this comparison for you right now. It might be too big, or there might be something weird with your repository.
You can try running this command locally to see the comparison on your machine:
git diff main...users/mizvekov/ast-type-provide-inline-defs