1 //===--- USRFinder.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 /// Methods for determining the USR of a symbol at a location in source
11 /// code.
12 ///
13 //===----------------------------------------------------------------------===//
14 
15 #ifndef LLVM_CLANG_TOOLING_REFACTORING_RENAME_USRFINDER_H
16 #define LLVM_CLANG_TOOLING_REFACTORING_RENAME_USRFINDER_H
17 
18 #include "clang/AST/AST.h"
19 #include "clang/AST/ASTContext.h"
20 #include <string>
21 #include <vector>
22 
23 namespace clang {
24 
25 class ASTContext;
26 class Decl;
27 class SourceLocation;
28 class NamedDecl;
29 
30 namespace tooling {
31 
32 // Given an AST context and a point, returns a NamedDecl identifying the symbol
33 // at the point. Returns null if nothing is found at the point.
34 const NamedDecl *getNamedDeclAt(const ASTContext &Context,
35                                 const SourceLocation Point);
36 
37 // Given an AST context and a fully qualified name, returns a NamedDecl
38 // identifying the symbol with a matching name. Returns null if nothing is
39 // found for the name.
40 const NamedDecl *getNamedDeclFor(const ASTContext &Context,
41                                  const std::string &Name);
42 
43 // Converts a Decl into a USR.
44 std::string getUSRForDecl(const Decl *Decl);
45 
46 } // end namespace tooling
47 } // end namespace clang
48 
49 #endif // LLVM_CLANG_TOOLING_REFACTORING_RENAME_USRFINDER_H
50