1 //===--- USRFindingAction.h - Clang refactoring library -------------------===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
11 /// \brief Provides an action to find all relevant USRs at a point.
13 //===----------------------------------------------------------------------===//
15 #ifndef LLVM_CLANG_TOOLING_REFACTOR_RENAME_USR_FINDING_ACTION_H
16 #define LLVM_CLANG_TOOLING_REFACTOR_RENAME_USR_FINDING_ACTION_H
18 #include "clang/Basic/LLVM.h"
19 #include "llvm/ADT/ArrayRef.h"
27 class CompilerInstance;
32 /// Returns the canonical declaration that best represents a symbol that can be
35 /// The following canonicalization rules are currently used:
37 /// - A constructor is canonicalized to its class.
38 /// - A destructor is canonicalized to its class.
39 const NamedDecl *getCanonicalSymbolDeclaration(const NamedDecl *FoundDecl);
41 /// Returns the set of USRs that correspond to the given declaration.
42 std::vector<std::string> getUSRsForDeclaration(const NamedDecl *ND,
45 struct USRFindingAction {
46 USRFindingAction(ArrayRef<unsigned> SymbolOffsets,
47 ArrayRef<std::string> QualifiedNames, bool Force)
48 : SymbolOffsets(SymbolOffsets), QualifiedNames(QualifiedNames),
49 ErrorOccurred(false), Force(Force) {}
50 std::unique_ptr<ASTConsumer> newASTConsumer();
52 ArrayRef<std::string> getUSRSpellings() { return SpellingNames; }
53 ArrayRef<std::vector<std::string>> getUSRList() { return USRList; }
54 bool errorOccurred() { return ErrorOccurred; }
57 std::vector<unsigned> SymbolOffsets;
58 std::vector<std::string> QualifiedNames;
59 std::vector<std::string> SpellingNames;
60 std::vector<std::vector<std::string>> USRList;
65 } // end namespace tooling
66 } // end namespace clang
68 #endif // LLVM_CLANG_TOOLING_REFACTOR_RENAME_USR_FINDING_ACTION_H