Author: Zequan Wu Date: 2024-11-08T14:18:45-05:00 New Revision: e5796321cee0f6b3c2fbf33813d6b3af1ddd8f18
URL: https://github.com/llvm/llvm-project/commit/e5796321cee0f6b3c2fbf33813d6b3af1ddd8f18 DIFF: https://github.com/llvm/llvm-project/commit/e5796321cee0f6b3c2fbf33813d6b3af1ddd8f18.diff LOG: [clang] Avoid unnecessary call to clang::NamespaceDecl::isRedundantInlineQualifierFor(). (#115196) We observed 2X slowdown in lldb's expression evaluation with https://github.com/llvm/llvm-project/pull/109147 in some cases. It turns out that calling `isRedundantInlineQualifierFor` is quite expensive. Using short-circuit evaluation in the if statement to avoid unnecessary calls to that function. Added: Modified: clang/lib/AST/Decl.cpp Removed: ################################################################################ diff --git a/clang/lib/AST/Decl.cpp b/clang/lib/AST/Decl.cpp index 047f354b200745..f33d2fb1530d17 100644 --- a/clang/lib/AST/Decl.cpp +++ b/clang/lib/AST/Decl.cpp @@ -1738,13 +1738,12 @@ void NamedDecl::printNestedNameSpecifier(raw_ostream &OS, // Suppress inline namespace if it doesn't make the result ambiguous. if (Ctx->isInlineNamespace() && NameInScope) { - bool isRedundant = - cast<NamespaceDecl>(Ctx)->isRedundantInlineQualifierFor(NameInScope); if (P.SuppressInlineNamespace == PrintingPolicy::SuppressInlineNamespaceMode::All || (P.SuppressInlineNamespace == PrintingPolicy::SuppressInlineNamespaceMode::Redundant && - isRedundant)) { + cast<NamespaceDecl>(Ctx)->isRedundantInlineQualifierFor( + NameInScope))) { continue; } } _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits