Skip to content

Commit 52552ce

Browse files
committed
Reapply "[NFC] Change the return type of getTraversalScope to ArrayRef"
vitalybuka identified a fix here that fixes the issue, and lets us make fewer copies! This applies his patch plus reapplys the original. This reverts commit c4c29b9.
1 parent c4c29b9 commit 52552ce

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

clang-tools-extra/clangd/refactor/tweaks/AnnotateHighlightings.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,8 @@ Expected<Tweak::Effect> AnnotateHighlightings::apply(const Selection &Inputs) {
5151
*Inputs.AST, /*IncludeInactiveRegionTokens=*/true);
5252
} else {
5353
// Store the existing scopes.
54-
const auto &BackupScopes = Inputs.AST->getASTContext().getTraversalScope();
54+
const std::vector<Decl *> BackupScopes =
55+
Inputs.AST->getASTContext().getTraversalScope();
5556
// Narrow the traversal scope to the selected node.
5657
Inputs.AST->getASTContext().setTraversalScope(
5758
{const_cast<Decl *>(CommonDecl)});

clang/include/clang/AST/ASTContext.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -723,7 +723,7 @@ class ASTContext : public RefCountedBase<ASTContext> {
723723
// (However they are still accessible via TranslationUnitDecl->decls())
724724
//
725725
// Changing the scope clears the parent cache, which is expensive to rebuild.
726-
std::vector<Decl *> getTraversalScope() const { return TraversalScope; }
726+
ArrayRef<Decl *> getTraversalScope() const { return TraversalScope; }
727727
void setTraversalScope(const std::vector<Decl *> &);
728728

729729
/// Forwards to get node parents from the ParentMapContext. New callers should

0 commit comments

Comments
 (0)