Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-05-10 08:37:11

0001 //===--- USRFindingAction.h - Clang refactoring library -------------------===//
0002 //
0003 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
0004 // See https://llvm.org/LICENSE.txt for license information.
0005 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
0006 //
0007 //===----------------------------------------------------------------------===//
0008 ///
0009 /// \file
0010 /// Provides an action to find all relevant USRs at a point.
0011 ///
0012 //===----------------------------------------------------------------------===//
0013 
0014 #ifndef LLVM_CLANG_TOOLING_REFACTORING_RENAME_USRFINDINGACTION_H
0015 #define LLVM_CLANG_TOOLING_REFACTORING_RENAME_USRFINDINGACTION_H
0016 
0017 #include "clang/Basic/LLVM.h"
0018 #include "llvm/ADT/ArrayRef.h"
0019 
0020 #include <string>
0021 #include <vector>
0022 
0023 namespace clang {
0024 class ASTConsumer;
0025 class ASTContext;
0026 class NamedDecl;
0027 
0028 namespace tooling {
0029 
0030 /// Returns the canonical declaration that best represents a symbol that can be
0031 /// renamed.
0032 ///
0033 /// The following canonicalization rules are currently used:
0034 ///
0035 /// - A constructor is canonicalized to its class.
0036 /// - A destructor is canonicalized to its class.
0037 const NamedDecl *getCanonicalSymbolDeclaration(const NamedDecl *FoundDecl);
0038 
0039 /// Returns the set of USRs that correspond to the given declaration.
0040 std::vector<std::string> getUSRsForDeclaration(const NamedDecl *ND,
0041                                                ASTContext &Context);
0042 
0043 struct USRFindingAction {
0044   USRFindingAction(ArrayRef<unsigned> SymbolOffsets,
0045                    ArrayRef<std::string> QualifiedNames, bool Force)
0046       : SymbolOffsets(SymbolOffsets), QualifiedNames(QualifiedNames),
0047         ErrorOccurred(false), Force(Force) {}
0048   std::unique_ptr<ASTConsumer> newASTConsumer();
0049 
0050   ArrayRef<std::string> getUSRSpellings() { return SpellingNames; }
0051   ArrayRef<std::vector<std::string>> getUSRList() { return USRList; }
0052   bool errorOccurred() { return ErrorOccurred; }
0053 
0054 private:
0055   std::vector<unsigned> SymbolOffsets;
0056   std::vector<std::string> QualifiedNames;
0057   std::vector<std::string> SpellingNames;
0058   std::vector<std::vector<std::string>> USRList;
0059   bool ErrorOccurred;
0060   bool Force;
0061 };
0062 
0063 } // end namespace tooling
0064 } // end namespace clang
0065 
0066 #endif // LLVM_CLANG_TOOLING_REFACTORING_RENAME_USRFINDINGACTION_H