[clang] [Clang] Optimize some `getBeginLoc` implementations (PR #141058)
Younan Zhang via cfe-commits
cfe-commits at lists.llvm.org
Thu May 22 07:02:56 PDT 2025
================
@@ -296,14 +298,18 @@ class NestedNameSpecifierLoc {
/// Retrieve the location of the beginning of this
/// nested-name-specifier.
SourceLocation getBeginLoc() const {
- return getSourceRange().getBegin();
+ if (!Qualifier)
+ return SourceLocation();
+
+ NestedNameSpecifierLoc First = *this;
+ while (NestedNameSpecifierLoc Prefix = First.getPrefix())
+ First = Prefix;
+ return First.getLocalSourceRange().getBegin();
----------------
zyn0217 wrote:
I didn't see the differences of changes on these functions... Are they related?
https://github.com/llvm/llvm-project/pull/141058
More information about the cfe-commits
mailing list