clang 8.0.0

USRFindingAction.h
Go to the documentation of this file.
1 //===--- USRFindingAction.h - Clang refactoring library -------------------===//
2 //
3 // The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 ///
10 /// \file
11 /// Provides an action to find all relevant USRs at a point.
12 ///
13 //===----------------------------------------------------------------------===//
14
15 #ifndef LLVM_CLANG_TOOLING_REFACTOR_RENAME_USR_FINDING_ACTION_H
16 #define LLVM_CLANG_TOOLING_REFACTOR_RENAME_USR_FINDING_ACTION_H
17
18 #include "clang/Basic/LLVM.h"
19 #include "llvm/ADT/ArrayRef.h"
20
21 #include <string>
22 #include <vector>
23
24 namespace clang {
25 class ASTConsumer;
26 class ASTContext;
27 class CompilerInstance;
28 class NamedDecl;
29
30 namespace tooling {
31
32 /// Returns the canonical declaration that best represents a symbol that can be
33 /// renamed.
34 ///
35 /// The following canonicalization rules are currently used:
36 ///
37 /// - A constructor is canonicalized to its class.
38 /// - A destructor is canonicalized to its class.
39 const NamedDecl *getCanonicalSymbolDeclaration(const NamedDecl *FoundDecl);
40
41 /// Returns the set of USRs that correspond to the given declaration.
42 std::vector<std::string> getUSRsForDeclaration(const NamedDecl *ND,
43 ASTContext &Context);
44
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();
51
52 ArrayRef<std::string> getUSRSpellings() { return SpellingNames; }
53 ArrayRef<std::vector<std::string>> getUSRList() { return USRList; }
54 bool errorOccurred() { return ErrorOccurred; }
55
56 private:
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;
61 bool ErrorOccurred;
62 bool Force;
63 };
64
65 } // end namespace tooling
66 } // end namespace clang
67
68 #endif // LLVM_CLANG_TOOLING_REFACTOR_RENAME_USR_FINDING_ACTION_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:177
clang::tooling::USRFindingAction::USRFindingAction
USRFindingAction(ArrayRef< unsigned > SymbolOffsets, ArrayRef< std::string > QualifiedNames, bool Force)
Definition: USRFindingAction.h:46
LLVM.h
Forward-declares and imports various common LLVM datatypes that clang wants to use unqualified...
llvm::ArrayRef< unsigned >
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:42
false
#define false
Definition: stdbool.h:33
clang::tooling::USRFindingAction::getUSRSpellings
ArrayRef< std::string > getUSRSpellings()
Definition: USRFindingAction.h:52
clang::tooling::USRFindingAction
Definition: USRFindingAction.h:45
clang::tooling::USRFindingAction::errorOccurred
bool errorOccurred()
Definition: USRFindingAction.h:54
clang
Dataflow Directional Tag Classes.
Definition: CFGReachabilityAnalysis.h:22
clang::tooling::USRFindingAction::newASTConsumer
std::unique_ptr< ASTConsumer > newASTConsumer()
Definition: USRFindingAction.cpp:267
clang::tooling::USRFindingAction::getUSRList
ArrayRef< std::vector< std::string > > getUSRList()
Definition: USRFindingAction.h:53