[clang] [clang] Avoid unnecessary call to clang::NamespaceDecl::isRedundantInlineQualifierFor(). (PR #115196)
via cfe-commits
cfe-commits at lists.llvm.org
Wed Nov 6 11:10:49 PST 2024
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-clang
Author: Zequan Wu (ZequanWu)
<details>
<summary>Changes</summary>
We observed 2X slowdown in lldb's expression evaluation with https://github.com/llvm/llvm-project/pull/109147. It turns out that calling `isRedundantInlineQualifierFor` is quite expensive. Using short-circuit evaluation in the if statement to avoid unnecessary calls to that function.
---
Full diff: https://github.com/llvm/llvm-project/pull/115196.diff
1 Files Affected:
- (modified) clang/lib/AST/Decl.cpp (+2-3)
``````````diff
diff --git a/clang/lib/AST/Decl.cpp b/clang/lib/AST/Decl.cpp
index 8204e3509dd563..a65dc85e04a83d 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;
}
}
``````````
</details>
https://github.com/llvm/llvm-project/pull/115196
More information about the cfe-commits
mailing list