[all-commits] [llvm/llvm-project] 63542d: meat and potatoes
Matheus Izvekov via All-commits
all-commits at lists.llvm.org
Tue Aug 26 12:47:07 PDT 2025
Branch: refs/heads/users/mizvekov/improve-type-helpers
Home: https://github.com/llvm/llvm-project
Commit: 63542d5cdeccb17b9125430d0a984f45d58e208c
https://github.com/llvm/llvm-project/commit/63542d5cdeccb17b9125430d0a984f45d58e208c
Author: Matheus Izvekov <mizvekov at gmail.com>
Date: 2025-08-26 (Tue, 26 Aug 2025)
Changed paths:
M clang/include/clang/AST/Type.h
M clang/include/clang/Basic/TypeNodes.td
M clang/lib/AST/Type.cpp
M clang/test/CXX/drs/cwg0xx.cpp
M clang/test/CXX/drs/cwg3xx.cpp
M clang/test/ExtractAPI/class_template_param_inheritance.cpp
M clang/utils/TableGen/ASTTableGen.h
M clang/utils/TableGen/ClangTypeNodesEmitter.cpp
Log Message:
-----------
meat and potatoes
Commit: 39b94875ca70f92580b1d297f92c039c927132c4
https://github.com/llvm/llvm-project/commit/39b94875ca70f92580b1d297f92c039c927132c4
Author: Matheus Izvekov <mizvekov at gmail.com>
Date: 2025-08-26 (Tue, 26 Aug 2025)
Changed paths:
M clang-tools-extra/clang-tidy/bugprone/EasilySwappableParametersCheck.cpp
M clang-tools-extra/clang-tidy/cppcoreguidelines/MissingStdForwardCheck.cpp
M clang-tools-extra/clang-tidy/cppcoreguidelines/ProTypeMemberInitCheck.cpp
M clang-tools-extra/clang-tidy/misc/UnusedUsingDeclsCheck.cpp
M clang-tools-extra/clang-tidy/modernize/UseScopedLockCheck.cpp
M clang-tools-extra/clang-tidy/readability/SuspiciousCallArgumentCheck.cpp
M clang-tools-extra/clangd/refactor/tweaks/PopulateSwitch.cpp
M clang/lib/AST/ASTContext.cpp
M clang/lib/AST/ByteCode/Compiler.cpp
M clang/lib/AST/ByteCode/Pointer.cpp
M clang/lib/AST/CXXInheritance.cpp
M clang/lib/AST/Decl.cpp
M clang/lib/AST/DeclCXX.cpp
M clang/lib/AST/DeclarationName.cpp
M clang/lib/AST/ExprConstant.cpp
M clang/lib/AST/InheritViz.cpp
M clang/lib/AST/ItaniumMangle.cpp
M clang/lib/AST/JSONNodeDumper.cpp
M clang/lib/AST/RecordLayoutBuilder.cpp
M clang/lib/AST/TextNodeDumper.cpp
M clang/lib/AST/Type.cpp
M clang/lib/AST/TypePrinter.cpp
M clang/lib/CodeGen/ABIInfoImpl.cpp
M clang/lib/CodeGen/CGCall.cpp
M clang/lib/CodeGen/CGDebugInfo.cpp
M clang/lib/CodeGen/CGExprAgg.cpp
M clang/lib/CodeGen/CGExprCXX.cpp
M clang/lib/CodeGen/CGExprScalar.cpp
M clang/lib/CodeGen/CGNonTrivialStruct.cpp
M clang/lib/CodeGen/CGObjCMac.cpp
M clang/lib/CodeGen/CodeGenModule.cpp
M clang/lib/CodeGen/CodeGenTBAA.cpp
M clang/lib/CodeGen/HLSLBufferLayoutBuilder.cpp
M clang/lib/CodeGen/SwiftCallingConv.cpp
M clang/lib/CodeGen/Targets/AArch64.cpp
M clang/lib/CodeGen/Targets/ARC.cpp
M clang/lib/CodeGen/Targets/ARM.cpp
M clang/lib/CodeGen/Targets/DirectX.cpp
M clang/lib/CodeGen/Targets/Lanai.cpp
M clang/lib/CodeGen/Targets/LoongArch.cpp
M clang/lib/CodeGen/Targets/Mips.cpp
M clang/lib/CodeGen/Targets/RISCV.cpp
M clang/lib/CodeGen/Targets/SPIR.cpp
M clang/lib/CodeGen/Targets/X86.cpp
M clang/lib/CodeGen/Targets/XCore.cpp
M clang/lib/Frontend/Rewrite/RewriteModernObjC.cpp
M clang/lib/Index/USRGeneration.cpp
M clang/lib/Sema/SemaBPF.cpp
M clang/lib/Sema/SemaCast.cpp
M clang/lib/Sema/SemaChecking.cpp
M clang/lib/Sema/SemaDeclAttr.cpp
M clang/lib/Sema/SemaDeclCXX.cpp
M clang/lib/Sema/SemaExpr.cpp
M clang/lib/Sema/SemaExprCXX.cpp
M clang/lib/Sema/SemaExprObjC.cpp
M clang/lib/Sema/SemaInit.cpp
M clang/lib/Sema/SemaObjC.cpp
M clang/lib/Sema/SemaOverload.cpp
M clang/lib/Sema/SemaStmt.cpp
M clang/lib/Sema/SemaStmtAsm.cpp
M clang/lib/Sema/SemaTemplate.cpp
M clang/lib/Sema/SemaTemplateDeduction.cpp
M clang/lib/Sema/SemaTemplateDeductionGuide.cpp
M clang/lib/Sema/SemaTypeTraits.cpp
M clang/lib/Sema/TreeTransform.h
M clang/lib/StaticAnalyzer/Checkers/LLVMConventionsChecker.cpp
M clang/lib/StaticAnalyzer/Checkers/WebKit/PtrTypesSemantics.cpp
M clang/lib/StaticAnalyzer/Core/RegionStore.cpp
Log Message:
-----------
[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" />
Compare: https://github.com/llvm/llvm-project/compare/745eb0bb2a04...39b94875ca70
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