]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/llvm-project/clang/include/clang/Tooling/Refactoring/Rename/USRFindingAction.h
Fix a memory leak in if_delgroups() introduced in r334118.
[FreeBSD/FreeBSD.git] / contrib / llvm-project / clang / include / clang / Tooling / Refactoring / Rename / USRFindingAction.h
1 //===--- USRFindingAction.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 an action to find all relevant USRs at a point.
11 ///
12 //===----------------------------------------------------------------------===//
13
14 #ifndef LLVM_CLANG_TOOLING_REFACTOR_RENAME_USR_FINDING_ACTION_H
15 #define LLVM_CLANG_TOOLING_REFACTOR_RENAME_USR_FINDING_ACTION_H
16
17 #include "clang/Basic/LLVM.h"
18 #include "llvm/ADT/ArrayRef.h"
19
20 #include <string>
21 #include <vector>
22
23 namespace clang {
24 class ASTConsumer;
25 class ASTContext;
26 class CompilerInstance;
27 class NamedDecl;
28
29 namespace tooling {
30
31 /// Returns the canonical declaration that best represents a symbol that can be
32 /// renamed.
33 ///
34 /// The following canonicalization rules are currently used:
35 ///
36 /// - A constructor is canonicalized to its class.
37 /// - A destructor is canonicalized to its class.
38 const NamedDecl *getCanonicalSymbolDeclaration(const NamedDecl *FoundDecl);
39
40 /// Returns the set of USRs that correspond to the given declaration.
41 std::vector<std::string> getUSRsForDeclaration(const NamedDecl *ND,
42                                                ASTContext &Context);
43
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();
50
51   ArrayRef<std::string> getUSRSpellings() { return SpellingNames; }
52   ArrayRef<std::vector<std::string>> getUSRList() { return USRList; }
53   bool errorOccurred() { return ErrorOccurred; }
54
55 private:
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;
60   bool ErrorOccurred;
61   bool Force;
62 };
63
64 } // end namespace tooling
65 } // end namespace clang
66
67 #endif // LLVM_CLANG_TOOLING_REFACTOR_RENAME_USR_FINDING_ACTION_H