clang 20.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
23namespace clang {
24class ASTConsumer;
25class ASTContext;
26class NamedDecl;
27
28namespace 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.
37const NamedDecl *getCanonicalSymbolDeclaration(const NamedDecl *FoundDecl);
38
39/// Returns the set of USRs that correspond to the given declaration.
40std::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
54private:
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
Forward-declares and imports various common LLVM datatypes that clang wants to use unqualified.
const NamedDecl * getCanonicalSymbolDeclaration(const NamedDecl *FoundDecl)
Returns the canonical declaration that best represents a symbol that can be renamed.
std::vector< std::string > getUSRsForDeclaration(const NamedDecl *ND, ASTContext &Context)
Returns the set of USRs that correspond to the given declaration.
The JSON file list parser is used to communicate input to InstallAPI.
#define false
Definition: stdbool.h:26
ArrayRef< std::vector< std::string > > getUSRList()
USRFindingAction(ArrayRef< unsigned > SymbolOffsets, ArrayRef< std::string > QualifiedNames, bool Force)
std::unique_ptr< ASTConsumer > newASTConsumer()
ArrayRef< std::string > getUSRSpellings()