clang
22.0.0git
include
clang
Tooling
Refactoring
Rename
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
43
struct
USRFindingAction
{
44
USRFindingAction
(
ArrayRef<unsigned>
SymbolOffsets,
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; }
51
ArrayRef<std::vector<std::string>
>
getUSRList
() {
return
USRList; }
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
LLVM.h
Forward-declares and imports various common LLVM datatypes that clang wants to use unqualified.
clang::ASTConsumer
ASTConsumer - This is an abstract interface that should be implemented by clients that read ASTs.
Definition
ASTConsumer.h:34
clang::ASTContext
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
Definition
ASTContext.h:188
clang::NamedDecl
This represents a decl that may have a name.
Definition
Decl.h:273
llvm::ArrayRef
Definition
LLVM.h:31
clang::tooling
Definition
AllTUsExecution.h:22
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:34
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:210
clang
The JSON file list parser is used to communicate input to InstallAPI.
Definition
CalledOnceCheck.h:17
false
#define false
Definition
stdbool.h:26
clang::tooling::USRFindingAction::errorOccurred
bool errorOccurred()
Definition
USRFindingAction.h:52
clang::tooling::USRFindingAction::getUSRList
ArrayRef< std::vector< std::string > > getUSRList()
Definition
USRFindingAction.h:51
clang::tooling::USRFindingAction::USRFindingAction
USRFindingAction(ArrayRef< unsigned > SymbolOffsets, ArrayRef< std::string > QualifiedNames, bool Force)
Definition
USRFindingAction.h:44
clang::tooling::USRFindingAction::newASTConsumer
std::unique_ptr< ASTConsumer > newASTConsumer()
Definition
USRFindingAction.cpp:301
clang::tooling::USRFindingAction::getUSRSpellings
ArrayRef< std::string > getUSRSpellings()
Definition
USRFindingAction.h:50
Generated on
for clang by
1.14.0