llvmorg-github-actions[bot] wrote:
<!--LLVM PR SUMMARY COMMENT--> @llvm/pr-subscribers-clang @llvm/pr-subscribers-clang-static-analyzer-1 Author: Gábor Horváth (Xazax-hun) <details> <summary>Changes</summary> 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 --- Full diff: https://github.com/llvm/llvm-project/pull/244863.diff 1 Files Affected: - (modified) clang/lib/StaticAnalyzer/Core/CallDescription.cpp (+23) ``````````diff diff --git a/clang/lib/StaticAnalyzer/Core/CallDescription.cpp b/clang/lib/StaticAnalyzer/Core/CallDescription.cpp index 4da12f776d20c..f94714841c86f 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. `````````` </details> https://github.com/llvm/llvm-project/pull/244863 _______________________________________________ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
