1 //===--- USRFindingAction.h - Clang refactoring library -------------------===//
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
7 //===----------------------------------------------------------------------===//
10 /// Provides an action to find all relevant USRs at a point.
12 //===----------------------------------------------------------------------===//
14 #ifndef LLVM_CLANG_TOOLING_REFACTOR_RENAME_USR_FINDING_ACTION_H
15 #define LLVM_CLANG_TOOLING_REFACTOR_RENAME_USR_FINDING_ACTION_H
17 #include "clang/Basic/LLVM.h"
18 #include "llvm/ADT/ArrayRef.h"
26 class CompilerInstance;
31 /// Returns the canonical declaration that best represents a symbol that can be
34 /// The following canonicalization rules are currently used:
36 /// - A constructor is canonicalized to its class.
37 /// - A destructor is canonicalized to its class.
38 const NamedDecl *getCanonicalSymbolDeclaration(const NamedDecl *FoundDecl);
40 /// Returns the set of USRs that correspond to the given declaration.
41 std::vector<std::string> getUSRsForDeclaration(const NamedDecl *ND,
44 struct USRFindingAction {
45 USRFindingAction(ArrayRef<unsigned> SymbolOffsets,
46 ArrayRef<std::string> QualifiedNames, bool Force)
47 : SymbolOffsets(SymbolOffsets), QualifiedNames(QualifiedNames),
48 ErrorOccurred(false), Force(Force) {}
49 std::unique_ptr<ASTConsumer> newASTConsumer();
51 ArrayRef<std::string> getUSRSpellings() { return SpellingNames; }
52 ArrayRef<std::vector<std::string>> getUSRList() { return USRList; }
53 bool errorOccurred() { return ErrorOccurred; }
56 std::vector<unsigned> SymbolOffsets;
57 std::vector<std::string> QualifiedNames;
58 std::vector<std::string> SpellingNames;
59 std::vector<std::vector<std::string>> USRList;
64 } // end namespace tooling
65 } // end namespace clang
67 #endif // LLVM_CLANG_TOOLING_REFACTOR_RENAME_USR_FINDING_ACTION_H