clang  15.0.0git
USRFindingAction.h
Go to the documentation of this file.
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_REFACTORING_RENAME_USRFINDINGACTION_H
15 #define LLVM_CLANG_TOOLING_REFACTORING_RENAME_USRFINDINGACTION_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 NamedDecl;
27 
28 namespace tooling {
29 
30 /// Returns the canonical declaration that best represents a symbol that can be
31 /// renamed.
32 ///
33 /// The following canonicalization rules are currently used:
34 ///
35 /// - A constructor is canonicalized to its class.
36 /// - A destructor is canonicalized to its class.
37 const NamedDecl *getCanonicalSymbolDeclaration(const NamedDecl *FoundDecl);
38 
39 /// Returns the set of USRs that correspond to the given declaration.
40 std::vector<std::string> getUSRsForDeclaration(const NamedDecl *ND,
41  ASTContext &Context);
42 
45  ArrayRef<std::string> QualifiedNames, bool Force)
46  : SymbolOffsets(SymbolOffsets), QualifiedNames(QualifiedNames),
47  ErrorOccurred(false), Force(Force) {}
48  std::unique_ptr<ASTConsumer> newASTConsumer();
49 
50  ArrayRef<std::string> getUSRSpellings() { return SpellingNames; }
52  bool errorOccurred() { return ErrorOccurred; }
53 
54 private:
55  std::vector<unsigned> SymbolOffsets;
56  std::vector<std::string> QualifiedNames;
57  std::vector<std::string> SpellingNames;
58  std::vector<std::vector<std::string>> USRList;
59  bool ErrorOccurred;
60  bool Force;
61 };
62 
63 } // end namespace tooling
64 } // end namespace clang
65 
66 #endif // LLVM_CLANG_TOOLING_REFACTORING_RENAME_USRFINDINGACTION_H
clang::tooling::USRFindingAction::getUSRList
ArrayRef< std::vector< std::string > > getUSRList()
Definition: USRFindingAction.h:51
clang::tooling::USRFindingAction
Definition: USRFindingAction.h:43
clang::tooling::getCanonicalSymbolDeclaration
const NamedDecl * getCanonicalSymbolDeclaration(const NamedDecl *FoundDecl)
Returns the canonical declaration that best represents a symbol that can be renamed.
Definition: USRFindingAction.cpp:41
clang::tooling::USRFindingAction::newASTConsumer
std::unique_ptr< ASTConsumer > newASTConsumer()
Definition: USRFindingAction.cpp:307
clang::tooling::USRFindingAction::errorOccurred
bool errorOccurred()
Definition: USRFindingAction.h:52
false
#define false
Definition: stdbool.h:22
llvm::ArrayRef< unsigned >
LLVM.h
clang::tooling::getUSRsForDeclaration
std::vector< std::string > getUSRsForDeclaration(const NamedDecl *ND, ASTContext &Context)
Returns the set of USRs that correspond to the given declaration.
Definition: USRFindingAction.cpp:217
clang
Definition: CalledOnceCheck.h:17
clang::tooling::USRFindingAction::getUSRSpellings
ArrayRef< std::string > getUSRSpellings()
Definition: USRFindingAction.h:50
clang::tooling::USRFindingAction::USRFindingAction
USRFindingAction(ArrayRef< unsigned > SymbolOffsets, ArrayRef< std::string > QualifiedNames, bool Force)
Definition: USRFindingAction.h:44