1 //===--- USRLocFinder.h - Clang refactoring library -----------------------===// 2 // 3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4 // See https://llvm.org/LICENSE.txt for license information. 5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 // 7 //===----------------------------------------------------------------------===// 8 /// 9 /// \file 10 /// Provides functionality for finding all instances of a USR in a given 11 /// AST. 12 /// 13 //===----------------------------------------------------------------------===// 14 15 #ifndef LLVM_CLANG_TOOLING_REFACTOR_RENAME_USR_LOC_FINDER_H 16 #define LLVM_CLANG_TOOLING_REFACTOR_RENAME_USR_LOC_FINDER_H 17 18 #include "clang/AST/AST.h" 19 #include "clang/Tooling/Core/Replacement.h" 20 #include "clang/Tooling/Refactoring/AtomicChange.h" 21 #include "clang/Tooling/Refactoring/Rename/SymbolOccurrences.h" 22 #include "llvm/ADT/StringRef.h" 23 #include <string> 24 #include <vector> 25 26 namespace clang { 27 namespace tooling { 28 29 /// Create atomic changes for renaming all symbol references which are 30 /// identified by the USRs set to a given new name. 31 /// 32 /// \param USRs The set containing USRs of a particular old symbol. 33 /// \param NewName The new name to replace old symbol name. 34 /// \param TranslationUnitDecl The translation unit declaration. 35 /// 36 /// \return Atomic changes for renaming. 37 std::vector<tooling::AtomicChange> 38 createRenameAtomicChanges(llvm::ArrayRef<std::string> USRs, 39 llvm::StringRef NewName, Decl *TranslationUnitDecl); 40 41 /// Finds the symbol occurrences for the symbol that's identified by the given 42 /// USR set. 43 /// 44 /// \return SymbolOccurrences that can be converted to AtomicChanges when 45 /// renaming. 46 SymbolOccurrences getOccurrencesOfUSRs(ArrayRef<std::string> USRs, 47 StringRef PrevName, Decl *Decl); 48 49 } // end namespace tooling 50 } // end namespace clang 51 52 #endif // LLVM_CLANG_TOOLING_REFACTOR_RENAME_USR_LOC_FINDER_H 53