1 //===--- Lookup.h - Framework for clang refactoring tools --*- C++ -*------===//
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 //  This file defines helper methods for clang tools performing name lookup.
10 //
11 //===----------------------------------------------------------------------===//
12 
13 #ifndef LLVM_CLANG_TOOLING_REFACTOR_LOOKUP_H
14 #define LLVM_CLANG_TOOLING_REFACTOR_LOOKUP_H
15 
16 #include "clang/Basic/LLVM.h"
17 #include "clang/Basic/SourceLocation.h"
18 #include <string>
19 
20 namespace clang {
21 
22 class DeclContext;
23 class NamedDecl;
24 class NestedNameSpecifier;
25 
26 namespace tooling {
27 
28 /// Emulate a lookup to replace one nested name specifier with another using as
29 /// few additional namespace qualifications as possible.
30 ///
31 /// This does not perform a full C++ lookup so ADL will not work.
32 ///
33 /// \param Use The nested name to be replaced.
34 /// \param UseLoc The location of name to be replaced.
35 /// \param UseContext The context in which the nested name is contained. This
36 ///                   will be used to minimize namespace qualifications.
37 /// \param FromDecl The declaration to which the nested name points.
38 /// \param ReplacementString The replacement nested name. Must be fully
39 ///                          qualified including a leading "::".
40 /// \returns The new name to be inserted in place of the current nested name.
41 std::string replaceNestedName(const NestedNameSpecifier *Use,
42                               SourceLocation UseLoc,
43                               const DeclContext *UseContext,
44                               const NamedDecl *FromDecl,
45                               StringRef ReplacementString);
46 
47 } // end namespace tooling
48 } // end namespace clang
49 
50 #endif // LLVM_CLANG_TOOLING_REFACTOR_LOOKUP_H
51