diff options
Diffstat (limited to 'include/clang/Tooling')
-rw-r--r-- | include/clang/Tooling/Core/QualTypeNames.h | 79 | ||||
-rw-r--r-- | include/clang/Tooling/Execution.h | 7 | ||||
-rw-r--r-- | include/clang/Tooling/Refactoring/RecursiveSymbolVisitor.h | 12 | ||||
-rw-r--r-- | include/clang/Tooling/Refactoring/Rename/RenamingAction.h | 22 |
4 files changed, 41 insertions, 79 deletions
diff --git a/include/clang/Tooling/Core/QualTypeNames.h b/include/clang/Tooling/Core/QualTypeNames.h deleted file mode 100644 index 7248356e74..0000000000 --- a/include/clang/Tooling/Core/QualTypeNames.h +++ /dev/null @@ -1,79 +0,0 @@ -//===--- QualTypeNames.h - Generate Complete QualType Names ----*- C++ -*-===// -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -// ===----------------------------------------------------------------------===// -// -// \file -// Functionality to generate the fully-qualified names of QualTypes, -// including recursively expanding any subtypes and template -// parameters. -// -// More precisely: Generates a name that can be used to name the same -// type if used at the end of the current translation unit--with -// certain limitations. See below. -// -// This code desugars names only very minimally, so in this code: -// -// namespace A { -// struct X {}; -// } -// using A::X; -// namespace B { -// using std::tuple; -// typedef tuple<X> TX; -// TX t; -// } -// -// B::t's type is reported as "B::TX", rather than std::tuple<A::X>. -// -// Also, this code replaces types found via using declarations with -// their more qualified name, so for the code: -// -// using std::tuple; -// tuple<int> TInt; -// -// TInt's type will be named, "std::tuple<int>". -// -// Limitations: -// -// Some types have ambiguous names at the end of a translation unit, -// are not namable at all there, or are special cases in other ways. -// -// 1) Types with only local scope will have their local names: -// -// void foo() { -// struct LocalType {} LocalVar; -// } -// -// LocalVar's type will be named, "struct LocalType", without any -// qualification. -// -// 2) Types that have been shadowed are reported normally, but a -// client using that name at the end of the translation unit will be -// referring to a different type. -// -// ===----------------------------------------------------------------------===// - -#ifndef LLVM_CLANG_TOOLING_CORE_QUALTYPENAMES_H -#define LLVM_CLANG_TOOLING_CORE_QUALTYPENAMES_H - -#include "clang/AST/ASTContext.h" - -namespace clang { -namespace TypeName { -/// \brief Get the fully qualified name for a type. This includes full -/// qualification of all template parameters etc. -/// -/// \param[in] QT - the type for which the fully qualified name will be -/// returned. -/// \param[in] Ctx - the ASTContext to be used. -/// \param[in] WithGlobalNsPrefix - If true, then the global namespace -/// specifier "::" will be prepended to the fully qualified name. -std::string getFullyQualifiedName(QualType QT, - const ASTContext &Ctx, - bool WithGlobalNsPrefix = false); -} // end namespace TypeName -} // end namespace clang -#endif // LLVM_CLANG_TOOLING_CORE_QUALTYPENAMES_H diff --git a/include/clang/Tooling/Execution.h b/include/clang/Tooling/Execution.h index 9d07c5659e..1a44c4788c 100644 --- a/include/clang/Tooling/Execution.h +++ b/include/clang/Tooling/Execution.h @@ -162,6 +162,13 @@ createExecutorFromCommandLineArgs(int &argc, const char **argv, llvm::cl::OptionCategory &Category, const char *Overview = nullptr); +namespace internal { +llvm::Expected<std::unique_ptr<ToolExecutor>> +createExecutorFromCommandLineArgsImpl(int &argc, const char **argv, + llvm::cl::OptionCategory &Category, + const char *Overview = nullptr); +} // end namespace internal + } // end namespace tooling } // end namespace clang diff --git a/include/clang/Tooling/Refactoring/RecursiveSymbolVisitor.h b/include/clang/Tooling/Refactoring/RecursiveSymbolVisitor.h index 8b01a61256..d96ad78ad8 100644 --- a/include/clang/Tooling/Refactoring/RecursiveSymbolVisitor.h +++ b/include/clang/Tooling/Refactoring/RecursiveSymbolVisitor.h @@ -70,6 +70,18 @@ public: return visit(Expr->getFoundDecl().getDecl(), Expr->getMemberLoc()); } + bool VisitOffsetOfExpr(const OffsetOfExpr *S) { + for (unsigned I = 0, E = S->getNumComponents(); I != E; ++I) { + const OffsetOfNode &Component = S->getComponent(I); + if (Component.getKind() == OffsetOfNode::Field) { + if (!visit(Component.getField(), Component.getLocEnd())) + return false; + } + // FIXME: Try to resolve dependent field references. + } + return true; + } + // Other visitors: bool VisitTypeLoc(const TypeLoc Loc) { diff --git a/include/clang/Tooling/Refactoring/Rename/RenamingAction.h b/include/clang/Tooling/Refactoring/Rename/RenamingAction.h index d9ed7d3a1f..734b624d77 100644 --- a/include/clang/Tooling/Refactoring/Rename/RenamingAction.h +++ b/include/clang/Tooling/Refactoring/Rename/RenamingAction.h @@ -66,6 +66,28 @@ private: std::string NewName; }; +class QualifiedRenameRule final : public SourceChangeRefactoringRule { +public: + static Expected<QualifiedRenameRule> initiate(RefactoringRuleContext &Context, + std::string OldQualifiedName, + std::string NewQualifiedName); + + static const RefactoringDescriptor &describe(); + +private: + QualifiedRenameRule(const NamedDecl *ND, + std::string NewQualifiedName) + : ND(ND), NewQualifiedName(std::move(NewQualifiedName)) {} + + Expected<AtomicChanges> + createSourceReplacements(RefactoringRuleContext &Context) override; + + // A NamedDecl which indentifies the the symbol being renamed. + const NamedDecl *ND; + // The new qualified name to change the symbol to. + std::string NewQualifiedName; +}; + /// Returns source replacements that correspond to the rename of the given /// symbol occurrences. llvm::Expected<std::vector<AtomicChange>> |