https://github.com/Xazax-hun created https://github.com/llvm/llvm-project/pull/244863
CallDescription::matchNameOnly printed the name of every constructor, destructor and operator call into a string to compare it against each CallDescription. Reject operator names unless the description starts with "operator" and destructor names unless it starts with '~', and compare constructor and destructor names to the record identifier, which is what printing them yields for named records. On some LLVM TUs (GVN, LiveVariables, RegionStore, SemaExpr) this reduces the instructions of the static analyzer by 0.4-1.0% and the cycles by 0.4-1.1%; peak memory is unchanged within noise. The diagnostics are unchanged. Assisted-by: Claude Opus 5.5 From 57ec9d58e8540b28824519fd6214fbb4696cfa3d Mon Sep 17 00:00:00 2001 From: Gabor Horvath <[email protected]> Date: Sat, 21 Nov 2026 09:09:56 +0000 Subject: [PATCH] [analyzer] Avoid printing names in CallDescription::matchNameOnly CallDescription::matchNameOnly printed the name of every constructor, destructor and operator call into a string to compare it against each CallDescription. Reject operator names unless the description starts with "operator" and destructor names unless it starts with '~', and compare constructor and destructor names to the record identifier, which is what printing them yields for named records. On some LLVM TUs (GVN, LiveVariables, RegionStore, SemaExpr) this reduces the instructions of the static analyzer by 0.4-1.0% and the cycles by 0.4-1.1%; peak memory is unchanged within noise. The diagnostics are unchanged. Assisted-by: Claude Opus 5.5 --- .../StaticAnalyzer/Core/CallDescription.cpp | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/clang/lib/StaticAnalyzer/Core/CallDescription.cpp b/clang/lib/StaticAnalyzer/Core/CallDescription.cpp index 4da12f776d20c7..f94714841c86f0 100644 --- a/clang/lib/StaticAnalyzer/Core/CallDescription.cpp +++ b/clang/lib/StaticAnalyzer/Core/CallDescription.cpp @@ -76,6 +76,29 @@ bool ento::CallDescription::matchNameOnly(const NamedDecl *ND) const { return NameII == *II; // Fast case. } + // Avoid the stringification below where the printed name is known. + StringRef FuncName = getFunctionName(); + switch (Name.getNameKind()) { + case DeclarationName::CXXDestructorName: + if (!FuncName.consume_front("~")) + return false; + [[fallthrough]]; + case DeclarationName::CXXConstructorName: + // Constructor and destructor names are printed using the record name. + if (const auto *RT = Name.getCXXNameType()->getAsCanonical<RecordType>()) + if (const IdentifierInfo *RecordII = RT->getDecl()->getIdentifier()) + return RecordII->getName() == FuncName; + break; + case DeclarationName::CXXOperatorName: + case DeclarationName::CXXLiteralOperatorName: + case DeclarationName::CXXConversionFunctionName: + if (!FuncName.starts_with("operator")) + return false; + break; + default: + break; + } + // Fallback to the slow stringification and comparison for: // C++ overloaded operators, constructors, destructors, etc. // FIXME This comparison is way SLOWER than comparing pointers. _______________________________________________ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
