[clang] b168bbf - [clang-format] Recognize "hxx" as a C++ header in clang-format-diff.py

2020-09-18 Thread Miklos Vajna via cfe-commits

Author: Miklos Vajna
Date: 2020-09-18T21:43:18+02:00
New Revision: b168bbfae42e792542b4ced8729599524b9759c5

URL: 
https://github.com/llvm/llvm-project/commit/b168bbfae42e792542b4ced8729599524b9759c5
DIFF: 
https://github.com/llvm/llvm-project/commit/b168bbfae42e792542b4ced8729599524b9759c5.diff

LOG: [clang-format] Recognize "hxx" as a C++ header in clang-format-diff.py

And shift "proto" to the next line to avoid a too long line.

Reviewed By: MyDeveloperDay

Differential Revision: https://reviews.llvm.org/D87931

Added: 


Modified: 
clang/tools/clang-format/clang-format-diff.py

Removed: 




diff  --git a/clang/tools/clang-format/clang-format-
diff .py b/clang/tools/clang-format/clang-format-
diff .py
index c5331202fc1b..6e653a134289 100755
--- a/clang/tools/clang-format/clang-format-
diff .py
+++ b/clang/tools/clang-format/clang-format-
diff .py
@@ -47,8 +47,8 @@ def main():
   help='custom pattern selecting file paths to reformat '
   '(case sensitive, overrides -iregex)')
   parser.add_argument('-iregex', metavar='PATTERN', default=
-  
r'.*\.(cpp|cc|c\+\+|cxx|c|cl|h|hh|hpp|m|mm|inc|js|ts|proto'
-  r'|protodevel|java|cs)',
+  r'.*\.(cpp|cc|c\+\+|cxx|c|cl|h|hh|hpp|hxx|m|mm|inc|js|ts'
+  r'|proto|protodevel|java|cs)',
   help='custom pattern selecting file paths to reformat '
   '(case insensitive, overridden by -regex)')
   parser.add_argument('-sort-includes', action='store_true', default=False,



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r364014 - [git-clang-format] recognize hxx as a C++ file

2019-06-21 Thread Miklos Vajna via cfe-commits
Author: vmiklos
Date: Fri Jun 21 02:49:38 2019
New Revision: 364014

URL: http://llvm.org/viewvc/llvm-project?rev=364014&view=rev
Log:
[git-clang-format] recognize hxx as a C++ file

clangd, clang-tidy, etc does that already, no reason why
git-clang-format should skip hxx files.

Reviewed By: ilya-biryukov

Differential Revision: https://reviews.llvm.org/D63621

Modified:
cfe/trunk/tools/clang-format/git-clang-format

Modified: cfe/trunk/tools/clang-format/git-clang-format
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/clang-format/git-clang-format?rev=364014&r1=364013&r2=364014&view=diff
==
--- cfe/trunk/tools/clang-format/git-clang-format (original)
+++ cfe/trunk/tools/clang-format/git-clang-format Fri Jun 21 02:49:38 2019
@@ -77,7 +77,7 @@ def main():
   'c', 'h',  # C
   'm',  # ObjC
   'mm',  # ObjC++
-  'cc', 'cp', 'cpp', 'c++', 'cxx', 'hpp',  # C++
+  'cc', 'cp', 'cpp', 'c++', 'cxx', 'hpp', 'hxx',  # C++
   'cu',  # CUDA
   # Other languages that clang-format supports
   'proto', 'protodevel',  # Protocol Buffers


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] r351686 - [clang-tidy] misc-non-private-member-variables-in-classes: ignore implicit methods

2019-01-20 Thread Miklos Vajna via cfe-commits
Author: vmiklos
Date: Sun Jan 20 06:28:27 2019
New Revision: 351686

URL: http://llvm.org/viewvc/llvm-project?rev=351686&view=rev
Log:
[clang-tidy] misc-non-private-member-variables-in-classes: ignore implicit 
methods

Otherwise we don't warn on a struct containing a single public int, but
we warn on a struct containing a single public std::string, which is
inconsistent.

Modified:

clang-tools-extra/trunk/clang-tidy/misc/NonPrivateMemberVariablesInClassesCheck.cpp

clang-tools-extra/trunk/docs/clang-tidy/checks/misc-non-private-member-variables-in-classes.rst

clang-tools-extra/trunk/test/clang-tidy/misc-non-private-member-variables-in-classes.cpp

Modified: 
clang-tools-extra/trunk/clang-tidy/misc/NonPrivateMemberVariablesInClassesCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/misc/NonPrivateMemberVariablesInClassesCheck.cpp?rev=351686&r1=351685&r2=351686&view=diff
==
--- 
clang-tools-extra/trunk/clang-tidy/misc/NonPrivateMemberVariablesInClassesCheck.cpp
 (original)
+++ 
clang-tools-extra/trunk/clang-tidy/misc/NonPrivateMemberVariablesInClassesCheck.cpp
 Sun Jan 20 06:28:27 2019
@@ -22,8 +22,8 @@ AST_MATCHER(CXXRecordDecl, hasMethods) {
   return std::distance(Node.method_begin(), Node.method_end()) != 0;
 }
 
-AST_MATCHER(CXXRecordDecl, hasNonStaticMethod) {
-  return hasMethod(unless(isStaticStorageClass()))
+AST_MATCHER(CXXRecordDecl, hasNonStaticNonImplicitMethod) {
+  return hasMethod(unless(anyOf(isStaticStorageClass(), isImplicit(
   .matches(Node, Finder, Builder);
 }
 
@@ -66,10 +66,11 @@ void NonPrivateMemberVariablesInClassesC
   IgnorePublicMemberVariables ? isProtected() : unless(isPrivate()));
 
   // We only want the records that not only contain the mutable data 
(non-static
-  // member variables), but also have some logic (non-static member functions).
-  // We may optionally ignore records where all the member variables are 
public.
+  // member variables), but also have some logic (non-static, non-implicit
+  // member functions).  We may optionally ignore records where all the member
+  // variables are public.
   Finder->addMatcher(cxxRecordDecl(anyOf(isStruct(), isClass()), hasMethods(),
-   hasNonStaticMethod(),
+   hasNonStaticNonImplicitMethod(),
unless(ShouldIgnoreRecord),
forEach(InterestingField.bind("field")))
  .bind("record"),

Modified: 
clang-tools-extra/trunk/docs/clang-tidy/checks/misc-non-private-member-variables-in-classes.rst
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/docs/clang-tidy/checks/misc-non-private-member-variables-in-classes.rst?rev=351686&r1=351685&r2=351686&view=diff
==
--- 
clang-tools-extra/trunk/docs/clang-tidy/checks/misc-non-private-member-variables-in-classes.rst
 (original)
+++ 
clang-tools-extra/trunk/docs/clang-tidy/checks/misc-non-private-member-variables-in-classes.rst
 Sun Jan 20 06:28:27 2019
@@ -6,11 +6,11 @@ misc-non-private-member-variables-in-cla
 `cppcoreguidelines-non-private-member-variables-in-classes` redirects here
 as an alias for this check.
 
-Finds classes that contain non-static data members in addition to non-static
-member functions and diagnose all data members declared with a non-``public``
-access specifier. The data members should be declared as ``private`` and
-accessed through member functions instead of exposed to derived classes or
-class consumers.
+Finds classes that contain non-static data members in addition to user-declared
+non-static member functions and diagnose all data members declared with a
+non-``public`` access specifier. The data members should be declared as
+``private`` and accessed through member functions instead of exposed to derived
+classes or class consumers.
 
 Options
 ---

Modified: 
clang-tools-extra/trunk/test/clang-tidy/misc-non-private-member-variables-in-classes.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/misc-non-private-member-variables-in-classes.cpp?rev=351686&r1=351685&r2=351686&view=diff
==
--- 
clang-tools-extra/trunk/test/clang-tidy/misc-non-private-member-variables-in-classes.cpp
 (original)
+++ 
clang-tools-extra/trunk/test/clang-tidy/misc-non-private-member-variables-in-classes.cpp
 Sun Jan 20 06:28:27 2019
@@ -35,6 +35,23 @@ private:
   int S1_v3;
 };
 
+// Only data and implicit or static methods, do not warn
+
+class C {
+public:
+  C() {}
+  ~C() {}
+};
+
+struct S1Implicit {
+  C S1Implicit_v0;
+};
+
+struct S1ImplicitAndStatic {
+  C S1Implicit_v0;
+  static void s() {}
+};
+
 
////

[clang-tools-extra] r350922 - [clang-tidy] new check 'readability-redundant-preprocessor'

2019-01-11 Thread Miklos Vajna via cfe-commits
Author: vmiklos
Date: Thu Jan 10 23:59:47 2019
New Revision: 350922

URL: http://llvm.org/viewvc/llvm-project?rev=350922&view=rev
Log:
[clang-tidy] new check 'readability-redundant-preprocessor'

Finds potentially redundant preprocessor directives.

Reviewed By: aaron.ballman

Differential Revision: https://reviews.llvm.org/D54349

Added:

clang-tools-extra/trunk/clang-tidy/readability/RedundantPreprocessorCheck.cpp
clang-tools-extra/trunk/clang-tidy/readability/RedundantPreprocessorCheck.h

clang-tools-extra/trunk/docs/clang-tidy/checks/readability-redundant-preprocessor.rst

clang-tools-extra/trunk/test/clang-tidy/readability-redundant-preprocessor-ifdef.cpp

clang-tools-extra/trunk/test/clang-tidy/readability-redundant-preprocessor.cpp
clang-tools-extra/trunk/test/clang-tidy/readability-redundant-preprocessor.h
Modified:
clang-tools-extra/trunk/clang-tidy/readability/CMakeLists.txt
clang-tools-extra/trunk/clang-tidy/readability/ReadabilityTidyModule.cpp
clang-tools-extra/trunk/docs/ReleaseNotes.rst
clang-tools-extra/trunk/docs/clang-tidy/checks/list.rst

Modified: clang-tools-extra/trunk/clang-tidy/readability/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/readability/CMakeLists.txt?rev=350922&r1=350921&r2=350922&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/readability/CMakeLists.txt (original)
+++ clang-tools-extra/trunk/clang-tidy/readability/CMakeLists.txt Thu Jan 10 
23:59:47 2019
@@ -24,6 +24,7 @@ add_clang_library(clangTidyReadabilityMo
   RedundantDeclarationCheck.cpp
   RedundantFunctionPtrDereferenceCheck.cpp
   RedundantMemberInitCheck.cpp
+  RedundantPreprocessorCheck.cpp
   RedundantSmartptrGetCheck.cpp
   RedundantStringCStrCheck.cpp
   RedundantStringInitCheck.cpp

Modified: 
clang-tools-extra/trunk/clang-tidy/readability/ReadabilityTidyModule.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/readability/ReadabilityTidyModule.cpp?rev=350922&r1=350921&r2=350922&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/readability/ReadabilityTidyModule.cpp 
(original)
+++ clang-tools-extra/trunk/clang-tidy/readability/ReadabilityTidyModule.cpp 
Thu Jan 10 23:59:47 2019
@@ -31,6 +31,7 @@
 #include "RedundantDeclarationCheck.h"
 #include "RedundantFunctionPtrDereferenceCheck.h"
 #include "RedundantMemberInitCheck.h"
+#include "RedundantPreprocessorCheck.h"
 #include "RedundantSmartptrGetCheck.h"
 #include "RedundantStringCStrCheck.h"
 #include "RedundantStringInitCheck.h"
@@ -83,6 +84,8 @@ public:
 "readability-redundant-function-ptr-dereference");
 CheckFactories.registerCheck(
 "readability-redundant-member-init");
+CheckFactories.registerCheck(
+"readability-redundant-preprocessor");
 CheckFactories.registerCheck(
 "readability-simplify-subscript-expr");
 CheckFactories.registerCheck(

Added: 
clang-tools-extra/trunk/clang-tidy/readability/RedundantPreprocessorCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/readability/RedundantPreprocessorCheck.cpp?rev=350922&view=auto
==
--- 
clang-tools-extra/trunk/clang-tidy/readability/RedundantPreprocessorCheck.cpp 
(added)
+++ 
clang-tools-extra/trunk/clang-tidy/readability/RedundantPreprocessorCheck.cpp 
Thu Jan 10 23:59:47 2019
@@ -0,0 +1,109 @@
+//===--- RedundantPreprocessorCheck.cpp - clang-tidy 
--===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#include "RedundantPreprocessorCheck.h"
+#include "clang/Frontend/CompilerInstance.h"
+
+namespace clang {
+namespace tidy {
+namespace readability {
+
+namespace {
+/// Information about an opening preprocessor directive.
+struct PreprocessorEntry {
+  SourceLocation Loc;
+  /// Condition used after the preprocessor directive.
+  std::string Condition;
+};
+
+class RedundantPreprocessorCallbacks : public PPCallbacks {
+  enum DirectiveKind { DK_If = 0, DK_Ifdef = 1, DK_Ifndef = 2 };
+
+public:
+  explicit RedundantPreprocessorCallbacks(ClangTidyCheck &Check,
+  Preprocessor &PP)
+  : Check(Check), PP(PP),
+WarningDescription("nested redundant %select{#if|#ifdef|#ifndef}0; "
+   "consider removing it"),
+NoteDescription("previous %select{#if|#ifdef|#ifndef}0 was here") {}
+
+  void If(SourceLocation Loc, SourceRange ConditionRange,
+  ConditionValueKind ConditionValue) override {
+StringRef Condition =
+Lexer::getSourceText(CharSourceR

[clang-tools-extra] r350056 - [clang-tidy] add IgnoreMacros option to readability-uppercase-literal-suffix

2018-12-24 Thread Miklos Vajna via cfe-commits
Author: vmiklos
Date: Mon Dec 24 09:47:32 2018
New Revision: 350056

URL: http://llvm.org/viewvc/llvm-project?rev=350056&view=rev
Log:
[clang-tidy] add IgnoreMacros option to readability-uppercase-literal-suffix

And also enable it by default to be consistent with e.g.
modernize-use-using.

This helps e.g. when running this check on client code where the macro
is provided by the system, so there is no easy way to modify it.

Reviewed By: JonasToth, lebedev.ri

Differential Revision: https://reviews.llvm.org/D56025

Modified:

clang-tools-extra/trunk/clang-tidy/readability/UppercaseLiteralSuffixCheck.cpp
clang-tools-extra/trunk/clang-tidy/readability/UppercaseLiteralSuffixCheck.h
clang-tools-extra/trunk/docs/ReleaseNotes.rst

clang-tools-extra/trunk/docs/clang-tidy/checks/readability-uppercase-literal-suffix.rst

clang-tools-extra/trunk/test/clang-tidy/readability-uppercase-literal-suffix-integer-macro.cpp

clang-tools-extra/trunk/test/clang-tidy/readability-uppercase-literal-suffix-integer.cpp

Modified: 
clang-tools-extra/trunk/clang-tidy/readability/UppercaseLiteralSuffixCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/readability/UppercaseLiteralSuffixCheck.cpp?rev=350056&r1=350055&r2=350056&view=diff
==
--- 
clang-tools-extra/trunk/clang-tidy/readability/UppercaseLiteralSuffixCheck.cpp 
(original)
+++ 
clang-tools-extra/trunk/clang-tidy/readability/UppercaseLiteralSuffixCheck.cpp 
Mon Dec 24 09:47:32 2018
@@ -183,12 +183,14 @@ UppercaseLiteralSuffixCheck::UppercaseLi
 StringRef Name, ClangTidyContext *Context)
 : ClangTidyCheck(Name, Context),
   NewSuffixes(
-  utils::options::parseStringList(Options.get("NewSuffixes", ""))) {}
+  utils::options::parseStringList(Options.get("NewSuffixes", ""))),
+  IgnoreMacros(Options.getLocalOrGlobal("IgnoreMacros", 1) != 0) {}
 
 void UppercaseLiteralSuffixCheck::storeOptions(
 ClangTidyOptions::OptionMap &Opts) {
   Options.store(Opts, "NewSuffixes",
 utils::options::serializeStringList(NewSuffixes));
+  Options.store(Opts, "IgnoreMacros", IgnoreMacros);
 }
 
 void UppercaseLiteralSuffixCheck::registerMatchers(MatchFinder *Finder) {
@@ -216,6 +218,8 @@ bool UppercaseLiteralSuffixCheck::checkB
   // We might have a suffix that is already uppercase.
   if (auto Details = shouldReplaceLiteralSuffix(
   *Literal, NewSuffixes, *Result.SourceManager, getLangOpts())) {
+if (Details->LiteralLocation.getBegin().isMacroID() && IgnoreMacros)
+  return true;
 auto Complaint = diag(Details->LiteralLocation.getBegin(),
   "%0 literal has suffix '%1', which is not uppercase")
  << LiteralType::Name << Details->OldSuffix;

Modified: 
clang-tools-extra/trunk/clang-tidy/readability/UppercaseLiteralSuffixCheck.h
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/readability/UppercaseLiteralSuffixCheck.h?rev=350056&r1=350055&r2=350056&view=diff
==
--- 
clang-tools-extra/trunk/clang-tidy/readability/UppercaseLiteralSuffixCheck.h 
(original)
+++ 
clang-tools-extra/trunk/clang-tidy/readability/UppercaseLiteralSuffixCheck.h 
Mon Dec 24 09:47:32 2018
@@ -35,6 +35,7 @@ private:
   bool checkBoundMatch(const ast_matchers::MatchFinder::MatchResult &Result);
 
   const std::vector NewSuffixes;
+  const bool IgnoreMacros;
 };
 
 } // namespace readability

Modified: clang-tools-extra/trunk/docs/ReleaseNotes.rst
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/docs/ReleaseNotes.rst?rev=350056&r1=350055&r2=350056&view=diff
==
--- clang-tools-extra/trunk/docs/ReleaseNotes.rst (original)
+++ clang-tools-extra/trunk/docs/ReleaseNotes.rst Mon Dec 24 09:47:32 2018
@@ -236,6 +236,10 @@ Improvements to clang-tidy
   ` check does not warn
   about calls inside macros anymore by default.
 
+- The :doc:`readability-uppercase-literal-suffix
+  ` check does not warn
+  about literal suffixes inside macros anymore by default.
+
 - The :doc:`cppcoreguidelines-narrowing-conversions
   ` check now
   detects more narrowing conversions:

Modified: 
clang-tools-extra/trunk/docs/clang-tidy/checks/readability-uppercase-literal-suffix.rst
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/docs/clang-tidy/checks/readability-uppercase-literal-suffix.rst?rev=350056&r1=350055&r2=350056&view=diff
==
--- 
clang-tools-extra/trunk/docs/clang-tidy/checks/readability-uppercase-literal-suffix.rst
 (original)
+++ 
clang-tools-extra/trunk/docs/clang-tidy/checks/readability-uppercase-literal-suffix.rst
 Mon Dec 24 09:47:32 2018
@@ -49,3 +49,8 @@ Given a list `L;uL`:
 * ``uL`` will be kept as is.
 * `

[clang-tools-extra] r344885 - ReleaseNotes: move readability-redundant-smartptr-get part down below new checks

2018-10-21 Thread Miklos Vajna via cfe-commits
Author: vmiklos
Date: Sun Oct 21 23:36:30 2018
New Revision: 344885

URL: http://llvm.org/viewvc/llvm-project?rev=344885&view=rev
Log:
ReleaseNotes: move readability-redundant-smartptr-get part down below new checks

Modified:
clang-tools-extra/trunk/docs/ReleaseNotes.rst

Modified: clang-tools-extra/trunk/docs/ReleaseNotes.rst
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/docs/ReleaseNotes.rst?rev=344885&r1=344884&r2=344885&view=diff
==
--- clang-tools-extra/trunk/docs/ReleaseNotes.rst (original)
+++ clang-tools-extra/trunk/docs/ReleaseNotes.rst Sun Oct 21 23:36:30 2018
@@ -67,10 +67,6 @@ The improvements are...
 Improvements to clang-tidy
 --
 
-- The :doc:`readability-redundant-smartptr-get
-  ` check does not warn
-  about calls inside macros anymore by default.
-
 - New :doc:`abseil-duration-division
   ` check.
 
@@ -157,6 +153,10 @@ Improvements to clang-tidy
   `
   added.
 
+- The :doc:`readability-redundant-smartptr-get
+  ` check does not warn
+  about calls inside macros anymore by default.
+
 Improvements to include-fixer
 -
 


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] r344871 - [clang-tidy] add IgnoreMacros option to readability-redundant-smartptr-get

2018-10-21 Thread Miklos Vajna via cfe-commits
Author: vmiklos
Date: Sun Oct 21 12:16:25 2018
New Revision: 344871

URL: http://llvm.org/viewvc/llvm-project?rev=344871&view=rev
Log:
[clang-tidy] add IgnoreMacros option to readability-redundant-smartptr-get

And also enable it by default to be consistent with e.g. modernize-use-using.

This helps e.g. when running this check on client code where the macro is
provided by the system, so there is no easy way to modify it.

Reviewed By: JonasToth

Differential Revision: https://reviews.llvm.org/D53454

Added:

clang-tools-extra/trunk/test/clang-tidy/readability-redundant-smartptr-get-macros.cpp
Modified:
clang-tools-extra/trunk/clang-tidy/readability/RedundantSmartptrGetCheck.cpp
clang-tools-extra/trunk/clang-tidy/readability/RedundantSmartptrGetCheck.h
clang-tools-extra/trunk/docs/ReleaseNotes.rst

clang-tools-extra/trunk/docs/clang-tidy/checks/readability-redundant-smartptr-get.rst

clang-tools-extra/trunk/test/clang-tidy/readability-redundant-smartptr-get.cpp

Modified: 
clang-tools-extra/trunk/clang-tidy/readability/RedundantSmartptrGetCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/readability/RedundantSmartptrGetCheck.cpp?rev=344871&r1=344870&r2=344871&view=diff
==
--- 
clang-tools-extra/trunk/clang-tidy/readability/RedundantSmartptrGetCheck.cpp 
(original)
+++ 
clang-tools-extra/trunk/clang-tidy/readability/RedundantSmartptrGetCheck.cpp 
Sun Oct 21 12:16:25 2018
@@ -91,6 +91,11 @@ void registerMatchersForGetEquals(MatchF
 
 } // namespace
 
+void RedundantSmartptrGetCheck::storeOptions(
+ClangTidyOptions::OptionMap &Opts) {
+  Options.store(Opts, "IgnoreMacros", IgnoreMacros);
+}
+
 void RedundantSmartptrGetCheck::registerMatchers(MatchFinder *Finder) {
   // Only register the matchers for C++; the functionality currently does not
   // provide any benefit to other languages, despite being benign.
@@ -126,6 +131,9 @@ void RedundantSmartptrGetCheck::check(co
   bool IsPtrToPtr = Result.Nodes.getNodeAs("ptr_to_ptr") != nullptr;
   bool IsMemberExpr = Result.Nodes.getNodeAs("memberExpr") != nullptr;
   const auto *GetCall = Result.Nodes.getNodeAs("redundant_get");
+  if (GetCall->getBeginLoc().isMacroID() && IgnoreMacros)
+return;
+
   const auto *Smartptr = Result.Nodes.getNodeAs("smart_pointer");
 
   if (IsPtrToPtr && IsMemberExpr) {

Modified: 
clang-tools-extra/trunk/clang-tidy/readability/RedundantSmartptrGetCheck.h
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/readability/RedundantSmartptrGetCheck.h?rev=344871&r1=344870&r2=344871&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/readability/RedundantSmartptrGetCheck.h 
(original)
+++ clang-tools-extra/trunk/clang-tidy/readability/RedundantSmartptrGetCheck.h 
Sun Oct 21 12:16:25 2018
@@ -28,9 +28,14 @@ namespace readability {
 class RedundantSmartptrGetCheck : public ClangTidyCheck {
 public:
   RedundantSmartptrGetCheck(StringRef Name, ClangTidyContext *Context)
-  : ClangTidyCheck(Name, Context) {}
+  : ClangTidyCheck(Name, Context),
+IgnoreMacros(Options.getLocalOrGlobal("IgnoreMacros", 1) != 0) {}
+  void storeOptions(ClangTidyOptions::OptionMap &Opts) override;
   void registerMatchers(ast_matchers::MatchFinder *Finder) override;
   void check(const ast_matchers::MatchFinder::MatchResult &Result) override;
+
+private:
+  const bool IgnoreMacros;
 };
 
 } // namespace readability

Modified: clang-tools-extra/trunk/docs/ReleaseNotes.rst
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/docs/ReleaseNotes.rst?rev=344871&r1=344870&r2=344871&view=diff
==
--- clang-tools-extra/trunk/docs/ReleaseNotes.rst (original)
+++ clang-tools-extra/trunk/docs/ReleaseNotes.rst Sun Oct 21 12:16:25 2018
@@ -67,6 +67,10 @@ The improvements are...
 Improvements to clang-tidy
 --
 
+- The :doc:`readability-redundant-smartptr-get
+  ` check does not warn
+  about calls inside macros anymore by default.
+
 - New :doc:`abseil-duration-division
   ` check.
 

Modified: 
clang-tools-extra/trunk/docs/clang-tidy/checks/readability-redundant-smartptr-get.rst
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/docs/clang-tidy/checks/readability-redundant-smartptr-get.rst?rev=344871&r1=344870&r2=344871&view=diff
==
--- 
clang-tools-extra/trunk/docs/clang-tidy/checks/readability-redundant-smartptr-get.rst
 (original)
+++ 
clang-tools-extra/trunk/docs/clang-tidy/checks/readability-redundant-smartptr-get.rst
 Sun Oct 21 12:16:25 2018
@@ -14,3 +14,8 @@ Examples:
   *ptr->get()  ==>  **ptr
   if (ptr.get() == nullptr) ... => if (ptr == nullptr) ...
 
+
+.. option:: IgnoreMacros
+
+   If this option is set to non-

[clang-tools-extra] r344440 - [clang-tidy] add IgnoreMacros option to modernize-use-equals-delete

2018-10-13 Thread Miklos Vajna via cfe-commits
Author: vmiklos
Date: Sat Oct 13 00:58:05 2018
New Revision: 30

URL: http://llvm.org/viewvc/llvm-project?rev=30&view=rev
Log:
[clang-tidy] add IgnoreMacros option to modernize-use-equals-delete

And also enable it by default to be consistent with e.g. modernize-use-using.
This improves consistency inside the check itself as well: both checks are now
disabled in macros by default.

This helps e.g. when running this check on client code where the macro is
provided by the system, so there is no easy way to modify it.

Reviewed By: alexfh

Differential Revision: https://reviews.llvm.org/D53217

Added:

clang-tools-extra/trunk/test/clang-tidy/modernize-use-equals-delete-macros.cpp
Modified:
clang-tools-extra/trunk/clang-tidy/modernize/UseEqualsDeleteCheck.cpp
clang-tools-extra/trunk/clang-tidy/modernize/UseEqualsDeleteCheck.h

clang-tools-extra/trunk/docs/clang-tidy/checks/modernize-use-equals-delete.rst
clang-tools-extra/trunk/test/clang-tidy/modernize-use-equals-delete.cpp

Modified: clang-tools-extra/trunk/clang-tidy/modernize/UseEqualsDeleteCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/modernize/UseEqualsDeleteCheck.cpp?rev=30&r1=344439&r2=30&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/modernize/UseEqualsDeleteCheck.cpp 
(original)
+++ clang-tools-extra/trunk/clang-tidy/modernize/UseEqualsDeleteCheck.cpp Sat 
Oct 13 00:58:05 2018
@@ -21,6 +21,10 @@ namespace modernize {
 static const char SpecialFunction[] = "SpecialFunction";
 static const char DeletedNotPublic[] = "DeletedNotPublic";
 
+void UseEqualsDeleteCheck::storeOptions(ClangTidyOptions::OptionMap &Opts) {
+  Options.store(Opts, "IgnoreMacros", IgnoreMacros);
+}
+
 void UseEqualsDeleteCheck::registerMatchers(MatchFinder *Finder) {
   if (!getLangOpts().CPlusPlus)
 return;
@@ -57,6 +61,8 @@ void UseEqualsDeleteCheck::check(const M
 SourceLocation EndLoc = Lexer::getLocForEndOfToken(
 Func->getEndLoc(), 0, *Result.SourceManager, getLangOpts());
 
+if (Func->getLocation().isMacroID() && IgnoreMacros)
+  return;
 // FIXME: Improve FixItHint to make the method public.
 diag(Func->getLocation(),
  "use '= delete' to prohibit calling of a special member function")
@@ -66,7 +72,7 @@ void UseEqualsDeleteCheck::check(const M
 // Ignore this warning in macros, since it's extremely noisy in code using
 // DISALLOW_COPY_AND_ASSIGN-style macros and there's no easy way to
 // automatically fix the warning when macros are in play.
-if (Func->getLocation().isMacroID())
+if (Func->getLocation().isMacroID() && IgnoreMacros)
   return;
 // FIXME: Add FixItHint to make the method public.
 diag(Func->getLocation(), "deleted member function should be public");

Modified: clang-tools-extra/trunk/clang-tidy/modernize/UseEqualsDeleteCheck.h
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/modernize/UseEqualsDeleteCheck.h?rev=30&r1=344439&r2=30&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/modernize/UseEqualsDeleteCheck.h 
(original)
+++ clang-tools-extra/trunk/clang-tidy/modernize/UseEqualsDeleteCheck.h Sat Oct 
13 00:58:05 2018
@@ -38,9 +38,14 @@ namespace modernize {
 class UseEqualsDeleteCheck : public ClangTidyCheck {
 public:
   UseEqualsDeleteCheck(StringRef Name, ClangTidyContext *Context)
-  : ClangTidyCheck(Name, Context) {}
+  : ClangTidyCheck(Name, Context),
+IgnoreMacros(Options.getLocalOrGlobal("IgnoreMacros", 1) != 0) {}
+  void storeOptions(ClangTidyOptions::OptionMap &Opts) override;
   void registerMatchers(ast_matchers::MatchFinder *Finder) override;
   void check(const ast_matchers::MatchFinder::MatchResult &Result) override;
+
+private:
+  const bool IgnoreMacros;
 };
 
 } // namespace modernize

Modified: 
clang-tools-extra/trunk/docs/clang-tidy/checks/modernize-use-equals-delete.rst
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/docs/clang-tidy/checks/modernize-use-equals-delete.rst?rev=30&r1=344439&r2=30&view=diff
==
--- 
clang-tools-extra/trunk/docs/clang-tidy/checks/modernize-use-equals-delete.rst 
(original)
+++ 
clang-tools-extra/trunk/docs/clang-tidy/checks/modernize-use-equals-delete.rst 
Sat Oct 13 00:58:05 2018
@@ -23,3 +23,8 @@ all other member functions implemented.
 A& operator=(const A&) = delete;
   };
 
+
+.. option:: IgnoreMacros
+
+   If this option is set to non-zero (default is `1`), the check will not warn
+   about functions declared inside macros.

Added: 
clang-tools-extra/trunk/test/clang-tidy/modernize-use-equals-delete-macros.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/modernize-use-equals-delete-macros.cpp?rev=30&vi

[clang-tools-extra] r327854 - run-clang-tidy: forward clang-tidy exit status

2018-03-19 Thread Miklos Vajna via cfe-commits
Author: vmiklos
Date: Mon Mar 19 07:43:59 2018
New Revision: 327854

URL: http://llvm.org/viewvc/llvm-project?rev=327854&view=rev
Log:
run-clang-tidy: forward clang-tidy exit status

Exit with a non-zero value in case any of the underlying clang-tidy
invocations exit with a non-zero value.

This is useful in case WarningsAsErrors is enabled for some of the
checks: if any of those checks find something, the exit status now
reflects that.

Also add the ability to use run-clang-tidy.py via lit, and assert that
the exit code is not 0 when modernize-use-auto is triggered
intentionally.

Reviewers: alexfh, aaron.ballman

Reviewed By: aaron.ballman

Differential Revision: https://reviews.llvm.org/D44366

Added:
clang-tools-extra/trunk/test/clang-tidy/run-clang-tidy.cpp
Modified:
clang-tools-extra/trunk/clang-tidy/tool/run-clang-tidy.py
clang-tools-extra/trunk/test/lit.cfg

Modified: clang-tools-extra/trunk/clang-tidy/tool/run-clang-tidy.py
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/tool/run-clang-tidy.py?rev=327854&r1=327853&r2=327854&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/tool/run-clang-tidy.py (original)
+++ clang-tools-extra/trunk/clang-tidy/tool/run-clang-tidy.py Mon Mar 19 
07:43:59 2018
@@ -153,7 +153,7 @@ def apply_fixes(args, tmpdir):
   subprocess.call(invocation)
 
 
-def run_tidy(args, tmpdir, build_path, queue):
+def run_tidy(args, tmpdir, build_path, queue, failed_files):
   """Takes filenames out of queue and runs clang-tidy on them."""
   while True:
 name = queue.get()
@@ -162,7 +162,9 @@ def run_tidy(args, tmpdir, build_path, q
  args.extra_arg, args.extra_arg_before,
  args.quiet, args.config)
 sys.stdout.write(' '.join(invocation) + '\n')
-subprocess.call(invocation)
+return_code = subprocess.call(invocation)
+if return_code != 0:
+  failed_files.append(name)
 queue.task_done()
 
 
@@ -255,12 +257,15 @@ def main():
   # Build up a big regexy filter from all command line arguments.
   file_name_re = re.compile('|'.join(args.files))
 
+  return_code = 0
   try:
 # Spin up a bunch of tidy-launching threads.
 task_queue = queue.Queue(max_task)
+# List of files with a non-zero return code.
+failed_files = []
 for _ in range(max_task):
   t = threading.Thread(target=run_tidy,
-   args=(args, tmpdir, build_path, task_queue))
+   args=(args, tmpdir, build_path, task_queue, 
failed_files))
   t.daemon = True
   t.start()
 
@@ -271,6 +276,8 @@ def main():
 
 # Wait for all threads to be done.
 task_queue.join()
+if len(failed_files):
+  return_code = 1
 
   except KeyboardInterrupt:
 # This is a sad hack. Unfortunately subprocess goes
@@ -280,7 +287,6 @@ def main():
   shutil.rmtree(tmpdir)
 os.kill(0, 9)
 
-  return_code = 0
   if args.export_fixes:
 print('Writing fixes to ' + args.export_fixes + ' ...')
 try:

Added: clang-tools-extra/trunk/test/clang-tidy/run-clang-tidy.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/run-clang-tidy.cpp?rev=327854&view=auto
==
--- clang-tools-extra/trunk/test/clang-tidy/run-clang-tidy.cpp (added)
+++ clang-tools-extra/trunk/test/clang-tidy/run-clang-tidy.cpp Mon Mar 19 
07:43:59 2018
@@ -0,0 +1,14 @@
+// RUN: rm -rf %t
+// RUN: mkdir %t
+// RUN: echo "[{\"directory\":\".\",\"command\":\"clang++ -c 
%/t/test.cpp\",\"file\":\"%/t/test.cpp\"}]" | sed -e 's/\\//g' > 
%t/compile_commands.json
+// RUN: echo "Checks: '-*,modernize-use-auto'" > %t/.clang-tidy
+// RUN: echo "WarningsAsErrors: '*'" >> %t/.clang-tidy
+// RUN: cp "%s" "%t/test.cpp"
+// RUN: cd "%t"
+// RUN: not %run_clang_tidy "%t/test.cpp"
+
+int main()
+{
+  int* x = new int();
+  delete x;
+}

Modified: clang-tools-extra/trunk/test/lit.cfg
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/lit.cfg?rev=327854&r1=327853&r2=327854&view=diff
==
--- clang-tools-extra/trunk/test/lit.cfg (original)
+++ clang-tools-extra/trunk/test/lit.cfg Mon Mar 19 07:43:59 2018
@@ -129,6 +129,11 @@ if config.clang_staticanalyzer:
 config.substitutions.append(
 ('%clang_tidy_diff',
  '%s %s' % (config.python_executable, clang_tidy_diff)) )
+run_clang_tidy = os.path.join(
+config.test_source_root, "..", "clang-tidy", "tool", 
"run-clang-tidy.py")
+config.substitutions.append(
+('%run_clang_tidy',
+ '%s %s' % (config.python_executable, run_clang_tidy)) )
 else:
 # exclude the clang-tidy test directory
 config.excludes.append('clang-tidy')


___
cfe-commits mailing list
cfe-commi

[clang-tools-extra] r321913 - clang-tidy: add IgnoreMacros option to readability-inconsistent-declaration-parameter-name

2018-01-05 Thread Miklos Vajna via cfe-commits
Author: vmiklos
Date: Fri Jan  5 15:22:10 2018
New Revision: 321913

URL: http://llvm.org/viewvc/llvm-project?rev=321913&view=rev
Log:
clang-tidy: add IgnoreMacros option to 
readability-inconsistent-declaration-parameter-name

And also enable it by default to be consistent with e.g. modernize-use-using.

This helps e.g. when running this check on client code where the macro is
provided by the system, so there is no easy way to modify it.

Reviewers: alexfh, piotrdz, hokein, ilya-biryukov

Reviewed By: alexfh

Differential Revision: https://reviews.llvm.org/D41716

Added:

clang-tools-extra/trunk/test/clang-tidy/readability-inconsistent-declaration-parameter-name-macros.cpp
Modified:

clang-tools-extra/trunk/clang-tidy/readability/InconsistentDeclarationParameterNameCheck.cpp

clang-tools-extra/trunk/clang-tidy/readability/InconsistentDeclarationParameterNameCheck.h

clang-tools-extra/trunk/docs/clang-tidy/checks/readability-inconsistent-declaration-parameter-name.rst

clang-tools-extra/trunk/test/clang-tidy/readability-inconsistent-declaration-parameter-name.cpp

Modified: 
clang-tools-extra/trunk/clang-tidy/readability/InconsistentDeclarationParameterNameCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/readability/InconsistentDeclarationParameterNameCheck.cpp?rev=321913&r1=321912&r2=321913&view=diff
==
--- 
clang-tools-extra/trunk/clang-tidy/readability/InconsistentDeclarationParameterNameCheck.cpp
 (original)
+++ 
clang-tools-extra/trunk/clang-tidy/readability/InconsistentDeclarationParameterNameCheck.cpp
 Fri Jan  5 15:22:10 2018
@@ -281,6 +281,11 @@ void formatDiagnostics(
 
 } // anonymous namespace
 
+void InconsistentDeclarationParameterNameCheck::storeOptions(
+ClangTidyOptions::OptionMap &Opts) {
+  Options.store(Opts, "IgnoreMacros", IgnoreMacros);
+}
+
 void InconsistentDeclarationParameterNameCheck::registerMatchers(
 MatchFinder *Finder) {
   Finder->addMatcher(functionDecl(unless(isImplicit()), hasOtherDeclarations())
@@ -308,6 +313,12 @@ void InconsistentDeclarationParameterNam
 markRedeclarationsAsVisited(OriginalDeclaration);
 return;
   }
+
+  SourceLocation StartLoc = OriginalDeclaration->getLocStart();
+  if (StartLoc.isMacroID() && IgnoreMacros) {
+markRedeclarationsAsVisited(OriginalDeclaration);
+return;
+  }
 
   if (OriginalDeclaration->getTemplatedKind() ==
   FunctionDecl::TK_FunctionTemplateSpecialization) {

Modified: 
clang-tools-extra/trunk/clang-tidy/readability/InconsistentDeclarationParameterNameCheck.h
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/readability/InconsistentDeclarationParameterNameCheck.h?rev=321913&r1=321912&r2=321913&view=diff
==
--- 
clang-tools-extra/trunk/clang-tidy/readability/InconsistentDeclarationParameterNameCheck.h
 (original)
+++ 
clang-tools-extra/trunk/clang-tidy/readability/InconsistentDeclarationParameterNameCheck.h
 Fri Jan  5 15:22:10 2018
@@ -27,8 +27,10 @@ class InconsistentDeclarationParameterNa
 public:
   InconsistentDeclarationParameterNameCheck(StringRef Name,
 ClangTidyContext *Context)
-  : ClangTidyCheck(Name, Context) {}
+  : ClangTidyCheck(Name, Context),
+IgnoreMacros(Options.getLocalOrGlobal("IgnoreMacros", 1) != 0) {}
 
+  void storeOptions(ClangTidyOptions::OptionMap &Opts) override;
   void registerMatchers(ast_matchers::MatchFinder *Finder) override;
   void check(const ast_matchers::MatchFinder::MatchResult &Result) override;
 
@@ -36,6 +38,7 @@ private:
   void markRedeclarationsAsVisited(const FunctionDecl *FunctionDeclaration);
 
   llvm::DenseSet VisitedDeclarations;
+  const bool IgnoreMacros;
 };
 
 } // namespace readability

Modified: 
clang-tools-extra/trunk/docs/clang-tidy/checks/readability-inconsistent-declaration-parameter-name.rst
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/docs/clang-tidy/checks/readability-inconsistent-declaration-parameter-name.rst?rev=321913&r1=321912&r2=321913&view=diff
==
--- 
clang-tools-extra/trunk/docs/clang-tidy/checks/readability-inconsistent-declaration-parameter-name.rst
 (original)
+++ 
clang-tools-extra/trunk/docs/clang-tidy/checks/readability-inconsistent-declaration-parameter-name.rst
 Fri Jan  5 15:22:10 2018
@@ -42,3 +42,8 @@ references parameter names in its body.
 In the case of multiple redeclarations or function template specializations,
 a warning is issued for every redeclaration or specialization inconsistent with
 the definition or the first declaration seen in a translation unit.
+
+.. option:: IgnoreMacros
+
+   If this option is set to non-zero (default is `1`), the check will not warn
+   about names declared inside macros.

Added: 
clang-to

r312942 - clang-rename: let -force handle multiple renames

2017-09-11 Thread Miklos Vajna via cfe-commits
Author: vmiklos
Date: Mon Sep 11 13:18:38 2017
New Revision: 312942

URL: http://llvm.org/viewvc/llvm-project?rev=312942&view=rev
Log:
clang-rename: let -force handle multiple renames

Summary:
The use case is that renaming multiple symbols in a large enough codebase is
much faster if all of these can be done with a single invocation, but
there will be multiple translation units where one or more symbols are
not found.

Old behavior was to exit with an error (default) or exit without
reporting an error (-force). New behavior is that -force results in a
best-effort rename: rename symbols which are found and just ignore the
rest.

The existing help for -force sort of already implies this behavior.

Reviewers: cfe-commits, klimek, arphaman

Reviewed By: klimek

Differential Revision: https://reviews.llvm.org/D37634

Added:
cfe/trunk/test/clang-rename/ForceMulti.cpp
Modified:
cfe/trunk/lib/Tooling/Refactoring/Rename/RenamingAction.cpp
cfe/trunk/lib/Tooling/Refactoring/Rename/USRFindingAction.cpp
cfe/trunk/tools/clang-rename/ClangRename.cpp

Modified: cfe/trunk/lib/Tooling/Refactoring/Rename/RenamingAction.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Tooling/Refactoring/Rename/RenamingAction.cpp?rev=312942&r1=312941&r2=312942&view=diff
==
--- cfe/trunk/lib/Tooling/Refactoring/Rename/RenamingAction.cpp (original)
+++ cfe/trunk/lib/Tooling/Refactoring/Rename/RenamingAction.cpp Mon Sep 11 
13:18:38 2017
@@ -84,8 +84,13 @@ public:
 FileToReplaces(FileToReplaces), PrintLocations(PrintLocations) {}
 
   void HandleTranslationUnit(ASTContext &Context) override {
-for (unsigned I = 0; I < NewNames.size(); ++I)
+for (unsigned I = 0; I < NewNames.size(); ++I) {
+  // If the previous name was not found, ignore this rename request.
+  if (PrevNames[I].empty())
+continue;
+
   HandleOneRename(Context, NewNames[I], PrevNames[I], USRList[I]);
+}
   }
 
   void HandleOneRename(ASTContext &Context, const std::string &NewName,

Modified: cfe/trunk/lib/Tooling/Refactoring/Rename/USRFindingAction.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Tooling/Refactoring/Rename/USRFindingAction.cpp?rev=312942&r1=312941&r2=312942&view=diff
==
--- cfe/trunk/lib/Tooling/Refactoring/Rename/USRFindingAction.cpp (original)
+++ cfe/trunk/lib/Tooling/Refactoring/Rename/USRFindingAction.cpp Mon Sep 11 
13:18:38 2017
@@ -198,8 +198,11 @@ private:
 return false;
   }
 
-  if (Force)
+  if (Force) {
+SpellingNames.push_back(std::string());
+USRList.push_back(std::vector());
 return true;
+  }
 
   unsigned CouldNotFindSymbolNamed = Engine.getCustomDiagID(
   DiagnosticsEngine::Error, "clang-rename could not find symbol %0");

Added: cfe/trunk/test/clang-rename/ForceMulti.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/clang-rename/ForceMulti.cpp?rev=312942&view=auto
==
--- cfe/trunk/test/clang-rename/ForceMulti.cpp (added)
+++ cfe/trunk/test/clang-rename/ForceMulti.cpp Mon Sep 11 13:18:38 2017
@@ -0,0 +1,8 @@
+class B /* Test 1 */ { // CHECK: class B2 /* Test 1 */ {
+};
+
+class D : public B /* Test 1 */ { // CHECK: class D : public B2 /* Test 1 */ {
+};
+
+// Test 1.
+// RUN: clang-rename -force -qualified-name B -new-name B2 -qualified-name E 
-new-name E2 %s -- | sed 's,//.*,,' | FileCheck %s

Modified: cfe/trunk/tools/clang-rename/ClangRename.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/clang-rename/ClangRename.cpp?rev=312942&r1=312941&r2=312942&view=diff
==
--- cfe/trunk/tools/clang-rename/ClangRename.cpp (original)
+++ cfe/trunk/tools/clang-rename/ClangRename.cpp Mon Sep 11 13:18:38 2017
@@ -175,12 +175,6 @@ int main(int argc, const char **argv) {
 return 1;
   }
 
-  if (Force && PrevNames.size() < NewNames.size()) {
-// No matching PrevName for all NewNames. Without Force this is an error
-// above already.
-return 0;
-  }
-
   // Perform the renaming.
   tooling::RenamingAction RenameAction(NewNames, PrevNames, USRList,
Tool.getReplacements(), PrintLocations);


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] r304534 - clang-rename: add new -force option

2017-06-02 Thread Miklos Vajna via cfe-commits
Author: vmiklos
Date: Fri Jun  2 04:32:28 2017
New Revision: 304534

URL: http://llvm.org/viewvc/llvm-project?rev=304534&view=rev
Log:
clang-rename: add new -force option

Summary:
The use-case is when renaming a widely used name, like a lower-level
class in a codebase and clang-rename is simply invoked for each
translation unit based on the compile database. In this case it's not
interesting to show errors: not finding the symbol means there is
simply nothing to do.

Reviewers: klimek

Reviewed By: klimek

Differential Revision: https://reviews.llvm.org/D32403

Added:
clang-tools-extra/trunk/test/clang-rename/InvalidQualifiedName.cpp
Modified:
clang-tools-extra/trunk/clang-rename/USRFindingAction.cpp
clang-tools-extra/trunk/clang-rename/USRFindingAction.h
clang-tools-extra/trunk/clang-rename/tool/ClangRename.cpp
clang-tools-extra/trunk/docs/clang-rename.rst
clang-tools-extra/trunk/unittests/clang-rename/ClangRenameTest.h

Modified: clang-tools-extra/trunk/clang-rename/USRFindingAction.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-rename/USRFindingAction.cpp?rev=304534&r1=304533&r2=304534&view=diff
==
--- clang-tools-extra/trunk/clang-rename/USRFindingAction.cpp (original)
+++ clang-tools-extra/trunk/clang-rename/USRFindingAction.cpp Fri Jun  2 
04:32:28 2017
@@ -145,9 +145,9 @@ public:
ArrayRef QualifiedNames,
std::vector &SpellingNames,
std::vector> &USRList,
-   bool &ErrorOccurred)
+   bool Force, bool &ErrorOccurred)
   : SymbolOffsets(SymbolOffsets), QualifiedNames(QualifiedNames),
-SpellingNames(SpellingNames), USRList(USRList),
+SpellingNames(SpellingNames), USRList(USRList), Force(Force),
 ErrorOccurred(ErrorOccurred) {}
 
 private:
@@ -182,6 +182,10 @@ private:
 ErrorOccurred = true;
 return false;
   }
+
+  if (Force)
+return true;
+
   unsigned CouldNotFindSymbolNamed = Engine.getCustomDiagID(
   DiagnosticsEngine::Error, "clang-rename could not find symbol %0");
   Engine.Report(CouldNotFindSymbolNamed) << QualifiedName;
@@ -218,12 +222,14 @@ private:
   ArrayRef QualifiedNames;
   std::vector &SpellingNames;
   std::vector> &USRList;
+  bool Force;
   bool &ErrorOccurred;
 };
 
 std::unique_ptr USRFindingAction::newASTConsumer() {
   return llvm::make_unique(
-  SymbolOffsets, QualifiedNames, SpellingNames, USRList, ErrorOccurred);
+  SymbolOffsets, QualifiedNames, SpellingNames, USRList, Force,
+  ErrorOccurred);
 }
 
 } // namespace rename

Modified: clang-tools-extra/trunk/clang-rename/USRFindingAction.h
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-rename/USRFindingAction.h?rev=304534&r1=304533&r2=304534&view=diff
==
--- clang-tools-extra/trunk/clang-rename/USRFindingAction.h (original)
+++ clang-tools-extra/trunk/clang-rename/USRFindingAction.h Fri Jun  2 04:32:28 
2017
@@ -30,9 +30,9 @@ namespace rename {
 
 struct USRFindingAction {
   USRFindingAction(ArrayRef SymbolOffsets,
-   ArrayRef QualifiedNames)
+   ArrayRef QualifiedNames, bool Force)
   : SymbolOffsets(SymbolOffsets), QualifiedNames(QualifiedNames),
-ErrorOccurred(false) {}
+ErrorOccurred(false), Force(Force) {}
   std::unique_ptr newASTConsumer();
 
   ArrayRef getUSRSpellings() { return SpellingNames; }
@@ -45,6 +45,7 @@ private:
   std::vector SpellingNames;
   std::vector> USRList;
   bool ErrorOccurred;
+  bool Force;
 };
 
 } // namespace rename

Modified: clang-tools-extra/trunk/clang-rename/tool/ClangRename.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-rename/tool/ClangRename.cpp?rev=304534&r1=304533&r2=304534&view=diff
==
--- clang-tools-extra/trunk/clang-rename/tool/ClangRename.cpp (original)
+++ clang-tools-extra/trunk/clang-rename/tool/ClangRename.cpp Fri Jun  2 
04:32:28 2017
@@ -95,6 +95,9 @@ static cl::opt
 static cl::opt
 Input("input", cl::desc("YAML file to load oldname-newname pairs from."),
   cl::Optional, cl::cat(ClangRenameOptions));
+static cl::opt Force("force",
+   cl::desc("Ignore nonexistent qualified names."),
+   cl::cat(ClangRenameOptions));
 
 int main(int argc, const char **argv) {
   tooling::CommonOptionsParser OP(argc, argv, ClangRenameOptions);
@@ -157,7 +160,7 @@ int main(int argc, const char **argv) {
 
   auto Files = OP.getSourcePathList();
   tooling::RefactoringTool Tool(OP.getCompilations(), Files);
-  rename::USRFindingAction FindingAction(SymbolOffsets, QualifiedNames);
+  rename::USRFindingAction Findi

[clang-tools-extra] r302429 - clang-tidy: add IgnoreMacros option to modernize-use-default-member-init

2017-05-08 Thread Miklos Vajna via cfe-commits
Author: vmiklos
Date: Mon May  8 10:13:31 2017
New Revision: 302429

URL: http://llvm.org/viewvc/llvm-project?rev=302429&view=rev
Log:
clang-tidy: add IgnoreMacros option to modernize-use-default-member-init

Summary:
And also enable it by default to be consistent with e.g.
modernize-use-using.

This helps e.g. when running this check on cppunit client code where the
macro is provided by the system, so there is no easy way to modify it.

Reviewers: alexfh, malcolm.parsons

Reviewed By: malcolm.parsons

Subscribers: cfe-commits

Differential Revision: https://reviews.llvm.org/D32945

Added:

clang-tools-extra/trunk/test/clang-tidy/modernize-use-default-member-init-macros.cpp
Modified:
clang-tools-extra/trunk/clang-tidy/modernize/UseDefaultMemberInitCheck.cpp
clang-tools-extra/trunk/clang-tidy/modernize/UseDefaultMemberInitCheck.h
clang-tools-extra/trunk/clang-tidy/modernize/UseUsingCheck.cpp

clang-tools-extra/trunk/docs/clang-tidy/checks/modernize-use-default-member-init.rst

clang-tools-extra/trunk/test/clang-tidy/modernize-use-default-member-init.cpp

Modified: 
clang-tools-extra/trunk/clang-tidy/modernize/UseDefaultMemberInitCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/modernize/UseDefaultMemberInitCheck.cpp?rev=302429&r1=302428&r2=302429&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/modernize/UseDefaultMemberInitCheck.cpp 
(original)
+++ clang-tools-extra/trunk/clang-tidy/modernize/UseDefaultMemberInitCheck.cpp 
Mon May  8 10:13:31 2017
@@ -139,11 +139,13 @@ static bool sameValue(const Expr *E1, co
 UseDefaultMemberInitCheck::UseDefaultMemberInitCheck(StringRef Name,
  ClangTidyContext *Context)
 : ClangTidyCheck(Name, Context),
-  UseAssignment(Options.get("UseAssignment", 0) != 0) {}
+  UseAssignment(Options.get("UseAssignment", 0) != 0),
+  IgnoreMacros(Options.getLocalOrGlobal("IgnoreMacros", 1) != 0) {}
 
 void UseDefaultMemberInitCheck::storeOptions(
 ClangTidyOptions::OptionMap &Opts) {
   Options.store(Opts, "UseAssignment", UseAssignment);
+  Options.store(Opts, "IgnoreMacros", IgnoreMacros);
 }
 
 void UseDefaultMemberInitCheck::registerMatchers(MatchFinder *Finder) {
@@ -197,6 +199,10 @@ void UseDefaultMemberInitCheck::checkDef
 const MatchFinder::MatchResult &Result, const CXXCtorInitializer *Init) {
   const FieldDecl *Field = Init->getMember();
 
+  SourceLocation StartLoc = Field->getLocStart();
+  if (StartLoc.isMacroID() && IgnoreMacros)
+return;
+
   SourceLocation FieldEnd =
   Lexer::getLocForEndOfToken(Field->getSourceRange().getEnd(), 0,
  *Result.SourceManager, getLangOpts());

Modified: 
clang-tools-extra/trunk/clang-tidy/modernize/UseDefaultMemberInitCheck.h
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/modernize/UseDefaultMemberInitCheck.h?rev=302429&r1=302428&r2=302429&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/modernize/UseDefaultMemberInitCheck.h 
(original)
+++ clang-tools-extra/trunk/clang-tidy/modernize/UseDefaultMemberInitCheck.h 
Mon May  8 10:13:31 2017
@@ -36,6 +36,7 @@ private:
  const CXXCtorInitializer *Init);
 
   const bool UseAssignment;
+  const bool IgnoreMacros;
 };
 
 } // namespace modernize

Modified: clang-tools-extra/trunk/clang-tidy/modernize/UseUsingCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/modernize/UseUsingCheck.cpp?rev=302429&r1=302428&r2=302429&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/modernize/UseUsingCheck.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/modernize/UseUsingCheck.cpp Mon May  8 
10:13:31 2017
@@ -19,7 +19,7 @@ namespace modernize {
 
 UseUsingCheck::UseUsingCheck(StringRef Name, ClangTidyContext *Context)
 : ClangTidyCheck(Name, Context),
-  IgnoreMacros(Options.get("IgnoreMacros", true)) {}
+  IgnoreMacros(Options.getLocalOrGlobal("IgnoreMacros", true)) {}
 
 void UseUsingCheck::registerMatchers(MatchFinder *Finder) {
   if (!getLangOpts().CPlusPlus11)

Modified: 
clang-tools-extra/trunk/docs/clang-tidy/checks/modernize-use-default-member-init.rst
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/docs/clang-tidy/checks/modernize-use-default-member-init.rst?rev=302429&r1=302428&r2=302429&view=diff
==
--- 
clang-tools-extra/trunk/docs/clang-tidy/checks/modernize-use-default-member-init.rst
 (original)
+++ 
clang-tools-extra/trunk/docs/clang-tidy/checks/modernize-use-default-member-init.rst
 Mon May  8 10:13:31 2017
@@ -47,3 +47,8 @@ Options
 int i = 5;
 double j = 10.0;
   };
+
+.. option:: 

[clang-tools-extra] r301130 - clang-rename: fix formatting

2017-04-23 Thread Miklos Vajna via cfe-commits
Author: vmiklos
Date: Sun Apr 23 11:07:06 2017
New Revision: 301130

URL: http://llvm.org/viewvc/llvm-project?rev=301130&view=rev
Log:
clang-rename: fix formatting

As detected by clang-format.

Modified:
clang-tools-extra/trunk/clang-rename/RenamingAction.cpp
clang-tools-extra/trunk/clang-rename/USRLocFinder.cpp
clang-tools-extra/trunk/clang-rename/USRLocFinder.h

Modified: clang-tools-extra/trunk/clang-rename/RenamingAction.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-rename/RenamingAction.cpp?rev=301130&r1=301129&r2=301130&view=diff
==
--- clang-tools-extra/trunk/clang-rename/RenamingAction.cpp (original)
+++ clang-tools-extra/trunk/clang-rename/RenamingAction.cpp Sun Apr 23 11:07:06 
2017
@@ -88,7 +88,7 @@ private:
 // new name.
 //
 // FIXME: Merge with the above RenamingASTConsumer.
-class USRSymbolRenamer: public ASTConsumer {
+class USRSymbolRenamer : public ASTConsumer {
 public:
   USRSymbolRenamer(const std::vector &NewNames,
const std::vector> &USRList,
@@ -110,7 +110,7 @@ public:
 llvm::errs() << "Renaming failed in " << Replace.getFilePath()
  << "! " << llvm::toString(std::move(Err)) << "\n";
   }
-  }
+}
   }
 }
   }
@@ -127,8 +127,7 @@ std::unique_ptr RenamingAct
 }
 
 std::unique_ptr QualifiedRenamingAction::newASTConsumer() {
-  return llvm::make_unique(
-  NewNames, USRList, FileToReplaces);
+  return llvm::make_unique(NewNames, USRList, 
FileToReplaces);
 }
 
 } // namespace rename

Modified: clang-tools-extra/trunk/clang-rename/USRLocFinder.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-rename/USRLocFinder.cpp?rev=301130&r1=301129&r2=301130&view=diff
==
--- clang-tools-extra/trunk/clang-rename/USRLocFinder.cpp (original)
+++ clang-tools-extra/trunk/clang-rename/USRLocFinder.cpp Sun Apr 23 11:07:06 
2017
@@ -195,8 +195,7 @@ NestedNameSpecifier *GetNestedNameForTyp
 //
 // This class will traverse the AST and find every AST node whose USR is in the
 // given USRs' set.
-class RenameLocFinder
-: public RecursiveASTVisitor {
+class RenameLocFinder : public RecursiveASTVisitor {
 public:
   RenameLocFinder(llvm::ArrayRef USRs, ASTContext &Context)
   : USRSet(USRs.begin(), USRs.end()), Context(Context) {}

Modified: clang-tools-extra/trunk/clang-rename/USRLocFinder.h
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-rename/USRLocFinder.h?rev=301130&r1=301129&r2=301130&view=diff
==
--- clang-tools-extra/trunk/clang-rename/USRLocFinder.h (original)
+++ clang-tools-extra/trunk/clang-rename/USRLocFinder.h Sun Apr 23 11:07:06 2017
@@ -17,9 +17,9 @@
 #define LLVM_CLANG_TOOLS_EXTRA_CLANG_RENAME_USR_LOC_FINDER_H
 
 #include "clang/AST/AST.h"
-#include "llvm/ADT/StringRef.h"
 #include "clang/Tooling/Core/Replacement.h"
 #include "clang/Tooling/Refactoring/AtomicChange.h"
+#include "llvm/ADT/StringRef.h"
 #include 
 #include 
 


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D24567: [clang-rename] Merge rename-{at|all} & optimise.

2016-09-15 Thread Miklos Vajna via cfe-commits
vmiklos added a comment.

As mentioned earlier, I have no problem with merging rename-at and rename-all.


https://reviews.llvm.org/D24567



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D24224: [clang-rename] Merge rename-{ at | all } and optimise USRFindingAction.

2016-09-05 Thread Miklos Vajna via cfe-commits
vmiklos added a comment.

Sure, I have no problems merging rename-all and rename-at, I added it as it 
looked like a good idea at that time.


https://reviews.llvm.org/D24224



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D23651: [clang-rename] improve performance for rename-all

2016-09-02 Thread Miklos Vajna via cfe-commits
vmiklos added a comment.

Ah, if you mean you squashed this into https://reviews.llvm.org/D24192, then I 
see what you mean, ignore me. :-)


https://reviews.llvm.org/D23651



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D23651: [clang-rename] improve performance for rename-all

2016-09-01 Thread Miklos Vajna via cfe-commits
vmiklos added a comment.

Kirill, are you waiting for me on this one? AFAICS the patch in its current 
form applies on top of current trunk, but no longer builds.


https://reviews.llvm.org/D23651



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] r280063 - clang-rename: fix formatting in USRFinder

2016-08-30 Thread Miklos Vajna via cfe-commits
Author: vmiklos
Date: Tue Aug 30 02:24:57 2016
New Revision: 280063

URL: http://llvm.org/viewvc/llvm-project?rev=280063&view=rev
Log:
clang-rename: fix formatting in USRFinder

As detected by clang-format.

Modified:
clang-tools-extra/trunk/clang-rename/USRFinder.cpp

Modified: clang-tools-extra/trunk/clang-rename/USRFinder.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-rename/USRFinder.cpp?rev=280063&r1=280062&r2=280063&view=diff
==
--- clang-tools-extra/trunk/clang-rename/USRFinder.cpp (original)
+++ clang-tools-extra/trunk/clang-rename/USRFinder.cpp Tue Aug 30 02:24:57 2016
@@ -76,8 +76,7 @@ public:
   bool VisitTypeLoc(const TypeLoc Loc) {
 const SourceLocation TypeBeginLoc = Loc.getBeginLoc();
 const SourceLocation TypeEndLoc = Lexer::getLocForEndOfToken(
- TypeBeginLoc, 0, Context.getSourceManager(),
- Context.getLangOpts());
+TypeBeginLoc, 0, Context.getSourceManager(), Context.getLangOpts());
 if (const auto *TemplateTypeParm =
 dyn_cast(Loc.getType())) {
   return setResult(TemplateTypeParm->getDecl(), TypeBeginLoc, TypeEndLoc);


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D24002: clang-rename: improve error message when -old-name is used and could not find symbol

2016-08-30 Thread Miklos Vajna via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL280062: clang-rename: improve error message when -old-name 
is used and could not find… (authored by vmiklos).

Changed prior to commit:
  https://reviews.llvm.org/D24002?vs=69644&id=69646#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D24002

Files:
  clang-tools-extra/trunk/clang-rename/USRFindingAction.cpp
  clang-tools-extra/trunk/test/clang-rename/InvalidOldName.cpp

Index: clang-tools-extra/trunk/clang-rename/USRFindingAction.cpp
===
--- clang-tools-extra/trunk/clang-rename/USRFindingAction.cpp
+++ clang-tools-extra/trunk/clang-rename/USRFindingAction.cpp
@@ -157,12 +157,15 @@
   FoundDecl = getNamedDeclFor(Context, OldName);
 }
 if (FoundDecl == nullptr) {
-  FullSourceLoc FullLoc(Point, SourceMgr);
-  errs() << "clang-rename: could not find symbol at "
- << SourceMgr.getFilename(Point) << ":"
- << FullLoc.getSpellingLineNumber() << ":"
- << FullLoc.getSpellingColumnNumber() << " (offset " << 
SymbolOffset
- << ").\n";
+  if (OldName.empty()) {
+FullSourceLoc FullLoc(Point, SourceMgr);
+errs() << "clang-rename: could not find symbol at "
+   << SourceMgr.getFilename(Point) << ":"
+   << FullLoc.getSpellingLineNumber() << ":"
+   << FullLoc.getSpellingColumnNumber() << " (offset "
+   << SymbolOffset << ").\n";
+  } else
+errs() << "clang-rename: could not find symbol " << OldName << ".\n";
   return;
 }
 
Index: clang-tools-extra/trunk/test/clang-rename/InvalidOldName.cpp
===
--- clang-tools-extra/trunk/test/clang-rename/InvalidOldName.cpp
+++ clang-tools-extra/trunk/test/clang-rename/InvalidOldName.cpp
@@ -0,0 +1,2 @@
+// RUN: not clang-rename rename-all -new-name=Foo -old-name=Bar %s -- 2>&1 | 
FileCheck %s
+// CHECK: clang-rename: could not find symbol Bar.


Index: clang-tools-extra/trunk/clang-rename/USRFindingAction.cpp
===
--- clang-tools-extra/trunk/clang-rename/USRFindingAction.cpp
+++ clang-tools-extra/trunk/clang-rename/USRFindingAction.cpp
@@ -157,12 +157,15 @@
   FoundDecl = getNamedDeclFor(Context, OldName);
 }
 if (FoundDecl == nullptr) {
-  FullSourceLoc FullLoc(Point, SourceMgr);
-  errs() << "clang-rename: could not find symbol at "
- << SourceMgr.getFilename(Point) << ":"
- << FullLoc.getSpellingLineNumber() << ":"
- << FullLoc.getSpellingColumnNumber() << " (offset " << SymbolOffset
- << ").\n";
+  if (OldName.empty()) {
+FullSourceLoc FullLoc(Point, SourceMgr);
+errs() << "clang-rename: could not find symbol at "
+   << SourceMgr.getFilename(Point) << ":"
+   << FullLoc.getSpellingLineNumber() << ":"
+   << FullLoc.getSpellingColumnNumber() << " (offset "
+   << SymbolOffset << ").\n";
+  } else
+errs() << "clang-rename: could not find symbol " << OldName << ".\n";
   return;
 }
 
Index: clang-tools-extra/trunk/test/clang-rename/InvalidOldName.cpp
===
--- clang-tools-extra/trunk/test/clang-rename/InvalidOldName.cpp
+++ clang-tools-extra/trunk/test/clang-rename/InvalidOldName.cpp
@@ -0,0 +1,2 @@
+// RUN: not clang-rename rename-all -new-name=Foo -old-name=Bar %s -- 2>&1 | FileCheck %s
+// CHECK: clang-rename: could not find symbol Bar.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] r280062 - clang-rename: improve error message when -old-name is used and could not find symbol

2016-08-30 Thread Miklos Vajna via cfe-commits
Author: vmiklos
Date: Tue Aug 30 02:23:24 2016
New Revision: 280062

URL: http://llvm.org/viewvc/llvm-project?rev=280062&view=rev
Log:
clang-rename: improve error message when -old-name is used and could not find 
symbol

Old output was:

clang-rename: could not find symbol at 
tools/clang/tools/extra/test/clang-rename/ClassFindByName.cpp:1:1 (offset 0).

Reviewers: omtcyfz

Differential Revision: https://reviews.llvm.org/D24002

Added:
clang-tools-extra/trunk/test/clang-rename/InvalidOldName.cpp
Modified:
clang-tools-extra/trunk/clang-rename/USRFindingAction.cpp

Modified: clang-tools-extra/trunk/clang-rename/USRFindingAction.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-rename/USRFindingAction.cpp?rev=280062&r1=280061&r2=280062&view=diff
==
--- clang-tools-extra/trunk/clang-rename/USRFindingAction.cpp (original)
+++ clang-tools-extra/trunk/clang-rename/USRFindingAction.cpp Tue Aug 30 
02:23:24 2016
@@ -157,12 +157,15 @@ struct NamedDeclFindingConsumer : public
   FoundDecl = getNamedDeclFor(Context, OldName);
 }
 if (FoundDecl == nullptr) {
-  FullSourceLoc FullLoc(Point, SourceMgr);
-  errs() << "clang-rename: could not find symbol at "
- << SourceMgr.getFilename(Point) << ":"
- << FullLoc.getSpellingLineNumber() << ":"
- << FullLoc.getSpellingColumnNumber() << " (offset " << 
SymbolOffset
- << ").\n";
+  if (OldName.empty()) {
+FullSourceLoc FullLoc(Point, SourceMgr);
+errs() << "clang-rename: could not find symbol at "
+   << SourceMgr.getFilename(Point) << ":"
+   << FullLoc.getSpellingLineNumber() << ":"
+   << FullLoc.getSpellingColumnNumber() << " (offset "
+   << SymbolOffset << ").\n";
+  } else
+errs() << "clang-rename: could not find symbol " << OldName << ".\n";
   return;
 }
 

Added: clang-tools-extra/trunk/test/clang-rename/InvalidOldName.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-rename/InvalidOldName.cpp?rev=280062&view=auto
==
--- clang-tools-extra/trunk/test/clang-rename/InvalidOldName.cpp (added)
+++ clang-tools-extra/trunk/test/clang-rename/InvalidOldName.cpp Tue Aug 30 
02:23:24 2016
@@ -0,0 +1,2 @@
+// RUN: not clang-rename rename-all -new-name=Foo -old-name=Bar %s -- 2>&1 | 
FileCheck %s
+// CHECK: clang-rename: could not find symbol Bar.


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D24002: clang-rename: improve error message when -old-name is used and could not find symbol

2016-08-30 Thread Miklos Vajna via cfe-commits
vmiklos marked an inline comment as done.
vmiklos added a comment.

> Probably something like "could not find symbol OldName" would be reasonable, 
> too.


OK, changed.


https://reviews.llvm.org/D24002



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D24002: clang-rename: improve error message when -old-name is used and could not find symbol

2016-08-30 Thread Miklos Vajna via cfe-commits
vmiklos updated this revision to Diff 69644.

https://reviews.llvm.org/D24002

Files:
  clang-rename/USRFindingAction.cpp
  test/clang-rename/InvalidOldName.cpp

Index: test/clang-rename/InvalidOldName.cpp
===
--- /dev/null
+++ test/clang-rename/InvalidOldName.cpp
@@ -0,0 +1,2 @@
+// RUN: not clang-rename rename-all -new-name=Foo -old-name=Bar %s -- 2>&1 | 
FileCheck %s
+// CHECK: clang-rename: could not find symbol Bar.
Index: clang-rename/USRFindingAction.cpp
===
--- clang-rename/USRFindingAction.cpp
+++ clang-rename/USRFindingAction.cpp
@@ -157,12 +157,15 @@
   FoundDecl = getNamedDeclFor(Context, OldName);
 }
 if (FoundDecl == nullptr) {
-  FullSourceLoc FullLoc(Point, SourceMgr);
-  errs() << "clang-rename: could not find symbol at "
- << SourceMgr.getFilename(Point) << ":"
- << FullLoc.getSpellingLineNumber() << ":"
- << FullLoc.getSpellingColumnNumber() << " (offset " << 
SymbolOffset
- << ").\n";
+  if (OldName.empty()) {
+FullSourceLoc FullLoc(Point, SourceMgr);
+errs() << "clang-rename: could not find symbol at "
+   << SourceMgr.getFilename(Point) << ":"
+   << FullLoc.getSpellingLineNumber() << ":"
+   << FullLoc.getSpellingColumnNumber() << " (offset "
+   << SymbolOffset << ").\n";
+  } else
+errs() << "clang-rename: could not find symbol " << OldName << ".\n";
   return;
 }
 


Index: test/clang-rename/InvalidOldName.cpp
===
--- /dev/null
+++ test/clang-rename/InvalidOldName.cpp
@@ -0,0 +1,2 @@
+// RUN: not clang-rename rename-all -new-name=Foo -old-name=Bar %s -- 2>&1 | FileCheck %s
+// CHECK: clang-rename: could not find symbol Bar.
Index: clang-rename/USRFindingAction.cpp
===
--- clang-rename/USRFindingAction.cpp
+++ clang-rename/USRFindingAction.cpp
@@ -157,12 +157,15 @@
   FoundDecl = getNamedDeclFor(Context, OldName);
 }
 if (FoundDecl == nullptr) {
-  FullSourceLoc FullLoc(Point, SourceMgr);
-  errs() << "clang-rename: could not find symbol at "
- << SourceMgr.getFilename(Point) << ":"
- << FullLoc.getSpellingLineNumber() << ":"
- << FullLoc.getSpellingColumnNumber() << " (offset " << SymbolOffset
- << ").\n";
+  if (OldName.empty()) {
+FullSourceLoc FullLoc(Point, SourceMgr);
+errs() << "clang-rename: could not find symbol at "
+   << SourceMgr.getFilename(Point) << ":"
+   << FullLoc.getSpellingLineNumber() << ":"
+   << FullLoc.getSpellingColumnNumber() << " (offset "
+   << SymbolOffset << ").\n";
+  } else
+errs() << "clang-rename: could not find symbol " << OldName << ".\n";
   return;
 }
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D24002: clang-rename: improve error message when -old-name is used and could not find symbol

2016-08-29 Thread Miklos Vajna via cfe-commits
vmiklos created this revision.
vmiklos added reviewers: klimek, omtcyfz.
vmiklos added a subscriber: cfe-commits.

Old output was:

clang-rename: could not find symbol at 
tools/clang/tools/extra/test/clang-rename/ClassFindByName.cpp:1:1 (offset 0). 

https://reviews.llvm.org/D24002

Files:
  clang-rename/USRFindingAction.cpp
  test/clang-rename/InvalidOldName.cpp

Index: test/clang-rename/InvalidOldName.cpp
===
--- /dev/null
+++ test/clang-rename/InvalidOldName.cpp
@@ -0,0 +1,2 @@
+// RUN: not clang-rename rename-all -new-name=Foo -old-name=Bar %s -- 2>&1 | 
FileCheck %s
+// CHECK: clang-rename: could not find symbol named Bar.
Index: clang-rename/USRFindingAction.cpp
===
--- clang-rename/USRFindingAction.cpp
+++ clang-rename/USRFindingAction.cpp
@@ -157,12 +157,16 @@
   FoundDecl = getNamedDeclFor(Context, OldName);
 }
 if (FoundDecl == nullptr) {
-  FullSourceLoc FullLoc(Point, SourceMgr);
-  errs() << "clang-rename: could not find symbol at "
- << SourceMgr.getFilename(Point) << ":"
- << FullLoc.getSpellingLineNumber() << ":"
- << FullLoc.getSpellingColumnNumber() << " (offset " << 
SymbolOffset
- << ").\n";
+  if (OldName.empty()) {
+FullSourceLoc FullLoc(Point, SourceMgr);
+errs() << "clang-rename: could not find symbol at "
+   << SourceMgr.getFilename(Point) << ":"
+   << FullLoc.getSpellingLineNumber() << ":"
+   << FullLoc.getSpellingColumnNumber() << " (offset "
+   << SymbolOffset << ").\n";
+  } else
+errs() << "clang-rename: could not find symbol named " << OldName
+   << ".\n";
   return;
 }
 


Index: test/clang-rename/InvalidOldName.cpp
===
--- /dev/null
+++ test/clang-rename/InvalidOldName.cpp
@@ -0,0 +1,2 @@
+// RUN: not clang-rename rename-all -new-name=Foo -old-name=Bar %s -- 2>&1 | FileCheck %s
+// CHECK: clang-rename: could not find symbol named Bar.
Index: clang-rename/USRFindingAction.cpp
===
--- clang-rename/USRFindingAction.cpp
+++ clang-rename/USRFindingAction.cpp
@@ -157,12 +157,16 @@
   FoundDecl = getNamedDeclFor(Context, OldName);
 }
 if (FoundDecl == nullptr) {
-  FullSourceLoc FullLoc(Point, SourceMgr);
-  errs() << "clang-rename: could not find symbol at "
- << SourceMgr.getFilename(Point) << ":"
- << FullLoc.getSpellingLineNumber() << ":"
- << FullLoc.getSpellingColumnNumber() << " (offset " << SymbolOffset
- << ").\n";
+  if (OldName.empty()) {
+FullSourceLoc FullLoc(Point, SourceMgr);
+errs() << "clang-rename: could not find symbol at "
+   << SourceMgr.getFilename(Point) << ":"
+   << FullLoc.getSpellingLineNumber() << ":"
+   << FullLoc.getSpellingColumnNumber() << " (offset "
+   << SymbolOffset << ").\n";
+  } else
+errs() << "clang-rename: could not find symbol named " << OldName
+   << ".\n";
   return;
 }
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D23651: [clang-rename] improve performance for rename-all

2016-08-25 Thread Miklos Vajna via cfe-commits
vmiklos added a comment.

> If I understood correctly, you and Alex are talking about different things.


Yes, sorry, the context of my above comment was the cl::opt instances in the 
tool itself, not the various parameters to the different actions called from 
the tool.


https://reviews.llvm.org/D23651



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D23651: [clang-rename] improve performance for rename-all

2016-08-19 Thread Miklos Vajna via cfe-commits
vmiklos added a comment.

It is expected that either SymbolOffsets or OldNames is empty, and the size of 
the non-empty container is the same as the size of the NewNames container. So 
no, the code does not rely on the offsets and the old names having the same 
length.


https://reviews.llvm.org/D23651



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D23651: [clang-rename] improve performance for rename-all

2016-08-18 Thread Miklos Vajna via cfe-commits
vmiklos added a comment.

I can confirm that with this, the test script from the mail thread shows that 
clang-rename is almost as fast as clang++ as expected. Thanks!


https://reviews.llvm.org/D23651



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [clang-tools-extra] r278295 - [Documentation] Improve consistency.

2016-08-15 Thread Miklos Vajna via cfe-commits
Hi Eugene,

On Wed, Aug 10, 2016 at 10:00:50PM -, Eugene Zelenko via cfe-commits 
 wrote:
> Modified: clang-tools-extra/trunk/docs/clang-rename.rst
> URL: 
> http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/docs/clang-rename.rst?rev=278295&r1=278294&r2=278295&view=diff
> ==
> --- clang-tools-extra/trunk/docs/clang-rename.rst (original)
> +++ clang-tools-extra/trunk/docs/clang-rename.rst Wed Aug 10 17:00:49 2016
> @@ -70,7 +70,7 @@ Alternatively, old name / new name pairs
>...
>  
>  
> -That way you can avoid spelling out all the names as commandline arguments:
> +That way you can avoid spelling out all the names as command line arguments:
>  
>  .. code-block:: console
>  
> @@ -122,12 +122,12 @@ The YAML file also supports offsets:
>clang-rename rename-at options:
>  
>  -export-fixes=   - YAML file to store suggested fixes in.
> --extra-arg=- Additional argument to append to the 
> compiler command line
> --extra-arg-before= - Additional argument to prepend to the 
> compiler command line
> +-extra-arg=- Additional argument to append to the 
> compiler command line.
> +-extra-arg-before= - Additional argument to prepend to the 
> compiler command line.
>  -i - Overwrite edited s.
>  -new-name= - The new name to change the symbol to.
>  -offset= - Locates the symbol by offset as opposed to 
> :.
> --p=- Build path
> +-p=- Build path.

This is the output of the commandline tool. Is it wise to modify the
documentation, even if the tool's output stays the same? I fear it'll be
reverted implicitly next time we copy&paste the output after a code
change.

Regards,

Miklos
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D23198: clang-rename rename-all: support reading old/newname pairs from a YAML file

2016-08-10 Thread Miklos Vajna via cfe-commits
vmiklos added a comment.

In https://reviews.llvm.org/D23198#510269, @alexfh wrote:

> A few late comments.


I've addressed these in r278201.


Repository:
  rL LLVM

https://reviews.llvm.org/D23198



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] r278201 - clang-rename YAML reader: address post-commit comments

2016-08-10 Thread Miklos Vajna via cfe-commits
Author: vmiklos
Date: Wed Aug 10 02:13:29 2016
New Revision: 278201

URL: http://llvm.org/viewvc/llvm-project?rev=278201&view=rev
Log:
clang-rename YAML reader: address post-commit comments

Modified:
clang-tools-extra/trunk/clang-rename/tool/ClangRename.cpp
clang-tools-extra/trunk/docs/clang-rename.rst

Modified: clang-tools-extra/trunk/clang-rename/tool/ClangRename.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-rename/tool/ClangRename.cpp?rev=278201&r1=278200&r2=278201&view=diff
==
--- clang-tools-extra/trunk/clang-rename/tool/ClangRename.cpp (original)
+++ clang-tools-extra/trunk/clang-rename/tool/ClangRename.cpp Wed Aug 10 
02:13:29 2016
@@ -59,10 +59,8 @@ static int helpMain(int argc, const char
 /// \brief An oldname -> newname rename.
 struct RenameAllInfo {
   std::string OldName;
-  unsigned Offset;
+  unsigned Offset = 0;
   std::string NewName;
-
-  RenameAllInfo() : Offset(0) {}
 };
 
 LLVM_YAML_IS_SEQUENCE_VECTOR(RenameAllInfo)
@@ -70,7 +68,7 @@ LLVM_YAML_IS_SEQUENCE_VECTOR(RenameAllIn
 namespace llvm {
 namespace yaml {
 
-/// \brief Specialized MappingTraits to describe how a RenameAllInfo is /
+/// \brief Specialized MappingTraits to describe how a RenameAllInfo is
 /// (de)serialized.
 template <> struct MappingTraits {
   static void mapping(IO &IO, RenameAllInfo &Info) {
@@ -149,11 +147,12 @@ int subcommandMain(bool isRenameAll, int
 
   if (!Input.empty()) {
 // Populate OldNames and NewNames from a YAML file.
-auto Buffer = llvm::MemoryBuffer::getFile(Input);
+ErrorOr> Buffer =
+llvm::MemoryBuffer::getFile(Input);
 if (!Buffer) {
   errs() << "clang-rename: failed to read " << Input << ": "
  << Buffer.getError().message() << "\n";
-  exit(1);
+  return 1;
 }
 
 std::vector Infos;

Modified: clang-tools-extra/trunk/docs/clang-rename.rst
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/docs/clang-rename.rst?rev=278201&r1=278200&r2=278201&view=diff
==
--- clang-tools-extra/trunk/docs/clang-rename.rst (original)
+++ clang-tools-extra/trunk/docs/clang-rename.rst Wed Aug 10 02:13:29 2016
@@ -42,7 +42,7 @@ To get an offset of a symbol in a file r
   $ grep -FUbo 'foo' file.cpp
 
 
-The tool currently supports renaming actions inside a single Translation Unit
+The tool currently supports renaming actions inside a single translation unit
 only. It is planned to extend the tool's functionality to support multi-TU
 renaming actions in the future.
 


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D23198: clang-rename rename-all: support reading old/newname pairs from a YAML file

2016-08-09 Thread Miklos Vajna via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL278145: clang-rename rename-all: support reading old/newname 
pairs from a YAML file (authored by vmiklos).

Changed prior to commit:
  https://reviews.llvm.org/D23198?vs=67215&id=67381#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D23198

Files:
  clang-tools-extra/trunk/clang-rename/tool/ClangRename.cpp
  clang-tools-extra/trunk/docs/clang-rename.rst
  clang-tools-extra/trunk/test/clang-rename/ClassTestMultiByNameYAML.cpp
  
clang-tools-extra/trunk/test/clang-rename/Inputs/ClassTestMultiByNameYAMLRenameAll.yaml
  
clang-tools-extra/trunk/test/clang-rename/Inputs/ClassTestMultiByNameYAMLRenameAt.yaml

Index: clang-tools-extra/trunk/clang-rename/tool/ClangRename.cpp
===
--- clang-tools-extra/trunk/clang-rename/tool/ClangRename.cpp
+++ clang-tools-extra/trunk/clang-rename/tool/ClangRename.cpp
@@ -56,6 +56,33 @@
 static int renameAllMain(int argc, const char *argv[]);
 static int helpMain(int argc, const char *argv[]);
 
+/// \brief An oldname -> newname rename.
+struct RenameAllInfo {
+  std::string OldName;
+  unsigned Offset;
+  std::string NewName;
+
+  RenameAllInfo() : Offset(0) {}
+};
+
+LLVM_YAML_IS_SEQUENCE_VECTOR(RenameAllInfo)
+
+namespace llvm {
+namespace yaml {
+
+/// \brief Specialized MappingTraits to describe how a RenameAllInfo is /
+/// (de)serialized.
+template <> struct MappingTraits {
+  static void mapping(IO &IO, RenameAllInfo &Info) {
+IO.mapOptional("OldName", Info.OldName);
+IO.mapOptional("Offset", Info.Offset);
+IO.mapRequired("NewName", Info.NewName);
+  }
+};
+
+} // end namespace yaml
+} // end namespace llvm
+
 int main(int argc, const char **argv) {
   if (argc > 1) {
 using MainFunction = std::function;
@@ -91,7 +118,7 @@
 
   cl::list NewNames(
   "new-name", cl::desc("The new name to change the symbol to."),
-  (isRenameAll ? cl::OneOrMore : cl::Required), cl::cat(*Category));
+  (isRenameAll ? cl::ZeroOrMore : cl::Required), cl::cat(*Category));
   cl::list SymbolOffsets(
   "offset",
   cl::desc("Locates the symbol by offset as opposed to :."),
@@ -114,11 +141,40 @@
   cl::opt ExportFixes(
   "export-fixes", cl::desc("YAML file to store suggested fixes in."),
   cl::value_desc("filename"), cl::cat(*Category));
+  cl::opt Input(
+  "input", cl::desc("YAML file to load oldname-newname pairs from."),
+  cl::Optional, cl::cat(ClangRenameAllCategory));
 
   tooling::CommonOptionsParser OP(argc, argv, *Category, Usage);
 
+  if (!Input.empty()) {
+// Populate OldNames and NewNames from a YAML file.
+auto Buffer = llvm::MemoryBuffer::getFile(Input);
+if (!Buffer) {
+  errs() << "clang-rename: failed to read " << Input << ": "
+ << Buffer.getError().message() << "\n";
+  exit(1);
+}
+
+std::vector Infos;
+llvm::yaml::Input YAML(Buffer.get()->getBuffer());
+YAML >> Infos;
+for (const auto &Info : Infos) {
+  if (!Info.OldName.empty())
+OldNames.push_back(Info.OldName);
+  else
+SymbolOffsets.push_back(Info.Offset);
+  NewNames.push_back(Info.NewName);
+}
+  }
+
   // Check the arguments for correctness.
 
+  if (NewNames.empty()) {
+errs() << "clang-rename: either -new-name or -input is required.\n\n";
+exit(1);
+  }
+
   // Check if NewNames is a valid identifier in C++17.
   for (const auto &NewName : NewNames) {
 LangOptions Options;
Index: clang-tools-extra/trunk/docs/clang-rename.rst
===
--- clang-tools-extra/trunk/docs/clang-rename.rst
+++ clang-tools-extra/trunk/docs/clang-rename.rst
@@ -42,23 +42,52 @@
   $ grep -FUbo 'foo' file.cpp
 
 
+The tool currently supports renaming actions inside a single Translation Unit
+only. It is planned to extend the tool's functionality to support multi-TU
+renaming actions in the future.
+
+:program:`clang-rename` also aims to be easily integrated into popular text
+editors, such as Vim and Emacs, and improve the workflow of users.
+
+Although a command line interface exists, it is highly recommended to use the
+text editor interface instead for better experience.
+
 You can also identify one or more symbols to be renamed by giving the fully qualified
 name:
 
 .. code-block:: console
 
   $ clang-rename rename-all -old-name=foo -new-name=bar test.cpp
 
 
-The tool currently supports renaming actions inside a single Translation Unit
-only. It is planned to extend the tool's functionality to support multi-TU
-renaming actions in the future.
+Alternatively, old name / new name pairs can be put into a YAML file:
 
-:program:`clang-rename` also aims to be easily integrated into popular text
-editors, such as Vim and Emacs, and improve the workflow of users.
+.. code-block:: yaml
 
-Although a command line interface exists, it is highly recommended to use the
-text editor i

[clang-tools-extra] r278145 - clang-rename rename-all: support reading old/newname pairs from a YAML file

2016-08-09 Thread Miklos Vajna via cfe-commits
Author: vmiklos
Date: Tue Aug  9 13:20:41 2016
New Revision: 278145

URL: http://llvm.org/viewvc/llvm-project?rev=278145&view=rev
Log:
clang-rename rename-all: support reading old/newname pairs from a YAML file

This is handy in case by the time clang-rename is invoked, an external
tool already genereated a list of oldname -> newname pairs to handle.

Reviewers: omtcyfz

Differential Revision: https://reviews.llvm.org/D23198

Added:
clang-tools-extra/trunk/test/clang-rename/ClassTestMultiByNameYAML.cpp
clang-tools-extra/trunk/test/clang-rename/Inputs/

clang-tools-extra/trunk/test/clang-rename/Inputs/ClassTestMultiByNameYAMLRenameAll.yaml

clang-tools-extra/trunk/test/clang-rename/Inputs/ClassTestMultiByNameYAMLRenameAt.yaml
Modified:
clang-tools-extra/trunk/clang-rename/tool/ClangRename.cpp
clang-tools-extra/trunk/docs/clang-rename.rst

Modified: clang-tools-extra/trunk/clang-rename/tool/ClangRename.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-rename/tool/ClangRename.cpp?rev=278145&r1=278144&r2=278145&view=diff
==
--- clang-tools-extra/trunk/clang-rename/tool/ClangRename.cpp (original)
+++ clang-tools-extra/trunk/clang-rename/tool/ClangRename.cpp Tue Aug  9 
13:20:41 2016
@@ -56,6 +56,33 @@ static int renameAtMain(int argc, const
 static int renameAllMain(int argc, const char *argv[]);
 static int helpMain(int argc, const char *argv[]);
 
+/// \brief An oldname -> newname rename.
+struct RenameAllInfo {
+  std::string OldName;
+  unsigned Offset;
+  std::string NewName;
+
+  RenameAllInfo() : Offset(0) {}
+};
+
+LLVM_YAML_IS_SEQUENCE_VECTOR(RenameAllInfo)
+
+namespace llvm {
+namespace yaml {
+
+/// \brief Specialized MappingTraits to describe how a RenameAllInfo is /
+/// (de)serialized.
+template <> struct MappingTraits {
+  static void mapping(IO &IO, RenameAllInfo &Info) {
+IO.mapOptional("OldName", Info.OldName);
+IO.mapOptional("Offset", Info.Offset);
+IO.mapRequired("NewName", Info.NewName);
+  }
+};
+
+} // end namespace yaml
+} // end namespace llvm
+
 int main(int argc, const char **argv) {
   if (argc > 1) {
 using MainFunction = std::function;
@@ -91,7 +118,7 @@ int subcommandMain(bool isRenameAll, int
 
   cl::list NewNames(
   "new-name", cl::desc("The new name to change the symbol to."),
-  (isRenameAll ? cl::OneOrMore : cl::Required), cl::cat(*Category));
+  (isRenameAll ? cl::ZeroOrMore : cl::Required), cl::cat(*Category));
   cl::list SymbolOffsets(
   "offset",
   cl::desc("Locates the symbol by offset as opposed to :."),
@@ -114,11 +141,40 @@ int subcommandMain(bool isRenameAll, int
   cl::opt ExportFixes(
   "export-fixes", cl::desc("YAML file to store suggested fixes in."),
   cl::value_desc("filename"), cl::cat(*Category));
+  cl::opt Input(
+  "input", cl::desc("YAML file to load oldname-newname pairs from."),
+  cl::Optional, cl::cat(ClangRenameAllCategory));
 
   tooling::CommonOptionsParser OP(argc, argv, *Category, Usage);
 
+  if (!Input.empty()) {
+// Populate OldNames and NewNames from a YAML file.
+auto Buffer = llvm::MemoryBuffer::getFile(Input);
+if (!Buffer) {
+  errs() << "clang-rename: failed to read " << Input << ": "
+ << Buffer.getError().message() << "\n";
+  exit(1);
+}
+
+std::vector Infos;
+llvm::yaml::Input YAML(Buffer.get()->getBuffer());
+YAML >> Infos;
+for (const auto &Info : Infos) {
+  if (!Info.OldName.empty())
+OldNames.push_back(Info.OldName);
+  else
+SymbolOffsets.push_back(Info.Offset);
+  NewNames.push_back(Info.NewName);
+}
+  }
+
   // Check the arguments for correctness.
 
+  if (NewNames.empty()) {
+errs() << "clang-rename: either -new-name or -input is required.\n\n";
+exit(1);
+  }
+
   // Check if NewNames is a valid identifier in C++17.
   for (const auto &NewName : NewNames) {
 LangOptions Options;

Modified: clang-tools-extra/trunk/docs/clang-rename.rst
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/docs/clang-rename.rst?rev=278145&r1=278144&r2=278145&view=diff
==
--- clang-tools-extra/trunk/docs/clang-rename.rst (original)
+++ clang-tools-extra/trunk/docs/clang-rename.rst Tue Aug  9 13:20:41 2016
@@ -42,6 +42,16 @@ To get an offset of a symbol in a file r
   $ grep -FUbo 'foo' file.cpp
 
 
+The tool currently supports renaming actions inside a single Translation Unit
+only. It is planned to extend the tool's functionality to support multi-TU
+renaming actions in the future.
+
+:program:`clang-rename` also aims to be easily integrated into popular text
+editors, such as Vim and Emacs, and improve the workflow of users.
+
+Although a command line interface exists, it is highly recommended to use the
+text editor interface instead for better experience.
+
 You can also iden

Re: [PATCH] D23198: clang-rename rename-all: support reading old/newname pairs from a YAML file

2016-08-09 Thread Miklos Vajna via cfe-commits
vmiklos added inline comments.


Comment at: clang-rename/tool/ClangRename.cpp:65
@@ +64,3 @@
+
+  RenameAllInfo() : Offset(0) {}
+};

omtcyfz wrote:
> omtcyfz wrote:
> > vmiklos wrote:
> > > omtcyfz wrote:
> > > > AFAIK there's no need to do that, integer types are by default 
> > > > initialized with 0, aren't they?
> > > Are you sure? Here is a minimal version that shows what goes wrong when 
> > > that's not initialized explicitly: http://pastebin.com/raw/2ZsUgWf6 The 
> > > "Use of uninitialised value of size 8" goes away with an explicit 
> > > initialization.
> > Well, in this case - yes. But in that case the default unsigned constructor 
> > isn't called.
> > 
> > What I meant is:
> > 
> > ```
> > RenameAllInfo() : Offset(0) {}
> > ```
> > - > 
> > ```
> > RenameAllInfo() : Offset() {}
> > ```
> > 
> > In this case Offset is default-constructed. However, it is also true that 
> > one might argue that it's less "trivial" (whatever "triviality" definition 
> > would be :]). I guess it's fine to leave it like this.
> > Well, in this case - yes. But in that case the default unsigned constructor 
> > isn't called.
> 
> 
> 
> -> Well, in the case you sent - yes. But there is no default-construction 
> there as there is no constructor with initializer list at all.
Ah, I see what you mean. :-) I don't mind either way, but then I'll leave it 
as-is for now.


https://reviews.llvm.org/D23198



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D23198: clang-rename rename-all: support reading old/newname pairs from a YAML file

2016-08-09 Thread Miklos Vajna via cfe-commits
vmiklos added inline comments.


Comment at: clang-rename/tool/ClangRename.cpp:65
@@ +64,3 @@
+
+  RenameAllInfo() : Offset(0) {}
+};

omtcyfz wrote:
> AFAIK there's no need to do that, integer types are by default initialized 
> with 0, aren't they?
Are you sure? Here is a minimal version that shows what goes wrong when that's 
not initialized explicitly: http://pastebin.com/raw/2ZsUgWf6 The "Use of 
uninitialised value of size 8" goes away with an explicit initialization.


https://reviews.llvm.org/D23198



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D23198: clang-rename rename-all: support reading old/newname pairs from a YAML file

2016-08-08 Thread Miklos Vajna via cfe-commits
vmiklos added a comment.

> .cpp.rename-at.yaml?


I just discovered that lit provides %S that allows getting rid of the confusing
.cpp.yaml, I'm using that now.

> Ah, and yes, it's better to move *.yaml to extra/test/clang-rename/Inputs


Done.


https://reviews.llvm.org/D23198



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D23198: clang-rename rename-all: support reading old/newname pairs from a YAML file

2016-08-08 Thread Miklos Vajna via cfe-commits
vmiklos updated this revision to Diff 67215.

https://reviews.llvm.org/D23198

Files:
  clang-rename/tool/ClangRename.cpp
  docs/clang-rename.rst
  test/clang-rename/ClassTestMultiByNameYAML.cpp
  test/clang-rename/Inputs/ClassTestMultiByNameYAMLRenameAll.yaml
  test/clang-rename/Inputs/ClassTestMultiByNameYAMLRenameAt.yaml

Index: test/clang-rename/Inputs/ClassTestMultiByNameYAMLRenameAt.yaml
===
--- /dev/null
+++ test/clang-rename/Inputs/ClassTestMultiByNameYAMLRenameAt.yaml
@@ -0,0 +1,6 @@
+---
+- Offset: 6
+  NewName:Bar1
+- Offset: 44
+  NewName:Bar2
+...
Index: test/clang-rename/Inputs/ClassTestMultiByNameYAMLRenameAll.yaml
===
--- /dev/null
+++ test/clang-rename/Inputs/ClassTestMultiByNameYAMLRenameAll.yaml
@@ -0,0 +1,6 @@
+---
+- OldName:Foo1
+  NewName:Bar1
+- OldName:Foo2
+  NewName:Bar2
+...
Index: test/clang-rename/ClassTestMultiByNameYAML.cpp
===
--- /dev/null
+++ test/clang-rename/ClassTestMultiByNameYAML.cpp
@@ -0,0 +1,7 @@
+class Foo1 { // CHECK: class Bar1
+};
+
+class Foo2 { // CHECK: class Bar2
+};
+// RUN: clang-rename rename-all -input %S/Inputs/ClassTestMultiByNameYAMLRenameAll.yaml %s -- | sed 's,//.*,,' | FileCheck %s
+// RUN: clang-rename rename-all -input %S/Inputs/ClassTestMultiByNameYAMLRenameAt.yaml %s -- | sed 's,//.*,,' | FileCheck %s
Index: docs/clang-rename.rst
===
--- docs/clang-rename.rst
+++ docs/clang-rename.rst
@@ -42,23 +42,52 @@
   $ grep -FUbo 'foo' file.cpp
 
 
+The tool currently supports renaming actions inside a single Translation Unit
+only. It is planned to extend the tool's functionality to support multi-TU
+renaming actions in the future.
+
+:program:`clang-rename` also aims to be easily integrated into popular text
+editors, such as Vim and Emacs, and improve the workflow of users.
+
+Although a command line interface exists, it is highly recommended to use the
+text editor interface instead for better experience.
+
 You can also identify one or more symbols to be renamed by giving the fully qualified
 name:
 
 .. code-block:: console
 
   $ clang-rename rename-all -old-name=foo -new-name=bar test.cpp
 
 
-The tool currently supports renaming actions inside a single Translation Unit
-only. It is planned to extend the tool's functionality to support multi-TU
-renaming actions in the future.
+Alternatively, old name / new name pairs can be put into a YAML file:
 
-:program:`clang-rename` also aims to be easily integrated into popular text
-editors, such as Vim and Emacs, and improve the workflow of users.
+.. code-block:: yaml
 
-Although a command line interface exists, it is highly recommended to use the
-text editor interface instead for better experience.
+  ---
+  - OldName:foo
+NewName:bar
+  ...
+
+
+That way you can avoid spelling out all the names as commandline arguments:
+
+.. code-block:: console
+
+  $ clang-rename rename-all -input=test.yaml test.cpp
+
+
+The YAML file also supports offsets:
+
+.. code-block:: yaml
+
+  ---
+  - Offset: 42
+NewName:foo
+  ...
+
+
+:program:`clang-rename` offers the following options:
 
 .. code-block:: console
 
@@ -125,6 +154,7 @@
 -extra-arg=- Additional argument to append to the compiler command line
 -extra-arg-before= - Additional argument to prepend to the compiler command line
 -i - Overwrite edited s.
+-input=- YAML file to load oldname-newname pairs from.
 -new-name= - The new name to change the symbol to.
 -offset= - Locates the symbol by offset as opposed to :.
 -old-name= - The fully qualified name of the symbol, if -offset is not used.
Index: clang-rename/tool/ClangRename.cpp
===
--- clang-rename/tool/ClangRename.cpp
+++ clang-rename/tool/ClangRename.cpp
@@ -56,6 +56,33 @@
 static int renameAllMain(int argc, const char *argv[]);
 static int helpMain(int argc, const char *argv[]);
 
+/// \brief An oldname -> newname rename.
+struct RenameAllInfo {
+  std::string OldName;
+  unsigned Offset;
+  std::string NewName;
+
+  RenameAllInfo() : Offset(0) {}
+};
+
+LLVM_YAML_IS_SEQUENCE_VECTOR(RenameAllInfo)
+
+namespace llvm {
+namespace yaml {
+
+/// \brief Specialized MappingTraits to describe how a RenameAllInfo is /
+/// (de)serialized.
+template <> struct MappingTraits {
+  static void mapping(IO &IO, RenameAllInfo &Info) {
+IO.mapOptional("OldName", Info.OldName);
+IO.mapOptional("Offset", Info.Offset);
+IO.mapRequired("NewName", Info.NewName);
+  }
+};
+
+} // end namespace yaml
+} // end namespace llvm
+
 int main(int argc, const char **argv) {
   if (argc > 1) {
 using 

Re: [PATCH] D23198: clang-rename rename-all: support reading old/newname pairs from a YAML file

2016-08-05 Thread Miklos Vajna via cfe-commits
vmiklos marked 2 inline comments as done.
vmiklos added a comment.

> Would also be nice to support at least `offset + new-name` in YAML input 
> files, too.


Done.

> Please move this block upwards [preferably right after line 42]. I consider

>  information about limitations and editor more important than numerous

>  clang-rename's terminal interface invocation examples.


Makes sense, done. I wouldn't mind if rename-all wouldn't be advertised (apart
from dumping the options) at all in the documentation, but then users would
have to look at the source code for what is the wanted YAML format, and *that*
would be bad, I guess. ;-)

> https://reviews.llvm.org/D23158 introduces simpler clang-rename invocations

>  in tests. Please do that here, too.


Done.


https://reviews.llvm.org/D23198



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D23198: clang-rename rename-all: support reading old/newname pairs from a YAML file

2016-08-05 Thread Miklos Vajna via cfe-commits
vmiklos updated this revision to Diff 66993.

https://reviews.llvm.org/D23198

Files:
  clang-rename/tool/ClangRename.cpp
  docs/clang-rename.rst
  test/clang-rename/ClassTestMultiByNameYAML.cpp
  test/clang-rename/ClassTestMultiByNameYAML.cpp.rename-all.yaml
  test/clang-rename/ClassTestMultiByNameYAML.cpp.rename-at.yaml

Index: test/clang-rename/ClassTestMultiByNameYAML.cpp.rename-at.yaml
===
--- /dev/null
+++ test/clang-rename/ClassTestMultiByNameYAML.cpp.rename-at.yaml
@@ -0,0 +1,6 @@
+---
+- Offset: 6
+  NewName:Bar1
+- Offset: 44
+  NewName:Bar2
+...
Index: test/clang-rename/ClassTestMultiByNameYAML.cpp.rename-all.yaml
===
--- /dev/null
+++ test/clang-rename/ClassTestMultiByNameYAML.cpp.rename-all.yaml
@@ -0,0 +1,6 @@
+---
+- OldName:Foo1
+  NewName:Bar1
+- OldName:Foo2
+  NewName:Bar2
+...
Index: test/clang-rename/ClassTestMultiByNameYAML.cpp
===
--- /dev/null
+++ test/clang-rename/ClassTestMultiByNameYAML.cpp
@@ -0,0 +1,7 @@
+class Foo1 { // CHECK: class Bar1
+};
+
+class Foo2 { // CHECK: class Bar2
+};
+// RUN: clang-rename rename-all -input %s.rename-all.yaml %s -- | sed 's,//.*,,' | FileCheck %s
+// RUN: clang-rename rename-all -input %s.rename-at.yaml %s -- | sed 's,//.*,,' | FileCheck %s
Index: docs/clang-rename.rst
===
--- docs/clang-rename.rst
+++ docs/clang-rename.rst
@@ -42,23 +42,52 @@
   $ grep -FUbo 'foo' file.cpp
 
 
+The tool currently supports renaming actions inside a single Translation Unit
+only. It is planned to extend the tool's functionality to support multi-TU
+renaming actions in the future.
+
+:program:`clang-rename` also aims to be easily integrated into popular text
+editors, such as Vim and Emacs, and improve the workflow of users.
+
+Although a command line interface exists, it is highly recommended to use the
+text editor interface instead for better experience.
+
 You can also identify one or more symbols to be renamed by giving the fully qualified
 name:
 
 .. code-block:: console
 
   $ clang-rename rename-all -old-name=foo -new-name=bar test.cpp
 
 
-The tool currently supports renaming actions inside a single Translation Unit
-only. It is planned to extend the tool's functionality to support multi-TU
-renaming actions in the future.
+Alternatively, old name / new name pairs can be put into a YAML file:
 
-:program:`clang-rename` also aims to be easily integrated into popular text
-editors, such as Vim and Emacs, and improve the workflow of users.
+.. code-block:: yaml
 
-Although a command line interface exists, it is highly recommended to use the
-text editor interface instead for better experience.
+  ---
+  - OldName:foo
+NewName:bar
+  ...
+
+
+That way you can avoid spelling out all the names as commandline arguments:
+
+.. code-block:: console
+
+  $ clang-rename rename-all -input=test.yaml test.cpp
+
+
+The YAML file also supports offsets:
+
+.. code-block:: yaml
+
+  ---
+  - Offset: 42
+NewName:foo
+  ...
+
+
+:program:`clang-rename` offers the following options:
 
 .. code-block:: console
 
@@ -125,6 +154,7 @@
 -extra-arg=- Additional argument to append to the compiler command line
 -extra-arg-before= - Additional argument to prepend to the compiler command line
 -i - Overwrite edited s.
+-input=- YAML file to load oldname-newname pairs from.
 -new-name= - The new name to change the symbol to.
 -offset= - Locates the symbol by offset as opposed to :.
 -old-name= - The fully qualified name of the symbol, if -offset is not used.
Index: clang-rename/tool/ClangRename.cpp
===
--- clang-rename/tool/ClangRename.cpp
+++ clang-rename/tool/ClangRename.cpp
@@ -56,6 +56,33 @@
 static int renameAllMain(int argc, const char *argv[]);
 static int helpMain(int argc, const char *argv[]);
 
+/// \brief An oldname -> newname rename.
+struct RenameAllInfo {
+  std::string OldName;
+  unsigned Offset;
+  std::string NewName;
+
+  RenameAllInfo() : Offset(0) {}
+};
+
+LLVM_YAML_IS_SEQUENCE_VECTOR(RenameAllInfo)
+
+namespace llvm {
+namespace yaml {
+
+/// \brief Specialized MappingTraits to describe how a RenameAllInfo is /
+/// (de)serialized.
+template <> struct MappingTraits {
+  static void mapping(IO &IO, RenameAllInfo &Info) {
+IO.mapOptional("OldName", Info.OldName);
+IO.mapOptional("Offset", Info.Offset);
+IO.mapRequired("NewName", Info.NewName);
+  }
+};
+
+} // end namespace yaml
+} // end namespace llvm
+
 int main(int argc, const char **argv) {
   if (argc > 1) {
 using MainFunction = std::function;
@@ -91,7 +118,7 @@
 
   cl::list New

Re: [PATCH] D23198: clang-rename rename-all: support reading old/newname pairs from a YAML file

2016-08-05 Thread Miklos Vajna via cfe-commits
vmiklos added inline comments.


Comment at: clang-rename/tool/ClangRename.cpp:140
@@ -116,1 +139,3 @@
   cl::value_desc("filename"), cl::cat(*Category));
+  cl::opt Input(
+  "input", cl::desc("YAML file to load oldname-newname pairs from."),

omtcyfz wrote:
> "Input" name doesn't make sense to me here.
When you feed a YAML file into include-fixer, the argument name is `-input`, 
that's what I copied. What about `-names`?


https://reviews.llvm.org/D23198



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D23198: clang-rename rename-all: support reading old/newname pairs from a YAML file

2016-08-05 Thread Miklos Vajna via cfe-commits
vmiklos added a comment.

As a side note, this is the last feature that LibreOffice's simple clang-based 
rename tool 
(https://cgit.freedesktop.org/libreoffice/contrib/dev-tools/tree/clang/rename.cxx)
 supports, and clang-rename does not. (That one takes a CSV file, but in case 
-export-fixes outputs YAML, then here the input should be YAML as well for 
consistency.


https://reviews.llvm.org/D23198



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D23198: clang-rename rename-all: support reading old/newname pairs from a YAML file

2016-08-05 Thread Miklos Vajna via cfe-commits
vmiklos created this revision.
vmiklos added reviewers: klimek, omtcyfz.
vmiklos added a subscriber: cfe-commits.

This is handy in case by the time clang-rename is invoked, an external
tool already genereated a list of oldname -> newname pairs to handle.

https://reviews.llvm.org/D23198

Files:
  clang-rename/tool/ClangRename.cpp
  docs/clang-rename.rst
  test/clang-rename/ClassTestMultiByNameYAML.cpp
  test/clang-rename/ClassTestMultiByNameYAML.cpp.yaml

Index: test/clang-rename/ClassTestMultiByNameYAML.cpp.yaml
===
--- /dev/null
+++ test/clang-rename/ClassTestMultiByNameYAML.cpp.yaml
@@ -0,0 +1,6 @@
+---
+- OldName:Foo1
+  NewName:Bar1
+- OldName:Foo2
+  NewName:Bar2
+...
Index: test/clang-rename/ClassTestMultiByNameYAML.cpp
===
--- /dev/null
+++ test/clang-rename/ClassTestMultiByNameYAML.cpp
@@ -0,0 +1,8 @@
+// RUN: cat %s > %t.cpp
+// RUN: clang-rename rename-all -input %s.yaml %t.cpp -i --
+// RUN: sed 's,//.*,,' %t.cpp | FileCheck %s
+class Foo1 { // CHECK: class Bar1
+};
+
+class Foo2 { // CHECK: class Bar2
+};
Index: docs/clang-rename.rst
===
--- docs/clang-rename.rst
+++ docs/clang-rename.rst
@@ -50,6 +50,23 @@
   $ clang-rename rename-all -old-name=foo -new-name=bar test.cpp
 
 
+Alternatively, old name / new name pairs can be put into a YAML file:
+
+.. code-block:: yaml
+
+  ---
+  - OldName:foo
+NewName:bar
+  ...
+
+
+That way you can avoid spelling out all the names as commandline arguments:
+
+.. code-block:: console
+
+  $ clang-rename rename-all -input=test.yaml test.cpp
+
+
 The tool currently supports renaming actions inside a single Translation Unit
 only. It is planned to extend the tool's functionality to support multi-TU
 renaming actions in the future.
@@ -125,6 +142,7 @@
 -extra-arg=- Additional argument to append to the compiler command line
 -extra-arg-before= - Additional argument to prepend to the compiler command line
 -i - Overwrite edited s.
+-input=- YAML file to load oldname-newname pairs from.
 -new-name= - The new name to change the symbol to.
 -offset= - Locates the symbol by offset as opposed to :.
 -old-name= - The fully qualified name of the symbol, if -offset is not used.
Index: clang-rename/tool/ClangRename.cpp
===
--- clang-rename/tool/ClangRename.cpp
+++ clang-rename/tool/ClangRename.cpp
@@ -56,6 +56,29 @@
 static int renameAllMain(int argc, const char *argv[]);
 static int helpMain(int argc, const char *argv[]);
 
+/// \brief An oldname -> newname rename.
+struct RenameAllInfo {
+  std::string OldName;
+  std::string NewName;
+};
+
+LLVM_YAML_IS_SEQUENCE_VECTOR(RenameAllInfo)
+
+namespace llvm {
+namespace yaml {
+
+/// \brief Specialized MappingTraits to describe how a RenameAllInfo is /
+/// (de)serialized.
+template <> struct MappingTraits {
+  static void mapping(IO &IO, RenameAllInfo &Info) {
+IO.mapRequired("OldName", Info.OldName);
+IO.mapRequired("NewName", Info.NewName);
+  }
+};
+
+} // end namespace yaml
+} // end namespace llvm
+
 int main(int argc, const char **argv) {
   if (argc > 1) {
 using MainFunction = std::function;
@@ -91,7 +114,7 @@
 
   cl::list NewNames(
   "new-name", cl::desc("The new name to change the symbol to."),
-  (isRenameAll ? cl::OneOrMore : cl::Required), cl::cat(*Category));
+  (isRenameAll ? cl::ZeroOrMore : cl::Required), cl::cat(*Category));
   cl::list SymbolOffsets(
   "offset",
   cl::desc("Locates the symbol by offset as opposed to :."),
@@ -114,11 +137,37 @@
   cl::opt ExportFixes(
   "export-fixes", cl::desc("YAML file to store suggested fixes in."),
   cl::value_desc("filename"), cl::cat(*Category));
+  cl::opt Input(
+  "input", cl::desc("YAML file to load oldname-newname pairs from."),
+  cl::Optional, cl::cat(ClangRenameAllCategory));
 
   tooling::CommonOptionsParser OP(argc, argv, *Category, Usage);
 
+  if (!Input.empty()) {
+// Populate OldNames and NewNames from a YAML file.
+auto Buffer = llvm::MemoryBuffer::getFile(Input);
+if (!Buffer) {
+  errs() << "clang-rename: failed to read " << Input << ": "
+ << Buffer.getError().message() << "\n";
+  exit(1);
+}
+
+std::vector Infos;
+llvm::yaml::Input YAML(Buffer.get()->getBuffer());
+YAML >> Infos;
+for (const auto &Info : Infos) {
+  OldNames.push_back(Info.OldName);
+  NewNames.push_back(Info.NewName);
+}
+  }
+
   // Check the arguments for correctness.
 
+  if (NewNames.empty()) {
+errs() << "clang-rename: either -new-name or -input is required.\n\n";
+exit(1);
+  }
+
   // Check if NewNames is a valid identifier in C++17.
   for (const

Re: [PATCH] D23153: Run clang-format on clang-rename code

2016-08-04 Thread Miklos Vajna via cfe-commits
vmiklos added a comment.

Thanks. Yes, I used the Linux-distro-provided clang-format-3.7, I didn't notice 
that the trunk version now also sorts includes.


Repository:
  rL LLVM

https://reviews.llvm.org/D23153



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D23153: Run clang-format on clang-rename code

2016-08-04 Thread Miklos Vajna via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL277702: Run clang-format on clang-rename code (authored by 
vmiklos).

Changed prior to commit:
  https://reviews.llvm.org/D23153?vs=66766&id=66769#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D23153

Files:
  clang-tools-extra/trunk/clang-rename/RenamingAction.h
  clang-tools-extra/trunk/clang-rename/USRFinder.h
  clang-tools-extra/trunk/clang-rename/USRFindingAction.cpp

Index: clang-tools-extra/trunk/clang-rename/RenamingAction.h
===
--- clang-tools-extra/trunk/clang-rename/RenamingAction.h
+++ clang-tools-extra/trunk/clang-rename/RenamingAction.h
@@ -41,7 +41,6 @@
   std::map &FileToReplaces;
   bool PrintLocations;
 };
-
 }
 }
 
Index: clang-tools-extra/trunk/clang-rename/USRFindingAction.cpp
===
--- clang-tools-extra/trunk/clang-rename/USRFindingAction.cpp
+++ clang-tools-extra/trunk/clang-rename/USRFindingAction.cpp
@@ -33,7 +33,6 @@
 #include 
 #include 
 
-
 using namespace llvm;
 
 namespace clang {
@@ -47,8 +46,8 @@
 class AdditionalUSRFinder : public RecursiveASTVisitor {
 public:
   explicit AdditionalUSRFinder(const Decl *FoundDecl, ASTContext &Context,
- std::vector *USRs)
-: FoundDecl(FoundDecl), Context(Context), USRs(USRs) {}
+   std::vector *USRs)
+  : FoundDecl(FoundDecl), Context(Context), USRs(USRs) {}
 
   void Find() {
 // Fill OverriddenMethods and PartialSpecs storages.
@@ -63,7 +62,7 @@
 } else if (const auto *RecordDecl = dyn_cast(FoundDecl)) {
   handleCXXRecordDecl(RecordDecl);
 } else if (const auto *TemplateDecl =
-   dyn_cast(FoundDecl)) {
+   dyn_cast(FoundDecl)) {
   handleClassTemplateDecl(TemplateDecl);
 } else {
   USRSet.insert(getUSRForDecl(FoundDecl));
@@ -87,8 +86,8 @@
 private:
   void handleCXXRecordDecl(const CXXRecordDecl *RecordDecl) {
 RecordDecl = RecordDecl->getDefinition();
-if (const auto *ClassTemplateSpecDecl
-= dyn_cast(RecordDecl)) {
+if (const auto *ClassTemplateSpecDecl =
+dyn_cast(RecordDecl)) {
   handleClassTemplateDecl(ClassTemplateSpecDecl->getSpecializedTemplate());
 }
 addUSRsOfCtorDtors(RecordDecl);
@@ -137,8 +136,8 @@
   ASTContext &Context;
   std::vector *USRs;
   std::set USRSet;
-  std::vector OverriddenMethods;
-  std::vector PartialSpecs;
+  std::vector OverriddenMethods;
+  std::vector PartialSpecs;
 };
 } // namespace
 
Index: clang-tools-extra/trunk/clang-rename/USRFinder.h
===
--- clang-tools-extra/trunk/clang-rename/USRFinder.h
+++ clang-tools-extra/trunk/clang-rename/USRFinder.h
@@ -49,7 +49,7 @@
 class NestedNameSpecifierLocFinder : public MatchFinder::MatchCallback {
 public:
   explicit NestedNameSpecifierLocFinder(ASTContext &Context)
-: Context(Context) {}
+  : Context(Context) {}
 
   std::vector getNestedNameSpecifierLocations() {
 addMatchers();
@@ -65,16 +65,15 @@
   }
 
   virtual void run(const MatchFinder::MatchResult &Result) {
-const auto *NNS =
-
Result.Nodes.getNodeAs("nestedNameSpecifierLoc");
+const auto *NNS = Result.Nodes.getNodeAs(
+"nestedNameSpecifierLoc");
 Locations.push_back(*NNS);
   }
 
   ASTContext &Context;
   std::vector Locations;
   MatchFinder Finder;
 };
-
 }
 }
 


Index: clang-tools-extra/trunk/clang-rename/RenamingAction.h
===
--- clang-tools-extra/trunk/clang-rename/RenamingAction.h
+++ clang-tools-extra/trunk/clang-rename/RenamingAction.h
@@ -41,7 +41,6 @@
   std::map &FileToReplaces;
   bool PrintLocations;
 };
-
 }
 }
 
Index: clang-tools-extra/trunk/clang-rename/USRFindingAction.cpp
===
--- clang-tools-extra/trunk/clang-rename/USRFindingAction.cpp
+++ clang-tools-extra/trunk/clang-rename/USRFindingAction.cpp
@@ -33,7 +33,6 @@
 #include 
 #include 
 
-
 using namespace llvm;
 
 namespace clang {
@@ -47,8 +46,8 @@
 class AdditionalUSRFinder : public RecursiveASTVisitor {
 public:
   explicit AdditionalUSRFinder(const Decl *FoundDecl, ASTContext &Context,
- std::vector *USRs)
-: FoundDecl(FoundDecl), Context(Context), USRs(USRs) {}
+   std::vector *USRs)
+  : FoundDecl(FoundDecl), Context(Context), USRs(USRs) {}
 
   void Find() {
 // Fill OverriddenMethods and PartialSpecs storages.
@@ -63,7 +62,7 @@
 } else if (const auto *RecordDecl = dyn_cast(FoundDecl)) {
   handleCXXRecordDecl(RecordDecl);
 } else if (const auto *TemplateDecl =
-   dyn_cast(FoundDecl)) {
+   dyn_cast(FoundDecl)) {
   handleClassTemplateDecl(TemplateDecl);
 } else {
   USRSet.insert

[clang-tools-extra] r277702 - Run clang-format on clang-rename code

2016-08-04 Thread Miklos Vajna via cfe-commits
Author: vmiklos
Date: Thu Aug  4 02:43:29 2016
New Revision: 277702

URL: http://llvm.org/viewvc/llvm-project?rev=277702&view=rev
Log:
Run clang-format on clang-rename code

So that later commits don't introduce non-functional changes when
running clang-format before committing.

Reviewers: klimek

Differential Revision: https://reviews.llvm.org/D23153

Modified:
clang-tools-extra/trunk/clang-rename/RenamingAction.h
clang-tools-extra/trunk/clang-rename/USRFinder.h
clang-tools-extra/trunk/clang-rename/USRFindingAction.cpp

Modified: clang-tools-extra/trunk/clang-rename/RenamingAction.h
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-rename/RenamingAction.h?rev=277702&r1=277701&r2=277702&view=diff
==
--- clang-tools-extra/trunk/clang-rename/RenamingAction.h (original)
+++ clang-tools-extra/trunk/clang-rename/RenamingAction.h Thu Aug  4 02:43:29 
2016
@@ -41,7 +41,6 @@ private:
   std::map &FileToReplaces;
   bool PrintLocations;
 };
-
 }
 }
 

Modified: clang-tools-extra/trunk/clang-rename/USRFinder.h
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-rename/USRFinder.h?rev=277702&r1=277701&r2=277702&view=diff
==
--- clang-tools-extra/trunk/clang-rename/USRFinder.h (original)
+++ clang-tools-extra/trunk/clang-rename/USRFinder.h Thu Aug  4 02:43:29 2016
@@ -49,7 +49,7 @@ std::string getUSRForDecl(const Decl *De
 class NestedNameSpecifierLocFinder : public MatchFinder::MatchCallback {
 public:
   explicit NestedNameSpecifierLocFinder(ASTContext &Context)
-: Context(Context) {}
+  : Context(Context) {}
 
   std::vector getNestedNameSpecifierLocations() {
 addMatchers();
@@ -65,8 +65,8 @@ private:
   }
 
   virtual void run(const MatchFinder::MatchResult &Result) {
-const auto *NNS =
-
Result.Nodes.getNodeAs("nestedNameSpecifierLoc");
+const auto *NNS = Result.Nodes.getNodeAs(
+"nestedNameSpecifierLoc");
 Locations.push_back(*NNS);
   }
 
@@ -74,7 +74,6 @@ private:
   std::vector Locations;
   MatchFinder Finder;
 };
-
 }
 }
 

Modified: clang-tools-extra/trunk/clang-rename/USRFindingAction.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-rename/USRFindingAction.cpp?rev=277702&r1=277701&r2=277702&view=diff
==
--- clang-tools-extra/trunk/clang-rename/USRFindingAction.cpp (original)
+++ clang-tools-extra/trunk/clang-rename/USRFindingAction.cpp Thu Aug  4 
02:43:29 2016
@@ -33,7 +33,6 @@
 #include 
 #include 
 
-
 using namespace llvm;
 
 namespace clang {
@@ -47,8 +46,8 @@ namespace {
 class AdditionalUSRFinder : public RecursiveASTVisitor {
 public:
   explicit AdditionalUSRFinder(const Decl *FoundDecl, ASTContext &Context,
- std::vector *USRs)
-: FoundDecl(FoundDecl), Context(Context), USRs(USRs) {}
+   std::vector *USRs)
+  : FoundDecl(FoundDecl), Context(Context), USRs(USRs) {}
 
   void Find() {
 // Fill OverriddenMethods and PartialSpecs storages.
@@ -63,7 +62,7 @@ public:
 } else if (const auto *RecordDecl = dyn_cast(FoundDecl)) {
   handleCXXRecordDecl(RecordDecl);
 } else if (const auto *TemplateDecl =
-   dyn_cast(FoundDecl)) {
+   dyn_cast(FoundDecl)) {
   handleClassTemplateDecl(TemplateDecl);
 } else {
   USRSet.insert(getUSRForDecl(FoundDecl));
@@ -87,8 +86,8 @@ public:
 private:
   void handleCXXRecordDecl(const CXXRecordDecl *RecordDecl) {
 RecordDecl = RecordDecl->getDefinition();
-if (const auto *ClassTemplateSpecDecl
-= dyn_cast(RecordDecl)) {
+if (const auto *ClassTemplateSpecDecl =
+dyn_cast(RecordDecl)) {
   handleClassTemplateDecl(ClassTemplateSpecDecl->getSpecializedTemplate());
 }
 addUSRsOfCtorDtors(RecordDecl);
@@ -137,8 +136,8 @@ private:
   ASTContext &Context;
   std::vector *USRs;
   std::set USRSet;
-  std::vector OverriddenMethods;
-  std::vector PartialSpecs;
+  std::vector OverriddenMethods;
+  std::vector PartialSpecs;
 };
 } // namespace
 


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D23153: Run clang-format on clang-rename code

2016-08-04 Thread Miklos Vajna via cfe-commits
vmiklos created this revision.
vmiklos added reviewers: klimek, omtcyfz.
vmiklos added a subscriber: cfe-commits.

So that later commits don't introduce non-functional changes when
running clang-format before committing.

https://reviews.llvm.org/D23153

Files:
  clang-rename/RenamingAction.h
  clang-rename/USRFinder.h
  clang-rename/USRFindingAction.cpp

Index: clang-rename/USRFindingAction.cpp
===
--- clang-rename/USRFindingAction.cpp
+++ clang-rename/USRFindingAction.cpp
@@ -33,7 +33,6 @@
 #include 
 #include 
 
-
 using namespace llvm;
 
 namespace clang {
@@ -47,8 +46,8 @@
 class AdditionalUSRFinder : public RecursiveASTVisitor {
 public:
   explicit AdditionalUSRFinder(const Decl *FoundDecl, ASTContext &Context,
- std::vector *USRs)
-: FoundDecl(FoundDecl), Context(Context), USRs(USRs) {}
+   std::vector *USRs)
+  : FoundDecl(FoundDecl), Context(Context), USRs(USRs) {}
 
   void Find() {
 // Fill OverriddenMethods and PartialSpecs storages.
@@ -63,7 +62,7 @@
 } else if (const auto *RecordDecl = dyn_cast(FoundDecl)) {
   handleCXXRecordDecl(RecordDecl);
 } else if (const auto *TemplateDecl =
-   dyn_cast(FoundDecl)) {
+   dyn_cast(FoundDecl)) {
   handleClassTemplateDecl(TemplateDecl);
 } else {
   USRSet.insert(getUSRForDecl(FoundDecl));
@@ -87,8 +86,8 @@
 private:
   void handleCXXRecordDecl(const CXXRecordDecl *RecordDecl) {
 RecordDecl = RecordDecl->getDefinition();
-if (const auto *ClassTemplateSpecDecl
-= dyn_cast(RecordDecl)) {
+if (const auto *ClassTemplateSpecDecl =
+dyn_cast(RecordDecl)) {
   handleClassTemplateDecl(ClassTemplateSpecDecl->getSpecializedTemplate());
 }
 addUSRsOfCtorDtors(RecordDecl);
@@ -137,8 +136,8 @@
   ASTContext &Context;
   std::vector *USRs;
   std::set USRSet;
-  std::vector OverriddenMethods;
-  std::vector PartialSpecs;
+  std::vector OverriddenMethods;
+  std::vector PartialSpecs;
 };
 } // namespace
 
Index: clang-rename/USRFinder.h
===
--- clang-rename/USRFinder.h
+++ clang-rename/USRFinder.h
@@ -49,7 +49,7 @@
 class NestedNameSpecifierLocFinder : public MatchFinder::MatchCallback {
 public:
   explicit NestedNameSpecifierLocFinder(ASTContext &Context)
-: Context(Context) {}
+  : Context(Context) {}
 
   std::vector getNestedNameSpecifierLocations() {
 addMatchers();
@@ -65,16 +65,15 @@
   }
 
   virtual void run(const MatchFinder::MatchResult &Result) {
-const auto *NNS =
-
Result.Nodes.getNodeAs("nestedNameSpecifierLoc");
+const auto *NNS = Result.Nodes.getNodeAs(
+"nestedNameSpecifierLoc");
 Locations.push_back(*NNS);
   }
 
   ASTContext &Context;
   std::vector Locations;
   MatchFinder Finder;
 };
-
 }
 }
 
Index: clang-rename/RenamingAction.h
===
--- clang-rename/RenamingAction.h
+++ clang-rename/RenamingAction.h
@@ -41,7 +41,6 @@
   std::map &FileToReplaces;
   bool PrintLocations;
 };
-
 }
 }
 


Index: clang-rename/USRFindingAction.cpp
===
--- clang-rename/USRFindingAction.cpp
+++ clang-rename/USRFindingAction.cpp
@@ -33,7 +33,6 @@
 #include 
 #include 
 
-
 using namespace llvm;
 
 namespace clang {
@@ -47,8 +46,8 @@
 class AdditionalUSRFinder : public RecursiveASTVisitor {
 public:
   explicit AdditionalUSRFinder(const Decl *FoundDecl, ASTContext &Context,
- std::vector *USRs)
-: FoundDecl(FoundDecl), Context(Context), USRs(USRs) {}
+   std::vector *USRs)
+  : FoundDecl(FoundDecl), Context(Context), USRs(USRs) {}
 
   void Find() {
 // Fill OverriddenMethods and PartialSpecs storages.
@@ -63,7 +62,7 @@
 } else if (const auto *RecordDecl = dyn_cast(FoundDecl)) {
   handleCXXRecordDecl(RecordDecl);
 } else if (const auto *TemplateDecl =
-   dyn_cast(FoundDecl)) {
+   dyn_cast(FoundDecl)) {
   handleClassTemplateDecl(TemplateDecl);
 } else {
   USRSet.insert(getUSRForDecl(FoundDecl));
@@ -87,8 +86,8 @@
 private:
   void handleCXXRecordDecl(const CXXRecordDecl *RecordDecl) {
 RecordDecl = RecordDecl->getDefinition();
-if (const auto *ClassTemplateSpecDecl
-= dyn_cast(RecordDecl)) {
+if (const auto *ClassTemplateSpecDecl =
+dyn_cast(RecordDecl)) {
   handleClassTemplateDecl(ClassTemplateSpecDecl->getSpecializedTemplate());
 }
 addUSRsOfCtorDtors(RecordDecl);
@@ -137,8 +136,8 @@
   ASTContext &Context;
   std::vector *USRs;
   std::set USRSet;
-  std::vector OverriddenMethods;
-  std::vector PartialSpecs;
+  std::vector OverriddenMethods;
+  std::vector PartialSpecs;
 };
 } // namespace
 
Index: clang-rename/USRFinder.h

Re: [PATCH] D21814: clang-rename: split existing options into two new subcommands

2016-08-02 Thread Miklos Vajna via cfe-commits
vmiklos added a comment.

Yes, I did that -- but I got no conflicts there. ;-)


Repository:
  rL LLVM

https://reviews.llvm.org/D21814



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] r277438 - clang-rename: split existing options into two new subcommands

2016-08-02 Thread Miklos Vajna via cfe-commits
Author: vmiklos
Date: Tue Aug  2 04:51:31 2016
New Revision: 277438

URL: http://llvm.org/viewvc/llvm-project?rev=277438&view=rev
Log:
clang-rename: split existing options into two new subcommands

- rename-at is meant to be integrated with editors and works mainly off
  of a location in a file, and this is the default
- rename-all is optimized for one or more oldname->newname renames, and
  works with clang-apply-replacements

Reviewers: bkramer, klimek

Subscribers: omtcyfz

Differential Revision: https://reviews.llvm.org/D21814

Added:
clang-tools-extra/trunk/test/clang-rename/ClassTestMulti.cpp
clang-tools-extra/trunk/test/clang-rename/ClassTestMultiByName.cpp
Modified:
clang-tools-extra/trunk/clang-rename/RenamingAction.cpp
clang-tools-extra/trunk/clang-rename/RenamingAction.h
clang-tools-extra/trunk/clang-rename/tool/ClangRename.cpp
clang-tools-extra/trunk/docs/clang-rename.rst
clang-tools-extra/trunk/test/clang-rename/ClassFindByName.cpp
clang-tools-extra/trunk/test/clang-rename/FunctionWithClassFindByName.cpp
clang-tools-extra/trunk/test/clang-rename/NoNewName.cpp

Modified: clang-tools-extra/trunk/clang-rename/RenamingAction.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-rename/RenamingAction.cpp?rev=277438&r1=277437&r2=277438&view=diff
==
--- clang-tools-extra/trunk/clang-rename/RenamingAction.cpp (original)
+++ clang-tools-extra/trunk/clang-rename/RenamingAction.cpp Tue Aug  2 04:51:31 
2016
@@ -35,14 +35,23 @@ namespace rename {
 class RenamingASTConsumer : public ASTConsumer {
 public:
   RenamingASTConsumer(
-  const std::string &NewName, const std::string &PrevName,
-  const std::vector &USRs,
+  const std::vector &NewNames,
+  const std::vector &PrevNames,
+  const std::vector> &USRList,
   std::map &FileToReplaces,
   bool PrintLocations)
-  : NewName(NewName), PrevName(PrevName), USRs(USRs),
+  : NewNames(NewNames), PrevNames(PrevNames), USRList(USRList),
 FileToReplaces(FileToReplaces), PrintLocations(PrintLocations) {}
 
   void HandleTranslationUnit(ASTContext &Context) override {
+for (unsigned I = 0; I < NewNames.size(); ++I) {
+  HandleOneRename(Context, NewNames[I], PrevNames[I], USRList[I]);
+}
+  }
+
+  void HandleOneRename(ASTContext &Context, const std::string &NewName,
+   const std::string &PrevName,
+   const std::vector &USRs) {
 const auto &SourceMgr = Context.getSourceManager();
 std::vector RenamingCandidates;
 std::vector NewCandidates;
@@ -70,14 +79,14 @@ public:
   }
 
 private:
-  const std::string &NewName, &PrevName;
-  const std::vector &USRs;
+  const std::vector &NewNames, &PrevNames;
+  const std::vector> &USRList;
   std::map &FileToReplaces;
   bool PrintLocations;
 };
 
 std::unique_ptr RenamingAction::newASTConsumer() {
-  return llvm::make_unique(NewName, PrevName, USRs,
+  return llvm::make_unique(NewNames, PrevNames, USRList,
 FileToReplaces, 
PrintLocations);
 }
 

Modified: clang-tools-extra/trunk/clang-rename/RenamingAction.h
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-rename/RenamingAction.h?rev=277438&r1=277437&r2=277438&view=diff
==
--- clang-tools-extra/trunk/clang-rename/RenamingAction.h (original)
+++ clang-tools-extra/trunk/clang-rename/RenamingAction.h Tue Aug  2 04:51:31 
2016
@@ -25,18 +25,19 @@ namespace rename {
 
 class RenamingAction {
 public:
-  RenamingAction(const std::string &NewName, const std::string &PrevName,
- const std::vector &USRs,
+  RenamingAction(const std::vector &NewNames,
+ const std::vector &PrevNames,
+ const std::vector> &USRList,
  std::map &FileToReplaces,
  bool PrintLocations = false)
-  : NewName(NewName), PrevName(PrevName), USRs(USRs),
+  : NewNames(NewNames), PrevNames(PrevNames), USRList(USRList),
 FileToReplaces(FileToReplaces), PrintLocations(PrintLocations) {}
 
   std::unique_ptr newASTConsumer();
 
 private:
-  const std::string &NewName, &PrevName;
-  const std::vector &USRs;
+  const std::vector &NewNames, &PrevNames;
+  const std::vector> &USRList;
   std::map &FileToReplaces;
   bool PrintLocations;
 };

Modified: clang-tools-extra/trunk/clang-rename/tool/ClangRename.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-rename/tool/ClangRename.cpp?rev=277438&r1=277437&r2=277438&view=diff
==
--- clang-tools-extra/trunk/clang-rename/tool/ClangRename.cpp (original)
+++ clang-tools-extra/trunk/clang-rename/tool/ClangRename.cpp Tue Aug  2 
04:51:31 2016
@@ -39,94 +39,146 @@
 
 using namespace llvm;
 
-cl::OptionCategory

Re: [PATCH] D21814: clang-rename: split existing options into two new subcommands

2016-08-02 Thread Miklos Vajna via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL277438: clang-rename: split existing options into two new 
subcommands (authored by vmiklos).

Changed prior to commit:
  https://reviews.llvm.org/D21814?vs=66362&id=66448#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D21814

Files:
  clang-tools-extra/trunk/clang-rename/RenamingAction.cpp
  clang-tools-extra/trunk/clang-rename/RenamingAction.h
  clang-tools-extra/trunk/clang-rename/tool/ClangRename.cpp
  clang-tools-extra/trunk/docs/clang-rename.rst
  clang-tools-extra/trunk/test/clang-rename/ClassFindByName.cpp
  clang-tools-extra/trunk/test/clang-rename/ClassTestMulti.cpp
  clang-tools-extra/trunk/test/clang-rename/ClassTestMultiByName.cpp
  clang-tools-extra/trunk/test/clang-rename/FunctionWithClassFindByName.cpp
  clang-tools-extra/trunk/test/clang-rename/NoNewName.cpp

Index: clang-tools-extra/trunk/test/clang-rename/NoNewName.cpp
===
--- clang-tools-extra/trunk/test/clang-rename/NoNewName.cpp
+++ clang-tools-extra/trunk/test/clang-rename/NoNewName.cpp
@@ -1,4 +1,4 @@
 // Check for an error while -new-name argument has not been passed to
 // clang-rename.
 // RUN: not clang-rename -offset=133 %s 2>&1 | FileCheck %s
-// CHECK: ERROR: no new name provided.
+// CHECK: clang-rename: for the -new-name option: must be specified
Index: clang-tools-extra/trunk/test/clang-rename/ClassTestMultiByName.cpp
===
--- clang-tools-extra/trunk/test/clang-rename/ClassTestMultiByName.cpp
+++ clang-tools-extra/trunk/test/clang-rename/ClassTestMultiByName.cpp
@@ -0,0 +1,8 @@
+// RUN: cat %s > %t.cpp
+// RUN: clang-rename rename-all -old-name=Foo1 -new-name=Bar1 -old-name=Foo2 -new-name=Bar2 %t.cpp -i --
+// RUN: sed 's,//.*,,' %t.cpp | FileCheck %s
+class Foo1 { // CHECK: class Bar1
+};
+
+class Foo2 { // CHECK: class Bar2
+};
Index: clang-tools-extra/trunk/test/clang-rename/ClassFindByName.cpp
===
--- clang-tools-extra/trunk/test/clang-rename/ClassFindByName.cpp
+++ clang-tools-extra/trunk/test/clang-rename/ClassFindByName.cpp
@@ -1,5 +1,5 @@
 // RUN: cat %s > %t.cpp
-// RUN: clang-rename -old-name=Foo -new-name=Bar %t.cpp -i --
+// RUN: clang-rename rename-all -old-name=Foo -new-name=Bar %t.cpp -i --
 // RUN: sed 's,//.*,,' %t.cpp | FileCheck %s
 
 class Foo { // CHECK: class Bar
Index: clang-tools-extra/trunk/test/clang-rename/ClassTestMulti.cpp
===
--- clang-tools-extra/trunk/test/clang-rename/ClassTestMulti.cpp
+++ clang-tools-extra/trunk/test/clang-rename/ClassTestMulti.cpp
@@ -0,0 +1,8 @@
+// RUN: cat %s > %t.cpp
+// RUN: clang-rename rename-all -offset=174 -new-name=Bar1 -offset=212 -new-name=Bar2 %t.cpp -i --
+// RUN: sed 's,//.*,,' %t.cpp | FileCheck %s
+class Foo1 { // CHECK: class Bar1
+};
+
+class Foo2 { // CHECK: class Bar2
+};
Index: clang-tools-extra/trunk/test/clang-rename/FunctionWithClassFindByName.cpp
===
--- clang-tools-extra/trunk/test/clang-rename/FunctionWithClassFindByName.cpp
+++ clang-tools-extra/trunk/test/clang-rename/FunctionWithClassFindByName.cpp
@@ -1,5 +1,5 @@
 // RUN: cat %s > %t.cpp
-// RUN: clang-rename -old-name=Foo -new-name=Bar %t.cpp -i --
+// RUN: clang-rename rename-all -old-name=Foo -new-name=Bar %t.cpp -i --
 // RUN: sed 's,//.*,,' %t.cpp | FileCheck %s
 
 void foo() {
Index: clang-tools-extra/trunk/clang-rename/RenamingAction.cpp
===
--- clang-tools-extra/trunk/clang-rename/RenamingAction.cpp
+++ clang-tools-extra/trunk/clang-rename/RenamingAction.cpp
@@ -35,14 +35,23 @@
 class RenamingASTConsumer : public ASTConsumer {
 public:
   RenamingASTConsumer(
-  const std::string &NewName, const std::string &PrevName,
-  const std::vector &USRs,
+  const std::vector &NewNames,
+  const std::vector &PrevNames,
+  const std::vector> &USRList,
   std::map &FileToReplaces,
   bool PrintLocations)
-  : NewName(NewName), PrevName(PrevName), USRs(USRs),
+  : NewNames(NewNames), PrevNames(PrevNames), USRList(USRList),
 FileToReplaces(FileToReplaces), PrintLocations(PrintLocations) {}
 
   void HandleTranslationUnit(ASTContext &Context) override {
+for (unsigned I = 0; I < NewNames.size(); ++I) {
+  HandleOneRename(Context, NewNames[I], PrevNames[I], USRList[I]);
+}
+  }
+
+  void HandleOneRename(ASTContext &Context, const std::string &NewName,
+   const std::string &PrevName,
+   const std::vector &USRs) {
 const auto &SourceMgr = Context.getSourceManager();
 std::vector RenamingCandidates;
 std::vector NewCandidates;
@@ -70,14 +79,14 @@
   }
 
 private:
-  const std::string &NewName, &PrevName;
-  cons

Re: [PATCH] D21814: clang-rename: split existing options into two new subcommands

2016-08-01 Thread Miklos Vajna via cfe-commits
vmiklos added a comment.

Rebased on top of r277356 and resolved conflicts. (A busy day, it seems. :-) )


https://reviews.llvm.org/D21814



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D21814: clang-rename: split existing options into two new subcommands

2016-08-01 Thread Miklos Vajna via cfe-commits
vmiklos updated this revision to Diff 66362.

https://reviews.llvm.org/D21814

Files:
  clang-rename/RenamingAction.cpp
  clang-rename/RenamingAction.h
  clang-rename/tool/ClangRename.cpp
  docs/clang-rename.rst
  test/clang-rename/ClassFindByName.cpp
  test/clang-rename/ClassTestMulti.cpp
  test/clang-rename/ClassTestMultiByName.cpp
  test/clang-rename/FunctionWithClassFindByName.cpp
  test/clang-rename/NoNewName.cpp

Index: test/clang-rename/NoNewName.cpp
===
--- test/clang-rename/NoNewName.cpp
+++ test/clang-rename/NoNewName.cpp
@@ -1,4 +1,4 @@
 // Check for an error while -new-name argument has not been passed to
 // clang-rename.
 // RUN: not clang-rename -offset=133 %s 2>&1 | FileCheck %s
-// CHECK: ERROR: no new name provided.
+// CHECK: clang-rename: for the -new-name option: must be specified
Index: test/clang-rename/FunctionWithClassFindByName.cpp
===
--- test/clang-rename/FunctionWithClassFindByName.cpp
+++ test/clang-rename/FunctionWithClassFindByName.cpp
@@ -1,5 +1,5 @@
 // RUN: cat %s > %t.cpp
-// RUN: clang-rename -old-name=Foo -new-name=Bar %t.cpp -i --
+// RUN: clang-rename rename-all -old-name=Foo -new-name=Bar %t.cpp -i --
 // RUN: sed 's,//.*,,' %t.cpp | FileCheck %s
 
 void foo() {
Index: test/clang-rename/ClassTestMultiByName.cpp
===
--- /dev/null
+++ test/clang-rename/ClassTestMultiByName.cpp
@@ -0,0 +1,8 @@
+// RUN: cat %s > %t.cpp
+// RUN: clang-rename rename-all -old-name=Foo1 -new-name=Bar1 -old-name=Foo2 -new-name=Bar2 %t.cpp -i --
+// RUN: sed 's,//.*,,' %t.cpp | FileCheck %s
+class Foo1 { // CHECK: class Bar1
+};
+
+class Foo2 { // CHECK: class Bar2
+};
Index: test/clang-rename/ClassTestMulti.cpp
===
--- /dev/null
+++ test/clang-rename/ClassTestMulti.cpp
@@ -0,0 +1,8 @@
+// RUN: cat %s > %t.cpp
+// RUN: clang-rename rename-all -offset=174 -new-name=Bar1 -offset=212 -new-name=Bar2 %t.cpp -i --
+// RUN: sed 's,//.*,,' %t.cpp | FileCheck %s
+class Foo1 { // CHECK: class Bar1
+};
+
+class Foo2 { // CHECK: class Bar2
+};
Index: test/clang-rename/ClassFindByName.cpp
===
--- test/clang-rename/ClassFindByName.cpp
+++ test/clang-rename/ClassFindByName.cpp
@@ -1,5 +1,5 @@
 // RUN: cat %s > %t.cpp
-// RUN: clang-rename -old-name=Foo -new-name=Bar %t.cpp -i --
+// RUN: clang-rename rename-all -old-name=Foo -new-name=Bar %t.cpp -i --
 // RUN: sed 's,//.*,,' %t.cpp | FileCheck %s
 
 class Foo { // CHECK: class Bar
Index: docs/clang-rename.rst
===
--- docs/clang-rename.rst
+++ docs/clang-rename.rst
@@ -42,6 +42,14 @@
   $ grep -FUbo 'foo' file.cpp
 
 
+You can also identify one or more symbols to be renamed by giving the fully qualified
+name:
+
+.. code-block:: console
+
+  $ clang-rename rename-all -old-name=foo -new-name=bar test.cpp
+
+
 The tool currently supports renaming actions inside a single Translation Unit
 only. It is planned to extend the tool's functionality to support multi-TU
 renaming actions in the future.
@@ -55,34 +63,73 @@
 .. code-block:: console
 
   $ clang-rename -help
+  Usage: clang-rename {rename-at|rename-all} [OPTION]...
+
+  A tool to rename symbols in C/C++ code.
+
+  Subcommands:
+rename-at:  Perform rename off of a location in a file. (This is the default.)
+rename-all: Perform rename of all symbols matching one or more fully qualified names.
+
+
+.. code-block:: console
+
+  $ clang-rename rename-at -help
   OVERVIEW: A tool to rename symbols in C/C++ code.
   clang-rename renames every occurrence of a symbol found at  in
   . If -i is specified, the edited files are overwritten to disk.
   Otherwise, the results are written to stdout.
-
-  USAGE: clang-rename [subcommand] [options]  [... ]
-
+  
+  USAGE: clang-rename rename-at [subcommand] [options]  [... ]
+  
   OPTIONS:
+  
+  Generic Options:
+  
+-help  - Display available options (-help-hidden for more)
+-help-list - Display list of available options (-help-list-hidden for more)
+-version   - Display the version of this program
 
-  Clang-rename options:
+  clang-rename rename-at options:
 
 -export-fixes=   - YAML file to store suggested fixes in.
 -extra-arg=- Additional argument to append to the compiler command line
 -extra-arg-before= - Additional argument to prepend to the compiler command line
 -i - Overwrite edited s.
 -new-name= - The new name to change the symbol to.
 -offset= - Locates the symbol by offset as opposed to :.
--old-name= - The fully qualified name of the symbol, if -offset is not used.
 -p=- Build path
 -pl  

Re: [PATCH] D21814: clang-rename: split existing options into two new subcommands

2016-08-01 Thread Miklos Vajna via cfe-commits
vmiklos added a comment.

Rebased on top of r277339 and resolved conflicts.


https://reviews.llvm.org/D21814



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D21814: clang-rename: split existing options into two new subcommands

2016-08-01 Thread Miklos Vajna via cfe-commits
vmiklos updated this revision to Diff 66304.

https://reviews.llvm.org/D21814

Files:
  clang-rename/RenamingAction.cpp
  clang-rename/RenamingAction.h
  clang-rename/tool/ClangRename.cpp
  docs/clang-rename.rst
  test/clang-rename/ClassFindByName.cpp
  test/clang-rename/ClassTestMulti.cpp
  test/clang-rename/ClassTestMultiByName.cpp
  test/clang-rename/FunctionWithClassFindByName.cpp
  test/clang-rename/NoNewName.cpp

Index: test/clang-rename/NoNewName.cpp
===
--- test/clang-rename/NoNewName.cpp
+++ test/clang-rename/NoNewName.cpp
@@ -1,4 +1,4 @@
 // Check for an error while -new-name argument has not been passed to
 // clang-rename.
 // RUN: not clang-rename -offset=133 %s 2>&1 | FileCheck %s
-// CHECK: ERROR: no new name provided.
+// CHECK: clang-rename: for the -new-name option: must be specified
Index: test/clang-rename/FunctionWithClassFindByName.cpp
===
--- test/clang-rename/FunctionWithClassFindByName.cpp
+++ test/clang-rename/FunctionWithClassFindByName.cpp
@@ -1,4 +1,4 @@
-// RUN: clang-rename -old-name=Foo -new-name=Bar %s -- | FileCheck %s
+// RUN: clang-rename rename-all -old-name=Foo -new-name=Bar %s -- | FileCheck %s
 
 void foo() {
 }
Index: test/clang-rename/ClassTestMultiByName.cpp
===
--- /dev/null
+++ test/clang-rename/ClassTestMultiByName.cpp
@@ -0,0 +1,6 @@
+// RUN: clang-rename rename-all -old-name=Foo1 -new-name=Bar1 -old-name=Foo2 -new-name=Bar2 %s -- | FileCheck %s
+class Foo1 { // CHECK: class Bar1
+};
+
+class Foo2 { // CHECK: class Bar2
+};
Index: test/clang-rename/ClassTestMulti.cpp
===
--- /dev/null
+++ test/clang-rename/ClassTestMulti.cpp
@@ -0,0 +1,6 @@
+// RUN: clang-rename rename-all -offset=113 -new-name=Bar1 -offset=151 -new-name=Bar2 %s -- | FileCheck %s
+class Foo1 { // CHECK: class Bar1
+};
+
+class Foo2 { // CHECK: class Bar2
+};
Index: test/clang-rename/ClassFindByName.cpp
===
--- test/clang-rename/ClassFindByName.cpp
+++ test/clang-rename/ClassFindByName.cpp
@@ -1,4 +1,4 @@
-// RUN: clang-rename -old-name=Foo -new-name=Bar %s -- | FileCheck %s
+// RUN: clang-rename rename-all -old-name=Foo -new-name=Bar %s -- | FileCheck %s
 
 class Foo { // CHECK: class Bar
 };
Index: docs/clang-rename.rst
===
--- docs/clang-rename.rst
+++ docs/clang-rename.rst
@@ -42,6 +42,14 @@
   $ grep -FUbo 'foo' file.cpp
 
 
+You can also identify one or more symbols to be renamed by giving the fully qualified
+name:
+
+.. code-block:: console
+
+  $ clang-rename rename-all -old-name=foo -new-name=bar test.cpp
+
+
 The tool currently supports renaming actions inside a single Translation Unit
 only. It is planned to extend the tool's functionality to support multi-TU
 renaming actions in the future.
@@ -55,34 +63,73 @@
 .. code-block:: console
 
   $ clang-rename -help
+  Usage: clang-rename {rename-at|rename-all} [OPTION]...
+
+  A tool to rename symbols in C/C++ code.
+
+  Subcommands:
+rename-at:  Perform rename off of a location in a file. (This is the default.)
+rename-all: Perform rename of all symbols matching one or more fully qualified names.
+
+
+.. code-block:: console
+
+  $ clang-rename rename-at -help
   OVERVIEW: A tool to rename symbols in C/C++ code.
   clang-rename renames every occurrence of a symbol found at  in
   . If -i is specified, the edited files are overwritten to disk.
   Otherwise, the results are written to stdout.
-
-  USAGE: clang-rename [subcommand] [options]  [... ]
-
+  
+  USAGE: clang-rename rename-at [subcommand] [options]  [... ]
+  
   OPTIONS:
+  
+  Generic Options:
+  
+-help  - Display available options (-help-hidden for more)
+-help-list - Display list of available options (-help-list-hidden for more)
+-version   - Display the version of this program
 
-  Clang-rename options:
+  clang-rename rename-at options:
 
 -export-fixes=   - YAML file to store suggested fixes in.
 -extra-arg=- Additional argument to append to the compiler command line
 -extra-arg-before= - Additional argument to prepend to the compiler command line
 -i - Overwrite edited s.
 -new-name= - The new name to change the symbol to.
 -offset= - Locates the symbol by offset as opposed to :.
--old-name= - The fully qualified name of the symbol, if -offset is not used.
 -p=- Build path
 -pl- Print the locations affected by renaming to stderr.
 -pn- Print the found symbol's name prior to renaming to stderr.
 
+
+.. code-block:: console
+
+  $ ~/git/llvm/workdir/bin/c

Re: [PATCH] D21814: clang-rename: split existing options into two new subcommands

2016-07-29 Thread Miklos Vajna via cfe-commits
vmiklos added a comment.

Great! Manuel, OK to land?


https://reviews.llvm.org/D21814



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D21814: clang-rename: split existing options into two new subcommands

2016-07-29 Thread Miklos Vajna via cfe-commits
vmiklos added a comment.

Yes, exactly, so not easy to customize I guess.


https://reviews.llvm.org/D21814



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D21814: clang-rename: split existing options into two new subcommands

2016-07-29 Thread Miklos Vajna via cfe-commits
vmiklos added a comment.

In https://reviews.llvm.org/D21814#500621, @omtcyfz wrote:

> P.S. not sure whether we have to write `clang-rename: for the -new-name 
> option: must be specified` out. We already launched `clang-rename` what else 
> could've give us an error?


You mean how is that error produced? Previously there was no `cl::Required` on 
NewName (now: NewNames), and that's why a manual check was needed, the error 
message changed, as now the option parser does this checking for us.


https://reviews.llvm.org/D21814



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D21814: clang-rename: split existing options into two new subcommands

2016-07-29 Thread Miklos Vajna via cfe-commits
vmiklos added a comment.

> Just write a FIXME then, I think I may look into that on the next week or 
> somewhen.


Done.

> Most of the time I use Foo->Bar renaming in tests


Done, I've renamed ClaN->KlaN to FooN->BarN.


https://reviews.llvm.org/D21814



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D21814: clang-rename: split existing options into two new subcommands

2016-07-29 Thread Miklos Vajna via cfe-commits
vmiklos updated this revision to Diff 66110.

https://reviews.llvm.org/D21814

Files:
  clang-rename/RenamingAction.cpp
  clang-rename/RenamingAction.h
  clang-rename/tool/ClangRename.cpp
  docs/clang-rename.rst
  test/clang-rename/ClassFindByName.cpp
  test/clang-rename/ClassTestMulti.cpp
  test/clang-rename/ClassTestMultiByName.cpp
  test/clang-rename/FunctionWithClassFindByName.cpp
  test/clang-rename/NoNewName.cpp

Index: test/clang-rename/NoNewName.cpp
===
--- test/clang-rename/NoNewName.cpp
+++ test/clang-rename/NoNewName.cpp
@@ -1,4 +1,4 @@
 // Check for an error while -new-name argument has not been passed to
 // clang-rename.
 // RUN: not clang-rename -offset=133 %s 2>&1 | FileCheck %s
-// CHECK: ERROR: no new name provided.
+// CHECK: clang-rename: for the -new-name option: must be specified
Index: test/clang-rename/FunctionWithClassFindByName.cpp
===
--- test/clang-rename/FunctionWithClassFindByName.cpp
+++ test/clang-rename/FunctionWithClassFindByName.cpp
@@ -1,4 +1,4 @@
-// RUN: clang-rename -old-name=Foo -new-name=Bar %s -- | FileCheck %s
+// RUN: clang-rename rename-all -old-name=Foo -new-name=Bar %s -- | FileCheck %s
 
 void foo() {
 }
Index: test/clang-rename/ClassTestMultiByName.cpp
===
--- /dev/null
+++ test/clang-rename/ClassTestMultiByName.cpp
@@ -0,0 +1,6 @@
+// RUN: clang-rename rename-all -old-name=Foo1 -new-name=Bar1 -old-name=Foo2 -new-name=Bar2 %s -- | FileCheck %s
+class Foo1 { // CHECK: class Bar1
+};
+
+class Foo2 { // CHECK: class Bar2
+};
Index: test/clang-rename/ClassTestMulti.cpp
===
--- /dev/null
+++ test/clang-rename/ClassTestMulti.cpp
@@ -0,0 +1,6 @@
+// RUN: clang-rename rename-all -offset=113 -new-name=Bar1 -offset=151 -new-name=Bar2 %s -- | FileCheck %s
+class Foo1 { // CHECK: class Bar1
+};
+
+class Foo2 { // CHECK: class Bar2
+};
Index: test/clang-rename/ClassFindByName.cpp
===
--- test/clang-rename/ClassFindByName.cpp
+++ test/clang-rename/ClassFindByName.cpp
@@ -1,4 +1,4 @@
-// RUN: clang-rename -old-name=Foo -new-name=Bar %s -- | FileCheck %s
+// RUN: clang-rename rename-all -old-name=Foo -new-name=Bar %s -- | FileCheck %s
 
 class Foo { // CHECK: class Bar
 };
Index: docs/clang-rename.rst
===
--- docs/clang-rename.rst
+++ docs/clang-rename.rst
@@ -42,6 +42,14 @@
   $ grep -FUbo 'foo' file.cpp
 
 
+You can also identify one or more symbols to be renamed by giving the fully qualified
+name:
+
+.. code-block:: console
+
+  $ clang-rename rename-all -old-name=foo -new-name=bar test.cpp
+
+
 The tool currently supports renaming actions inside a single Translation Unit
 only. It is planned to extend the tool's functionality to support multi-TU
 renaming actions in the future.
@@ -55,34 +63,73 @@
 .. code-block:: console
 
   $ clang-rename -help
+  Usage: clang-rename {rename-at|rename-all} [OPTION]...
+
+  A tool to rename symbols in C/C++ code.
+
+  Subcommands:
+rename-at:  Perform rename off of a location in a file. (This is the default.)
+rename-all: Perform rename of all symbols matching one or more fully qualified names.
+
+
+.. code-block:: console
+
+  $ clang-rename rename-at -help
   OVERVIEW: A tool to rename symbols in C/C++ code.
   clang-rename renames every occurrence of a symbol found at  in
   . If -i is specified, the edited files are overwritten to disk.
   Otherwise, the results are written to stdout.
-
-  USAGE: clang-rename [subcommand] [options]  [... ]
-
+  
+  USAGE: clang-rename rename-at [subcommand] [options]  [... ]
+  
   OPTIONS:
+  
+  Generic Options:
+  
+-help  - Display available options (-help-hidden for more)
+-help-list - Display list of available options (-help-list-hidden for more)
+-version   - Display the version of this program
 
-  Clang-rename options:
+  clang-rename rename-at options:
 
 -export-fixes=   - YAML file to store suggested fixes in.
 -extra-arg=- Additional argument to append to the compiler command line
 -extra-arg-before= - Additional argument to prepend to the compiler command line
 -i - Overwrite edited s.
 -new-name= - The new name to change the symbol to.
 -offset= - Locates the symbol by offset as opposed to :.
--old-name= - The fully qualified name of the symbol, if -offset is not used.
 -p=- Build path
 -pl- Print the locations affected by renaming to stderr.
 -pn- Print the found symbol's name prior to renaming to stderr.
 
+
+.. code-block:: console
+
+  $ ~/git/llvm/workdir/bin/c

Re: [PATCH] D21814: clang-rename: split existing options into two new subcommands

2016-07-29 Thread Miklos Vajna via cfe-commits
vmiklos added a comment.

Rebased on top of r277131 and resolved conflicts.

> As for help message, look at clang-tidy. Is there a need in helpMain?


I think so; we have this chicken-and-egg problem (see earlier comments of this
review), that the options parser wants to know the option category, but we only
know the option category after parsing options due to subcommands. This is not
a problem for clang-tidy that doesn't have subcommands (as far as I see).

So one way is the own code for handling the subcommands (that's what I did
here, and that's what e.g. llvm-cov does), an other way would be to extend
`tooling::CommonOptionsParser`, so it doesn't want a category in the ctor. That
requirement is a problem for us, since we have two categories, so we can't give
the correct one without parsing the options.

So all in all, the best seems to me is to go with a simple helpMain().

> besides, let me push one thing; it's about passing a vector of USRs to the 
> USRLocFinder instead of passing them 1 by 1; removes a need to write that 
> FIXME of yours :)


Great, I've removed it then.


https://reviews.llvm.org/D21814



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D21814: clang-rename: split existing options into two new subcommands

2016-07-29 Thread Miklos Vajna via cfe-commits
vmiklos updated this revision to Diff 66105.

https://reviews.llvm.org/D21814

Files:
  clang-rename/RenamingAction.cpp
  clang-rename/RenamingAction.h
  clang-rename/tool/ClangRename.cpp
  docs/clang-rename.rst
  test/clang-rename/ClassFindByName.cpp
  test/clang-rename/ClassTestMulti.cpp
  test/clang-rename/ClassTestMultiByName.cpp
  test/clang-rename/FunctionWithClassFindByName.cpp
  test/clang-rename/NoNewName.cpp

Index: test/clang-rename/NoNewName.cpp
===
--- test/clang-rename/NoNewName.cpp
+++ test/clang-rename/NoNewName.cpp
@@ -1,4 +1,4 @@
 // Check for an error while -new-name argument has not been passed to
 // clang-rename.
 // RUN: not clang-rename -offset=133 %s 2>&1 | FileCheck %s
-// CHECK: ERROR: no new name provided.
+// CHECK: clang-rename: for the -new-name option: must be specified
Index: test/clang-rename/FunctionWithClassFindByName.cpp
===
--- test/clang-rename/FunctionWithClassFindByName.cpp
+++ test/clang-rename/FunctionWithClassFindByName.cpp
@@ -1,4 +1,4 @@
-// RUN: clang-rename -old-name=Foo -new-name=Bar %s -- | FileCheck %s
+// RUN: clang-rename rename-all -old-name=Foo -new-name=Bar %s -- | FileCheck %s
 
 void foo() {
 }
Index: test/clang-rename/ClassTestMultiByName.cpp
===
--- /dev/null
+++ test/clang-rename/ClassTestMultiByName.cpp
@@ -0,0 +1,6 @@
+// RUN: clang-rename rename-all -old-name=Cla1 -new-name=Kla1 -old-name=Cla2 -new-name=Kla2 %s -- | FileCheck %s
+class Cla1 { // CHECK: class Kla1
+};
+
+class Cla2 { // CHECK: class Kla2
+};
Index: test/clang-rename/ClassTestMulti.cpp
===
--- /dev/null
+++ test/clang-rename/ClassTestMulti.cpp
@@ -0,0 +1,6 @@
+// RUN: clang-rename rename-all -offset=113 -new-name=Kla1 -offset=151 -new-name=Kla2 %s -- | FileCheck %s
+class Cla1 { // CHECK: class Kla1
+};
+
+class Cla2 { // CHECK: class Kla2
+};
Index: test/clang-rename/ClassFindByName.cpp
===
--- test/clang-rename/ClassFindByName.cpp
+++ test/clang-rename/ClassFindByName.cpp
@@ -1,4 +1,4 @@
-// RUN: clang-rename -old-name=Foo -new-name=Bar %s -- | FileCheck %s
+// RUN: clang-rename rename-all -old-name=Foo -new-name=Bar %s -- | FileCheck %s
 
 class Foo { // CHECK: class Bar
 };
Index: docs/clang-rename.rst
===
--- docs/clang-rename.rst
+++ docs/clang-rename.rst
@@ -42,6 +42,14 @@
   $ grep -FUbo 'foo' file.cpp
 
 
+You can also identify one or more symbols to be renamed by giving the fully qualified
+name:
+
+.. code-block:: console
+
+  $ clang-rename rename-all -old-name=foo -new-name=bar test.cpp
+
+
 The tool currently supports renaming actions inside a single Translation Unit
 only. It is planned to extend the tool's functionality to support multi-TU
 renaming actions in the future.
@@ -55,34 +63,73 @@
 .. code-block:: console
 
   $ clang-rename -help
+  Usage: clang-rename {rename-at|rename-all} [OPTION]...
+
+  A tool to rename symbols in C/C++ code.
+
+  Subcommands:
+rename-at:  Perform rename off of a location in a file. (This is the default.)
+rename-all: Perform rename of all symbols matching one or more fully qualified names.
+
+
+.. code-block:: console
+
+  $ clang-rename rename-at -help
   OVERVIEW: A tool to rename symbols in C/C++ code.
   clang-rename renames every occurrence of a symbol found at  in
   . If -i is specified, the edited files are overwritten to disk.
   Otherwise, the results are written to stdout.
-
-  USAGE: clang-rename [subcommand] [options]  [... ]
-
+  
+  USAGE: clang-rename rename-at [subcommand] [options]  [... ]
+  
   OPTIONS:
+  
+  Generic Options:
+  
+-help  - Display available options (-help-hidden for more)
+-help-list - Display list of available options (-help-list-hidden for more)
+-version   - Display the version of this program
 
-  Clang-rename options:
+  clang-rename rename-at options:
 
 -export-fixes=   - YAML file to store suggested fixes in.
 -extra-arg=- Additional argument to append to the compiler command line
 -extra-arg-before= - Additional argument to prepend to the compiler command line
 -i - Overwrite edited s.
 -new-name= - The new name to change the symbol to.
 -offset= - Locates the symbol by offset as opposed to :.
--old-name= - The fully qualified name of the symbol, if -offset is not used.
 -p=- Build path
 -pl- Print the locations affected by renaming to stderr.
 -pn- Print the found symbol's name prior to renaming to stderr.
 
+
+.. code-block:: console
+
+  $ ~/git/llvm/workdir/bin/c

Re: [PATCH] D21814: clang-rename: split existing options into two new subcommands

2016-07-29 Thread Miklos Vajna via cfe-commits
vmiklos added a subscriber: Eugene.Zelenko.
vmiklos added a comment.

> 1. Run `clang-format` or something, 80 char width limit is broken in 
> `tool/ClangRename.cpp` dozen of times.


Done. I was afraid doing that, due to the changes not related to my patch, but
the result doesn't seem to be too bad. I guess in a later patch it would be
great to run clang-format on the whole clang-rename code, then all contributors
could just run clang-format before committing in case LLVM coding style is not
in our muscle memory. :)

> 2. Only do `outs() << "abcd\n" << "efgh\n"` if you have something in between, 
> which can not be predefined. I.e. if you have ``` /// \brief Top level help. 
> static int helpMain(int argc, const char *argv[]) { errs() << "Usage: 
> clang-rename {rename-at|rename-all} [OPTION]...\n\n" << "A tool to rename 
> symbols in C/C++ code.\n\n" << "Subcommands:\n" << "  rename-at:  Perform 
> rename off of a location in a file. (This is the default.)\n" << "  
> rename-all: Perform rename of all symbols matching one or more fully 
> qualified names.\n"; return 0; } ``` Just make it a const string, isn't it 
> better?


Done. I copied llvm-cov, but I have no problems changing it.

> 3. `tooling::RefactoringTool` takes care of printing version IIUC, no need to 
> do that in a custom way (we don't have custom version in `clang-rename` head 
> at the moment, that was something @Eugene.Zelenko sent recently).


Indeed, removed.

> 4. `clang-rename/RenamingAction.h` -> `USRList` -> `USRs` or the other way 
> around everywhere. So far single naming convention feels right to me (I 
> personally prefer `*s` over `*List`). LLVM Coding Style 
> 
>  does, too, from what I understand. Unless it's `*Set`, which is pretty much 
> different thing.


I've changed NewNameList and PrevNameList.

USRList refers to a list of lists, i.e. doing one oldname->newname rename may
have to deal with multiple USRs, and when doing multiple oldname->newname
renames, you need to deal with a list of list of USRs. I used the List suffix
in this "list of list" case. I have no problem renaming
`std::vector> USRList` to USRs, but then we need a new
name for `std::vector USRs`.

> 5. Do we really need to dispatch these functions this way? with

> 

>   ``` enum RenameSubcommand { RenameAt, RenameAll }; ``` And many other 
> strange things. Just pass `bool isMultipleRename` or `isRenameAll` to `main` 
> routine instead of creating `enum`. We only have two such options here, 
> right? I pray we won't have more.


I promise I don't plan to suggest more. :) Changed the enum to a bool.

> 6. Move `int main(int argc, const char **argv)` upwards, so that it's above 
> dispatched routines. Otherwise when one wants to see what's going on, he sees 
> subroutine first without understanding where it comes from. Other way around 
> feels more intuitive to me.


Done.


https://reviews.llvm.org/D21814



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D21814: clang-rename: split existing options into two new subcommands

2016-07-29 Thread Miklos Vajna via cfe-commits
vmiklos updated this revision to Diff 66099.

https://reviews.llvm.org/D21814

Files:
  clang-rename/RenamingAction.cpp
  clang-rename/RenamingAction.h
  clang-rename/tool/ClangRename.cpp
  docs/clang-rename.rst
  test/clang-rename/ClassFindByName.cpp
  test/clang-rename/ClassTestMulti.cpp
  test/clang-rename/ClassTestMultiByName.cpp
  test/clang-rename/FunctionWithClassFindByName.cpp
  test/clang-rename/NoNewName.cpp

Index: test/clang-rename/NoNewName.cpp
===
--- test/clang-rename/NoNewName.cpp
+++ test/clang-rename/NoNewName.cpp
@@ -1,4 +1,4 @@
 // Check for an error while -new-name argument has not been passed to
 // clang-rename.
 // RUN: not clang-rename -offset=133 %s 2>&1 | FileCheck %s
-// CHECK: ERROR: no new name provided.
+// CHECK: clang-rename: for the -new-name option: must be specified
Index: test/clang-rename/FunctionWithClassFindByName.cpp
===
--- test/clang-rename/FunctionWithClassFindByName.cpp
+++ test/clang-rename/FunctionWithClassFindByName.cpp
@@ -1,4 +1,4 @@
-// RUN: clang-rename -old-name=Foo -new-name=Bar %s -- | FileCheck %s
+// RUN: clang-rename rename-all -old-name=Foo -new-name=Bar %s -- | FileCheck %s
 
 void foo() {
 }
Index: test/clang-rename/ClassTestMultiByName.cpp
===
--- /dev/null
+++ test/clang-rename/ClassTestMultiByName.cpp
@@ -0,0 +1,6 @@
+// RUN: clang-rename rename-all -old-name=Cla1 -new-name=Kla1 -old-name=Cla2 -new-name=Kla2 %s -- | FileCheck %s
+class Cla1 { // CHECK: class Kla1
+};
+
+class Cla2 { // CHECK: class Kla2
+};
Index: test/clang-rename/ClassTestMulti.cpp
===
--- /dev/null
+++ test/clang-rename/ClassTestMulti.cpp
@@ -0,0 +1,6 @@
+// RUN: clang-rename rename-all -offset=113 -new-name=Kla1 -offset=151 -new-name=Kla2 %s -- | FileCheck %s
+class Cla1 { // CHECK: class Kla1
+};
+
+class Cla2 { // CHECK: class Kla2
+};
Index: test/clang-rename/ClassFindByName.cpp
===
--- test/clang-rename/ClassFindByName.cpp
+++ test/clang-rename/ClassFindByName.cpp
@@ -1,4 +1,4 @@
-// RUN: clang-rename -old-name=Foo -new-name=Bar %s -- | FileCheck %s
+// RUN: clang-rename rename-all -old-name=Foo -new-name=Bar %s -- | FileCheck %s
 
 class Foo { // CHECK: class Bar
 };
Index: docs/clang-rename.rst
===
--- docs/clang-rename.rst
+++ docs/clang-rename.rst
@@ -42,6 +42,14 @@
   $ grep -FUbo 'foo' file.cpp
 
 
+You can also identify one or more symbols to be renamed by giving the fully qualified
+name:
+
+.. code-block:: console
+
+  $ clang-rename rename-all -old-name=foo -new-name=bar test.cpp
+
+
 The tool currently supports renaming actions inside a single Translation Unit
 only. It is planned to extend the tool's functionality to support multi-TU
 renaming actions in the future.
@@ -55,34 +63,73 @@
 .. code-block:: console
 
   $ clang-rename -help
+  Usage: clang-rename {rename-at|rename-all} [OPTION]...
+
+  A tool to rename symbols in C/C++ code.
+
+  Subcommands:
+rename-at:  Perform rename off of a location in a file. (This is the default.)
+rename-all: Perform rename of all symbols matching one or more fully qualified names.
+
+
+.. code-block:: console
+
+  $ clang-rename rename-at -help
   OVERVIEW: A tool to rename symbols in C/C++ code.
   clang-rename renames every occurrence of a symbol found at  in
   . If -i is specified, the edited files are overwritten to disk.
   Otherwise, the results are written to stdout.
-
-  USAGE: clang-rename [subcommand] [options]  [... ]
-
+  
+  USAGE: clang-rename rename-at [subcommand] [options]  [... ]
+  
   OPTIONS:
+  
+  Generic Options:
+  
+-help  - Display available options (-help-hidden for more)
+-help-list - Display list of available options (-help-list-hidden for more)
+-version   - Display the version of this program
 
-  Clang-rename options:
+  clang-rename rename-at options:
 
 -export-fixes=   - YAML file to store suggested fixes in.
 -extra-arg=- Additional argument to append to the compiler command line
 -extra-arg-before= - Additional argument to prepend to the compiler command line
 -i - Overwrite edited s.
 -new-name= - The new name to change the symbol to.
 -offset= - Locates the symbol by offset as opposed to :.
--old-name= - The fully qualified name of the symbol, if -offset is not used.
 -p=- Build path
 -pl- Print the locations affected by renaming to stderr.
 -pn- Print the found symbol's name prior to renaming to stderr.
 
+
+.. code-block:: console
+
+  $ ~/git/llvm/workdir/bin/c

Re: [PATCH] D21814: clang-rename: split existing options into two new subcommands

2016-07-29 Thread Miklos Vajna via cfe-commits
vmiklos added a comment.

Is there anything I can help with to get this accepted, please? As far as I see 
I addressed all so far mentioned concerns. Thanks.


https://reviews.llvm.org/D21814



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D21814: clang-rename: split existing options into two new subcommands

2016-07-27 Thread Miklos Vajna via cfe-commits
vmiklos added a comment.

Rebased on top of r276949 and resolved a failing test 
(FunctionWithClassFindByName.cpp).


https://reviews.llvm.org/D21814



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D21814: clang-rename: split existing options into two new subcommands

2016-07-27 Thread Miklos Vajna via cfe-commits
vmiklos updated this revision to Diff 65876.

https://reviews.llvm.org/D21814

Files:
  clang-rename/RenamingAction.cpp
  clang-rename/RenamingAction.h
  clang-rename/tool/ClangRename.cpp
  docs/clang-rename.rst
  test/clang-rename/ClassFindByName.cpp
  test/clang-rename/ClassTestMulti.cpp
  test/clang-rename/ClassTestMultiByName.cpp
  test/clang-rename/FunctionWithClassFindByName.cpp
  test/clang-rename/NoNewName.cpp

Index: test/clang-rename/NoNewName.cpp
===
--- test/clang-rename/NoNewName.cpp
+++ test/clang-rename/NoNewName.cpp
@@ -1,4 +1,4 @@
 // Check for an error while -new-name argument has not been passed to
 // clang-rename.
 // RUN: not clang-rename -offset=133 %s 2>&1 | FileCheck %s
-// CHECK: ERROR: no new name provided.
+// CHECK: clang-rename: for the -new-name option: must be specified
Index: test/clang-rename/FunctionWithClassFindByName.cpp
===
--- test/clang-rename/FunctionWithClassFindByName.cpp
+++ test/clang-rename/FunctionWithClassFindByName.cpp
@@ -1,4 +1,4 @@
-// RUN: clang-rename -old-name=Foo -new-name=Bar %s -- | FileCheck %s
+// RUN: clang-rename rename-all -old-name=Foo -new-name=Bar %s -- | FileCheck %s
 
 void foo() {
 }
Index: test/clang-rename/ClassTestMultiByName.cpp
===
--- /dev/null
+++ test/clang-rename/ClassTestMultiByName.cpp
@@ -0,0 +1,6 @@
+// RUN: clang-rename rename-all -old-name=Cla1 -new-name=Kla1 -old-name=Cla2 -new-name=Kla2 %s -- | FileCheck %s
+class Cla1 { // CHECK: class Kla1
+};
+
+class Cla2 { // CHECK: class Kla2
+};
Index: test/clang-rename/ClassTestMulti.cpp
===
--- /dev/null
+++ test/clang-rename/ClassTestMulti.cpp
@@ -0,0 +1,6 @@
+// RUN: clang-rename rename-all -offset=113 -new-name=Kla1 -offset=151 -new-name=Kla2 %s -- | FileCheck %s
+class Cla1 { // CHECK: class Kla1
+};
+
+class Cla2 { // CHECK: class Kla2
+};
Index: test/clang-rename/ClassFindByName.cpp
===
--- test/clang-rename/ClassFindByName.cpp
+++ test/clang-rename/ClassFindByName.cpp
@@ -1,4 +1,4 @@
-// RUN: clang-rename -old-name=Foo -new-name=Bar %s -- | FileCheck %s
+// RUN: clang-rename rename-all -old-name=Foo -new-name=Bar %s -- | FileCheck %s
 
 class Foo { // CHECK: class Bar
 };
Index: docs/clang-rename.rst
===
--- docs/clang-rename.rst
+++ docs/clang-rename.rst
@@ -42,6 +42,14 @@
   $ grep -FUbo 'foo' file.cpp
 
 
+You can also identify one or more symbols to be renamed by giving the fully qualified
+name:
+
+.. code-block:: console
+
+  $ clang-rename rename-all -old-name=foo -new-name=bar test.cpp
+
+
 The tool currently supports renaming actions inside a single Translation Unit
 only. It is planned to extend the tool's functionality to support multi-TU
 renaming actions in the future.
@@ -55,34 +63,73 @@
 .. code-block:: console
 
   $ clang-rename -help
+  Usage: clang-rename {rename-at|rename-all} [OPTION]...
+
+  A tool to rename symbols in C/C++ code.
+
+  Subcommands:
+rename-at:  Perform rename off of a location in a file. (This is the default.)
+rename-all: Perform rename of all symbols matching one or more fully qualified names.
+
+
+.. code-block:: console
+
+  $ clang-rename rename-at -help
   OVERVIEW: A tool to rename symbols in C/C++ code.
   clang-rename renames every occurrence of a symbol found at  in
   . If -i is specified, the edited files are overwritten to disk.
   Otherwise, the results are written to stdout.
-
-  USAGE: clang-rename [subcommand] [options]  [... ]
-
+  
+  USAGE: clang-rename rename-at [subcommand] [options]  [... ]
+  
   OPTIONS:
+  
+  Generic Options:
+  
+-help  - Display available options (-help-hidden for more)
+-help-list - Display list of available options (-help-list-hidden for more)
+-version   - Display the version of this program
 
-  Clang-rename options:
+  clang-rename rename-at options:
 
 -export-fixes=   - YAML file to store suggested fixes in.
 -extra-arg=- Additional argument to append to the compiler command line
 -extra-arg-before= - Additional argument to prepend to the compiler command line
 -i - Overwrite edited s.
 -new-name= - The new name to change the symbol to.
 -offset= - Locates the symbol by offset as opposed to :.
--old-name= - The fully qualified name of the symbol, if -offset is not used.
 -p=- Build path
 -pl- Print the locations affected by renaming to stderr.
 -pn- Print the found symbol's name prior to renaming to stderr.
 
+
+.. code-block:: console
+
+  $ ~/git/llvm/workdir/bin/c

Re: [PATCH] D22854: change Vim key binding for include-fixer and clang-rename

2016-07-27 Thread Miklos Vajna via cfe-commits
vmiklos added a subscriber: vmiklos.
vmiklos added a comment.

`:help leader` explains it. Or see this link: 
http://learnvimscriptthehardway.stevelosh.com/chapters/06.html#leader. The 
later describes 3 arguments for using `` instead of `,` directly.


https://reviews.llvm.org/D22854



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D21814: clang-rename: split existing options into two new subcommands

2016-07-27 Thread Miklos Vajna via cfe-commits
vmiklos marked 2 inline comments as done.
vmiklos added a comment.

> rename-at isn't necessary here anymore since it's going to be default 
> behavior IIUC


Indeed, it can be changed back now, done.

> docs should be fixed correspondingly; i.e. prefer to write clang-rename 
> -offset=42 over clang-rename -rename-at


Done.

> here and later, too


`clang-rename rename-at` is now only mentioned by the document when it comes to
`clang-rename rename-at -help`, which is still necessary, as `clang-rename
-help` talks about the subcommands only. I've updated `clang-rename -help` so
that it points out that `rename-at` is the default, though.


https://reviews.llvm.org/D21814



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D21814: clang-rename: split existing options into two new subcommands

2016-07-27 Thread Miklos Vajna via cfe-commits
vmiklos updated this revision to Diff 65684.

https://reviews.llvm.org/D21814

Files:
  clang-rename/RenamingAction.cpp
  clang-rename/RenamingAction.h
  clang-rename/tool/ClangRename.cpp
  docs/clang-rename.rst
  test/clang-rename/ClassFindByName.cpp
  test/clang-rename/ClassTestMulti.cpp
  test/clang-rename/ClassTestMultiByName.cpp
  test/clang-rename/NoNewName.cpp

Index: test/clang-rename/NoNewName.cpp
===
--- test/clang-rename/NoNewName.cpp
+++ test/clang-rename/NoNewName.cpp
@@ -1,4 +1,4 @@
 // Check for an error while -new-name argument has not been passed to
 // clang-rename.
 // RUN: not clang-rename -offset=133 %s 2>&1 | FileCheck %s
-// CHECK: ERROR: no new name provided.
+// CHECK: clang-rename: for the -new-name option: must be specified
Index: test/clang-rename/ClassTestMultiByName.cpp
===
--- /dev/null
+++ test/clang-rename/ClassTestMultiByName.cpp
@@ -0,0 +1,6 @@
+// RUN: clang-rename rename-all -old-name=Cla1 -new-name=Kla1 -old-name=Cla2 -new-name=Kla2 %s -- | FileCheck %s
+class Cla1 { // CHECK: class Kla1
+};
+
+class Cla2 { // CHECK: class Kla2
+};
Index: test/clang-rename/ClassTestMulti.cpp
===
--- /dev/null
+++ test/clang-rename/ClassTestMulti.cpp
@@ -0,0 +1,6 @@
+// RUN: clang-rename rename-all -offset=113 -new-name=Kla1 -offset=151 -new-name=Kla2 %s -- | FileCheck %s
+class Cla1 { // CHECK: class Kla1
+};
+
+class Cla2 { // CHECK: class Kla2
+};
Index: test/clang-rename/ClassFindByName.cpp
===
--- test/clang-rename/ClassFindByName.cpp
+++ test/clang-rename/ClassFindByName.cpp
@@ -1,4 +1,4 @@
-// RUN: clang-rename -old-name=Foo -new-name=Bar %s -- | FileCheck %s
+// RUN: clang-rename rename-all -old-name=Foo -new-name=Bar %s -- | FileCheck %s
 
 class Foo { // CHECK: class Bar
 };
Index: docs/clang-rename.rst
===
--- docs/clang-rename.rst
+++ docs/clang-rename.rst
@@ -42,6 +42,14 @@
   $ grep -FUbo 'foo' file.cpp
 
 
+You can also identify one or more symbols to be renamed by giving the fully qualified
+name:
+
+.. code-block:: console
+
+  $ clang-rename rename-all -old-name=foo -new-name=bar test.cpp
+
+
 The tool currently supports renaming actions inside a single Translation Unit
 only. It is planned to extend the tool's functionality to support multi-TU
 renaming actions in the future.
@@ -55,34 +63,73 @@
 .. code-block:: console
 
   $ clang-rename -help
+  Usage: clang-rename {rename-at|rename-all} [OPTION]...
+
+  A tool to rename symbols in C/C++ code.
+
+  Subcommands:
+rename-at:  Perform rename off of a location in a file. (This is the default.)
+rename-all: Perform rename of all symbols matching one or more fully qualified names.
+
+
+.. code-block:: console
+
+  $ clang-rename rename-at -help
   OVERVIEW: A tool to rename symbols in C/C++ code.
   clang-rename renames every occurrence of a symbol found at  in
   . If -i is specified, the edited files are overwritten to disk.
   Otherwise, the results are written to stdout.
-
-  USAGE: clang-rename [subcommand] [options]  [... ]
-
+  
+  USAGE: clang-rename rename-at [subcommand] [options]  [... ]
+  
   OPTIONS:
+  
+  Generic Options:
+  
+-help  - Display available options (-help-hidden for more)
+-help-list - Display list of available options (-help-list-hidden for more)
+-version   - Display the version of this program
 
-  Clang-rename options:
+  clang-rename rename-at options:
 
 -export-fixes=   - YAML file to store suggested fixes in.
 -extra-arg=- Additional argument to append to the compiler command line
 -extra-arg-before= - Additional argument to prepend to the compiler command line
 -i - Overwrite edited s.
 -new-name= - The new name to change the symbol to.
 -offset= - Locates the symbol by offset as opposed to :.
--old-name= - The fully qualified name of the symbol, if -offset is not used.
 -p=- Build path
 -pl- Print the locations affected by renaming to stderr.
 -pn- Print the found symbol's name prior to renaming to stderr.
 
+
+.. code-block:: console
+
+  $ ~/git/llvm/workdir/bin/clang-rename rename-all -help
+  OVERVIEW: A tool to rename symbols in C/C++ code.
+  clang-rename renames every occurrence of a symbol named .
+
+  USAGE: clang-rename rename-all [subcommand] [options]  [... ]
+
+  OPTIONS:
+
   Generic Options:
 
 -help  - Display available options (-help-hidden for more)
 -help-list - Display list of available options (-help-list-hidden for more)
 -version   - Display th

Re: [PATCH] D21814: clang-rename: split existing options into two new subcommands

2016-07-27 Thread Miklos Vajna via cfe-commits
vmiklos added a comment.

Rebased on top of r276836 and resolved conflicts.


https://reviews.llvm.org/D21814



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D21814: clang-rename: split existing options into two new subcommands

2016-07-27 Thread Miklos Vajna via cfe-commits
vmiklos updated this revision to Diff 65672.

https://reviews.llvm.org/D21814

Files:
  clang-rename/RenamingAction.cpp
  clang-rename/RenamingAction.h
  clang-rename/tool/ClangRename.cpp
  clang-rename/tool/clang-rename.py
  docs/clang-rename.rst
  test/clang-rename/ClassFindByName.cpp
  test/clang-rename/ClassTestMulti.cpp
  test/clang-rename/ClassTestMultiByName.cpp
  test/clang-rename/NoNewName.cpp

Index: test/clang-rename/NoNewName.cpp
===
--- test/clang-rename/NoNewName.cpp
+++ test/clang-rename/NoNewName.cpp
@@ -1,4 +1,4 @@
 // Check for an error while -new-name argument has not been passed to
 // clang-rename.
 // RUN: not clang-rename -offset=133 %s 2>&1 | FileCheck %s
-// CHECK: ERROR: no new name provided.
+// CHECK: clang-rename: for the -new-name option: must be specified
Index: test/clang-rename/ClassTestMultiByName.cpp
===
--- /dev/null
+++ test/clang-rename/ClassTestMultiByName.cpp
@@ -0,0 +1,6 @@
+// RUN: clang-rename rename-all -old-name=Cla1 -new-name=Kla1 -old-name=Cla2 -new-name=Kla2 %s -- | FileCheck %s
+class Cla1 { // CHECK: class Kla1
+};
+
+class Cla2 { // CHECK: class Kla2
+};
Index: test/clang-rename/ClassTestMulti.cpp
===
--- /dev/null
+++ test/clang-rename/ClassTestMulti.cpp
@@ -0,0 +1,6 @@
+// RUN: clang-rename rename-all -offset=113 -new-name=Kla1 -offset=151 -new-name=Kla2 %s -- | FileCheck %s
+class Cla1 { // CHECK: class Kla1
+};
+
+class Cla2 { // CHECK: class Kla2
+};
Index: test/clang-rename/ClassFindByName.cpp
===
--- test/clang-rename/ClassFindByName.cpp
+++ test/clang-rename/ClassFindByName.cpp
@@ -1,4 +1,4 @@
-// RUN: clang-rename -old-name=Foo -new-name=Bar %s -- | FileCheck %s
+// RUN: clang-rename rename-all -old-name=Foo -new-name=Bar %s -- | FileCheck %s
 
 class Foo { // CHECK: class Bar
 };
Index: docs/clang-rename.rst
===
--- docs/clang-rename.rst
+++ docs/clang-rename.rst
@@ -32,7 +32,7 @@
 
 .. code-block:: console
 
-  $ clang-rename -offset=42 -new-name=foo test.cpp -- -Imy_project/include -DMY_DEFINES ...
+  $ clang-rename rename-at -offset=42 -new-name=foo test.cpp -- -Imy_project/include -DMY_DEFINES ...
 
 
 To get an offset of a symbol in a file run
@@ -42,6 +42,14 @@
   $ grep -FUbo 'foo' file.cpp
 
 
+You can also identify one or more symbols to be renamed by giving the fully qualified
+name:
+
+.. code-block:: console
+
+  $ clang-rename rename-all -old-name=foo -new-name=bar test.cpp
+
+
 The tool currently supports renaming actions inside a single Translation Unit
 only. It is planned to extend the tool's functionality to support multi-TU
 renaming actions in the future.
@@ -55,34 +63,73 @@
 .. code-block:: console
 
   $ clang-rename -help
+  Usage: clang-rename {rename-at|rename-all} [OPTION]...
+
+  A tool to rename symbols in C/C++ code.
+
+  Subcommands:
+rename-at:  Perform rename off of a location in a file.
+rename-all: Perform rename of all symbols matching one or more fully qualified names.
+
+
+.. code-block:: console
+
+  $ clang-rename rename-at -help
   OVERVIEW: A tool to rename symbols in C/C++ code.
   clang-rename renames every occurrence of a symbol found at  in
   . If -i is specified, the edited files are overwritten to disk.
   Otherwise, the results are written to stdout.
-
-  USAGE: clang-rename [subcommand] [options]  [... ]
-
+  
+  USAGE: clang-rename rename-at [subcommand] [options]  [... ]
+  
   OPTIONS:
+  
+  Generic Options:
+  
+-help  - Display available options (-help-hidden for more)
+-help-list - Display list of available options (-help-list-hidden for more)
+-version   - Display the version of this program
 
-  Clang-rename options:
+  clang-rename rename-at options:
 
 -export-fixes=   - YAML file to store suggested fixes in.
 -extra-arg=- Additional argument to append to the compiler command line
 -extra-arg-before= - Additional argument to prepend to the compiler command line
 -i - Overwrite edited s.
 -new-name= - The new name to change the symbol to.
 -offset= - Locates the symbol by offset as opposed to :.
--old-name= - The fully qualified name of the symbol, if -offset is not used.
 -p=- Build path
 -pl- Print the locations affected by renaming to stderr.
 -pn- Print the found symbol's name prior to renaming to stderr.
 
+
+.. code-block:: console
+
+  $ ~/git/llvm/workdir/bin/clang-rename rename-all -help
+  OVERVIEW: A tool to rename symbols in C/C++ code.
+  clang-rename renames every occurrence of a symbol named .
+
+  USAGE: clang-rename r

Re: [PATCH] D21814: clang-rename: split existing options into two new subcommands

2016-07-25 Thread Miklos Vajna via cfe-commits
vmiklos added a comment.

Rebased on top of r276684 and resolved conflicts.


https://reviews.llvm.org/D21814



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D21814: clang-rename: split existing options into two new subcommands

2016-07-25 Thread Miklos Vajna via cfe-commits
vmiklos updated this revision to Diff 65417.

https://reviews.llvm.org/D21814

Files:
  clang-rename/RenamingAction.cpp
  clang-rename/RenamingAction.h
  clang-rename/tool/ClangRename.cpp
  clang-rename/tool/clang-rename.py
  docs/clang-rename.rst
  test/clang-rename/ClassFindByName.cpp
  test/clang-rename/ClassTestMulti.cpp
  test/clang-rename/ClassTestMultiByName.cpp
  test/clang-rename/NoNewName.cpp

Index: test/clang-rename/NoNewName.cpp
===
--- test/clang-rename/NoNewName.cpp
+++ test/clang-rename/NoNewName.cpp
@@ -1,4 +1,4 @@
 // Check for an error while -new-name argument has not been passed to
 // clang-rename.
 // RUN: not clang-rename -offset=133 %s 2>&1 | FileCheck %s
-// CHECK: ERROR: no new name provided.
+// CHECK: clang-rename: for the -new-name option: must be specified
Index: test/clang-rename/ClassTestMultiByName.cpp
===
--- /dev/null
+++ test/clang-rename/ClassTestMultiByName.cpp
@@ -0,0 +1,8 @@
+// RUN: cat %s > %t.cpp
+// RUN: clang-rename rename-all -old-name=Cla1 -new-name=Kla1 -old-name=Cla2 -new-name=Kla2 %t.cpp -i --
+// RUN: sed 's,//.*,,' %t.cpp | FileCheck %s
+class Cla1 { // CHECK: class Kla1
+};
+
+class Cla2 { // CHECK: class Kla2
+};
Index: test/clang-rename/ClassTestMulti.cpp
===
--- /dev/null
+++ test/clang-rename/ClassTestMulti.cpp
@@ -0,0 +1,8 @@
+// RUN: cat %s > %t.cpp
+// RUN: clang-rename rename-all -offset=174 -new-name=Kla1 -offset=212 -new-name=Kla2 %t.cpp -i --
+// RUN: sed 's,//.*,,' %t.cpp | FileCheck %s
+class Cla1 { // CHECK: class Kla1
+};
+
+class Cla2 { // CHECK: class Kla2
+};
Index: test/clang-rename/ClassFindByName.cpp
===
--- test/clang-rename/ClassFindByName.cpp
+++ test/clang-rename/ClassFindByName.cpp
@@ -1,5 +1,5 @@
 // RUN: cat %s > %t.cpp
-// RUN: clang-rename -old-name=Foo -new-name=Bar %t.cpp -i --
+// RUN: clang-rename rename-all -old-name=Foo -new-name=Bar %t.cpp -i --
 // RUN: sed 's,//.*,,' %t.cpp | FileCheck %s
 
 class Foo { // CHECK: class Bar
Index: docs/clang-rename.rst
===
--- docs/clang-rename.rst
+++ docs/clang-rename.rst
@@ -32,7 +32,7 @@
 
 .. code-block:: console
 
-  $ clang-rename -offset=42 -new-name=foo test.cpp -- -Imy_project/include -DMY_DEFINES ...
+  $ clang-rename rename-at -offset=42 -new-name=foo test.cpp -- -Imy_project/include -DMY_DEFINES ...
 
 
 To get an offset of a symbol in a file run
@@ -42,6 +42,14 @@
   $ grep -FUbo 'foo' file.cpp
 
 
+You can also identify one or more symbols to be renamed by giving the fully qualified
+name:
+
+.. code-block:: console
+
+  $ clang-rename rename-all -old-name=foo -new-name=bar test.cpp
+
+
 The tool currently supports renaming actions inside a single Translation Unit
 only. It is planned to extend the tool's functionality to support multi-TU
 renaming actions in the future.
@@ -55,34 +63,73 @@
 .. code-block:: console
 
   $ clang-rename -help
+  Usage: clang-rename {rename-at|rename-all} [OPTION]...
+
+  A tool to rename symbols in C/C++ code.
+
+  Subcommands:
+rename-at:  Perform rename off of a location in a file.
+rename-all: Perform rename of all symbols matching one or more fully qualified names.
+
+
+.. code-block:: console
+
+  $ clang-rename rename-at -help
   OVERVIEW: A tool to rename symbols in C/C++ code.
   clang-rename renames every occurrence of a symbol found at  in
   . If -i is specified, the edited files are overwritten to disk.
   Otherwise, the results are written to stdout.
-
-  USAGE: clang-rename [subcommand] [options]  [... ]
-
+  
+  USAGE: clang-rename rename-at [subcommand] [options]  [... ]
+  
   OPTIONS:
+  
+  Generic Options:
+  
+-help  - Display available options (-help-hidden for more)
+-help-list - Display list of available options (-help-list-hidden for more)
+-version   - Display the version of this program
 
-  Clang-rename options:
+  clang-rename rename-at options:
 
 -export-fixes=   - YAML file to store suggested fixes in.
 -extra-arg=- Additional argument to append to the compiler command line
 -extra-arg-before= - Additional argument to prepend to the compiler command line
 -i - Overwrite edited s.
 -new-name= - The new name to change the symbol to.
 -offset= - Locates the symbol by offset as opposed to :.
--old-name= - The fully qualified name of the symbol, if -offset is not used.
 -p=- Build path
 -pl- Print the locations affected by renaming to stderr.
 -pn- Print the found symbol's name prior to renaming to stderr.
 
+
+.. code-block:: console
+
+  $ ~/git/llvm/workd

Re: [PATCH] D21814: clang-rename: split existing options into two new subcommands

2016-07-22 Thread Miklos Vajna via cfe-commits
vmiklos updated this revision to Diff 65042.

https://reviews.llvm.org/D21814

Files:
  clang-rename/RenamingAction.cpp
  clang-rename/RenamingAction.h
  clang-rename/tool/ClangRename.cpp
  clang-rename/tool/clang-rename.py
  docs/clang-rename.rst
  test/clang-rename/ClassFindByName.cpp
  test/clang-rename/ClassTestMulti.cpp
  test/clang-rename/ClassTestMultiByName.cpp
  test/clang-rename/NoNewName.cpp

Index: test/clang-rename/NoNewName.cpp
===
--- test/clang-rename/NoNewName.cpp
+++ test/clang-rename/NoNewName.cpp
@@ -1,4 +1,4 @@
 // Check for an error while -new-name argument has not been passed to
 // clang-rename.
 // RUN: not clang-rename -offset=133 %s 2>&1 | FileCheck %s
-// CHECK: ERROR: no new name provided.
+// CHECK: clang-rename: for the -new-name option: must be specified
Index: test/clang-rename/ClassTestMultiByName.cpp
===
--- /dev/null
+++ test/clang-rename/ClassTestMultiByName.cpp
@@ -0,0 +1,8 @@
+// RUN: cat %s > %t.cpp
+// RUN: clang-rename rename-all -old-name=Cla1 -new-name=Kla1 -old-name=Cla2 -new-name=Kla2 %t.cpp -i --
+// RUN: sed 's,//.*,,' %t.cpp | FileCheck %s
+class Cla1 { // CHECK: class Kla1
+};
+
+class Cla2 { // CHECK: class Kla2
+};
Index: test/clang-rename/ClassTestMulti.cpp
===
--- /dev/null
+++ test/clang-rename/ClassTestMulti.cpp
@@ -0,0 +1,8 @@
+// RUN: cat %s > %t.cpp
+// RUN: clang-rename rename-all -offset=174 -new-name=Kla1 -offset=212 -new-name=Kla2 %t.cpp -i --
+// RUN: sed 's,//.*,,' %t.cpp | FileCheck %s
+class Cla1 { // CHECK: class Kla1
+};
+
+class Cla2 { // CHECK: class Kla2
+};
Index: test/clang-rename/ClassFindByName.cpp
===
--- test/clang-rename/ClassFindByName.cpp
+++ test/clang-rename/ClassFindByName.cpp
@@ -1,5 +1,5 @@
 // RUN: cat %s > %t.cpp
-// RUN: clang-rename -old-name=Foo -new-name=Bar %t.cpp -i --
+// RUN: clang-rename rename-all -old-name=Foo -new-name=Bar %t.cpp -i --
 // RUN: sed 's,//.*,,' %t.cpp | FileCheck %s
 
 class Foo { // CHECK: class Bar
Index: docs/clang-rename.rst
===
--- docs/clang-rename.rst
+++ docs/clang-rename.rst
@@ -32,7 +32,7 @@
 
 .. code-block:: console
 
-  $ clang-rename -offset=42 -new-name=foo test.cpp -- -Imy_project/include -DMY_DEFINES ...
+  $ clang-rename rename-at -offset=42 -new-name=foo test.cpp -- -Imy_project/include -DMY_DEFINES ...
 
 
 To get an offset of a symbol in a file run
@@ -42,6 +42,14 @@
   $ grep -FUbo 'foo' file.cpp
 
 
+You can also identify one or more symbols to be renamed by giving the fully qualified
+name:
+
+.. code-block:: console
+
+  $ clang-rename rename-all -old-name=foo -new-name=bar test.cpp
+
+
 The tool currently supports renaming actions inside a single Translation Unit
 only. It is planned to extend the tool's functionality to support multi-TU
 renaming actions in the future.
@@ -55,34 +63,73 @@
 .. code-block:: console
 
   $ clang-rename -help
+  Usage: clang-rename {rename-at|rename-all} [OPTION]...
+
+  A tool to rename symbols in C/C++ code.
+
+  Subcommands:
+rename-at:  Perform rename off of a location in a file.
+rename-all: Perform rename of all symbols matching one or more fully qualified names.
+
+
+.. code-block:: console
+
+  $ clang-rename rename-at -help
   OVERVIEW: A tool to rename symbols in C/C++ code.
   clang-rename renames every occurrence of a symbol found at  in
   . If -i is specified, the edited files are overwritten to disk.
   Otherwise, the results are written to stdout.
-
-  USAGE: clang-rename [subcommand] [options]  [... ]
-
+  
+  USAGE: clang-rename rename-at [subcommand] [options]  [... ]
+  
   OPTIONS:
+  
+  Generic Options:
+  
+-help  - Display available options (-help-hidden for more)
+-help-list - Display list of available options (-help-list-hidden for more)
+-version   - Display the version of this program
 
-  Clang-rename options:
+  clang-rename rename-at options:
 
 -export-fixes=   - YAML file to store suggested fixes in.
 -extra-arg=- Additional argument to append to the compiler command line
 -extra-arg-before= - Additional argument to prepend to the compiler command line
 -i - Overwrite edited s.
 -new-name= - The new name to change the symbol to.
 -offset= - Locates the symbol by offset as opposed to :.
--old-name= - The fully qualified name of the symbol, if -offset is not used.
 -p=- Build path
 -pl- Print the locations affected by renaming to stderr.
 -pn- Print the found symbol's name prior to renaming to stderr.
 
+
+.. code-block:: console
+
+  $ ~/git/llvm/workd

Re: [PATCH] D21814: clang-rename: split existing options into two new subcommands

2016-07-22 Thread Miklos Vajna via cfe-commits
vmiklos added a comment.

Done, that also allows not modifying most existing tests.


https://reviews.llvm.org/D21814



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D21814: clang-rename: split existing options into two new subcommands

2016-07-22 Thread Miklos Vajna via cfe-commits
vmiklos added a comment.

In https://reviews.llvm.org/D21814#492540, @omtcyfz wrote:

> I'd be actually happy if instead of having `-rename-at` option we'd have this 
> behavior by default unless `-rename-all` is used.


Not sure I understand this request. rename-at and rename-all all subcommands, 
not options. "have this by default", you mean the ability to perform multiple 
oldname->newname replacements with one commandline invocation? If so, not 
allowing that when the rename-all subcommand is chosen sounds confusing to me. 
But perhaps I misunderstand something. ;-)

I can make the rename-at subcommand optional, and when not specifying a 
subcommand, assume rename-at was specified (unless -help or -version is used). 
Is this what you want?


https://reviews.llvm.org/D21814



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D21814: clang-rename: split existing options into two new subcommands

2016-07-22 Thread Miklos Vajna via cfe-commits
vmiklos marked an inline comment as done.
vmiklos added a comment.

https://reviews.llvm.org/D21814



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D21814: clang-rename: split existing options into two new subcommands

2016-07-22 Thread Miklos Vajna via cfe-commits
vmiklos updated this revision to Diff 65031.

https://reviews.llvm.org/D21814

Files:
  clang-rename/RenamingAction.cpp
  clang-rename/RenamingAction.h
  clang-rename/tool/ClangRename.cpp
  clang-rename/tool/clang-rename.py
  docs/clang-rename.rst
  test/clang-rename/ClassFindByName.cpp
  test/clang-rename/ClassReplacements.cpp
  test/clang-rename/ClassSimpleRenaming.cpp
  test/clang-rename/ClassTestMulti.cpp
  test/clang-rename/ClassTestMultiByName.cpp
  test/clang-rename/ConstCastExpr.cpp
  test/clang-rename/ConstructExpr.cpp
  test/clang-rename/CtorFindByDeclaration.cpp
  test/clang-rename/CtorFindByDefinition.cpp
  test/clang-rename/CtorInitializer.cpp
  test/clang-rename/DeclRefExpr.cpp
  test/clang-rename/DtorDeclaration.cpp
  test/clang-rename/DtorDefinition.cpp
  test/clang-rename/DynamicCastExpr.cpp
  test/clang-rename/Field.cpp
  test/clang-rename/FunctionMacro.cpp
  test/clang-rename/InvalidNewName.cpp
  test/clang-rename/MemberExprMacro.cpp
  test/clang-rename/Namespace.cpp
  test/clang-rename/NoNewName.cpp
  test/clang-rename/ReinterpretCastExpr.cpp
  test/clang-rename/StaticCastExpr.cpp
  test/clang-rename/Variable.cpp
  test/clang-rename/VariableMacro.cpp

Index: test/clang-rename/VariableMacro.cpp
===
--- test/clang-rename/VariableMacro.cpp
+++ test/clang-rename/VariableMacro.cpp
@@ -1,5 +1,5 @@
 // RUN: cat %s > %t.cpp
-// RUN: clang-rename -offset=208 -new-name=Z %t.cpp -i --
+// RUN: clang-rename rename-at -offset=218 -new-name=Z %t.cpp -i --
 // RUN: sed 's,//.*,,' %t.cpp | FileCheck %s
 
 #define Y X // CHECK: #define Y Z
Index: test/clang-rename/Variable.cpp
===
--- test/clang-rename/Variable.cpp
+++ test/clang-rename/Variable.cpp
@@ -1,5 +1,5 @@
 // RUN: cat %s > %t.cpp
-// RUN: clang-rename -offset=148 -new-name=Bar %t.cpp -i --
+// RUN: clang-rename rename-at -offset=158 -new-name=Bar %t.cpp -i --
 // RUN: sed 's,//.*,,' %t.cpp | FileCheck %s
 
 namespace A {
Index: test/clang-rename/StaticCastExpr.cpp
===
--- test/clang-rename/StaticCastExpr.cpp
+++ test/clang-rename/StaticCastExpr.cpp
@@ -1,5 +1,5 @@
 // RUN: cat %s > %t.cpp
-// RUN: clang-rename -offset=152 -new-name=Bar %t.cpp -i --
+// RUN: clang-rename rename-at -offset=162 -new-name=Bar %t.cpp -i --
 // RUN: sed 's,//.*,,' %t.cpp | FileCheck %s
 
 class Baz {
Index: test/clang-rename/ReinterpretCastExpr.cpp
===
--- test/clang-rename/ReinterpretCastExpr.cpp
+++ test/clang-rename/ReinterpretCastExpr.cpp
@@ -1,5 +1,5 @@
 // RUN: cat %s > %t.cpp
-// RUN: clang-rename -offset=133 -new-name=X %t.cpp -i --
+// RUN: clang-rename rename-at -offset=143 -new-name=X %t.cpp -i --
 // RUN: sed 's,//.*,,' %t.cpp | FileCheck %s
 class Cla {
 public:
Index: test/clang-rename/NoNewName.cpp
===
--- test/clang-rename/NoNewName.cpp
+++ test/clang-rename/NoNewName.cpp
@@ -1,4 +1,4 @@
 // Check for an error while -new-name argument has not been passed to
 // clang-rename.
-// RUN: not clang-rename -offset=133 %s 2>&1 | FileCheck %s
-// CHECK: ERROR: no new name provided.
+// RUN: not clang-rename rename-at -offset=133 %s 2>&1 | FileCheck %s
+// CHECK: clang-rename rename-at: for the -new-name option: must be specified
Index: test/clang-rename/Namespace.cpp
===
--- test/clang-rename/Namespace.cpp
+++ test/clang-rename/Namespace.cpp
@@ -1,5 +1,5 @@
 // RUN: cat %s > %t.cpp
-// RUN: clang-rename -offset=143 -new-name=llvm %t.cpp -i --
+// RUN: clang-rename rename-at -offset=153 -new-name=llvm %t.cpp -i --
 // RUN: sed 's,//.*,,' %t.cpp | FileCheck %s
 
 namespace foo { // CHECK: namespace llvm {
Index: test/clang-rename/MemberExprMacro.cpp
===
--- test/clang-rename/MemberExprMacro.cpp
+++ test/clang-rename/MemberExprMacro.cpp
@@ -1,5 +1,5 @@
 // RUN: cat %s > %t.cpp
-// RUN: clang-rename -offset=156 -new-name=Bar %t.cpp -i --
+// RUN: clang-rename rename-at -offset=166 -new-name=Bar %t.cpp -i --
 // RUN: sed 's,//.*,,' %t.cpp | FileCheck %s
 
 class Baz {
Index: test/clang-rename/InvalidNewName.cpp
===
--- test/clang-rename/InvalidNewName.cpp
+++ test/clang-rename/InvalidNewName.cpp
@@ -1,2 +1,2 @@
-// RUN: not clang-rename -new-name=class -offset=133 %s 2>&1 | FileCheck %s
+// RUN: not clang-rename rename-at -new-name=class -offset=133 %s 2>&1 | FileCheck %s
 // CHECK: ERROR: new name is not a valid identifier in  C++17.
Index: test/clang-rename/FunctionMacro.cpp
===
--- test/clang-rename/FunctionMacro.cpp
+++ test/clang-rename/FunctionMacro.cpp
@@ -1,5 +1,5 @@
 // RUN: cat %s > %t.cp

Re: [PATCH] D21814: clang-rename: split existing options into two new subcommands

2016-07-22 Thread Miklos Vajna via cfe-commits
vmiklos added inline comments.


Comment at: clang-rename/RenamingAction.cpp:48
@@ +47,3 @@
+for (unsigned I = 0; I < NewNameList.size(); ++I) {
+  HandleOneRename(Context, NewNameList[I], PrevNameList[I], USRList[I]);
+}

klimek wrote:
> Question is whether if we go down that route we shouldn't do one search for 
> all the names, instead of re-looping for each name.
You mean improving USRLocFindingASTVisitor, so that it can work with a list of 
USRs, not with just a single USR? I can do that, but if possible, I would like 
to do that as a follow-up patch; it was called in a loop already before this 
patch, so sounds orthogonal. (And it would potentially conflict with any 
pending patches that touch that class.)

I could fold HandleOneRename() into HandleTranslationUnit(), but that just 
makes the resulting function larger, and does not get rid of the looping. Or is 
that what you want?


https://reviews.llvm.org/D21814



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D21814: clang-rename: split existing options into two new subcommands

2016-07-21 Thread Miklos Vajna via cfe-commits
vmiklos updated this revision to Diff 64941.

https://reviews.llvm.org/D21814

Files:
  clang-rename/RenamingAction.cpp
  clang-rename/RenamingAction.h
  clang-rename/tool/ClangRename.cpp
  clang-rename/tool/clang-rename.py
  docs/clang-rename.rst
  test/clang-rename/ClassFindByName.cpp
  test/clang-rename/ClassReplacements.cpp
  test/clang-rename/ClassSimpleRenaming.cpp
  test/clang-rename/ClassTestMulti.cpp
  test/clang-rename/ClassTestMultiByName.cpp
  test/clang-rename/ConstCastExpr.cpp
  test/clang-rename/ConstructExpr.cpp
  test/clang-rename/CtorFindByDeclaration.cpp
  test/clang-rename/CtorFindByDefinition.cpp
  test/clang-rename/CtorInitializer.cpp
  test/clang-rename/DeclRefExpr.cpp
  test/clang-rename/DtorDeclaration.cpp
  test/clang-rename/DtorDefinition.cpp
  test/clang-rename/DynamicCastExpr.cpp
  test/clang-rename/Field.cpp
  test/clang-rename/FunctionMacro.cpp
  test/clang-rename/InvalidNewName.cpp
  test/clang-rename/MemberExprMacro.cpp
  test/clang-rename/Namespace.cpp
  test/clang-rename/NoNewName.cpp
  test/clang-rename/ReinterpretCastExpr.cpp
  test/clang-rename/StaticCastExpr.cpp
  test/clang-rename/Variable.cpp
  test/clang-rename/VariableMacro.cpp

Index: test/clang-rename/VariableMacro.cpp
===
--- test/clang-rename/VariableMacro.cpp
+++ test/clang-rename/VariableMacro.cpp
@@ -1,5 +1,5 @@
 // RUN: cat %s > %t.cpp
-// RUN: clang-rename -offset=208 -new-name=Z %t.cpp -i --
+// RUN: clang-rename rename-at -offset=218 -new-name=Z %t.cpp -i --
 // RUN: sed 's,//.*,,' %t.cpp | FileCheck %s
 
 #define Y X // CHECK: #define Y Z
Index: test/clang-rename/Variable.cpp
===
--- test/clang-rename/Variable.cpp
+++ test/clang-rename/Variable.cpp
@@ -1,5 +1,5 @@
 // RUN: cat %s > %t.cpp
-// RUN: clang-rename -offset=148 -new-name=Bar %t.cpp -i --
+// RUN: clang-rename rename-at -offset=158 -new-name=Bar %t.cpp -i --
 // RUN: sed 's,//.*,,' %t.cpp | FileCheck %s
 
 namespace A {
Index: test/clang-rename/StaticCastExpr.cpp
===
--- test/clang-rename/StaticCastExpr.cpp
+++ test/clang-rename/StaticCastExpr.cpp
@@ -1,5 +1,5 @@
 // RUN: cat %s > %t.cpp
-// RUN: clang-rename -offset=152 -new-name=Bar %t.cpp -i --
+// RUN: clang-rename rename-at -offset=162 -new-name=Bar %t.cpp -i --
 // RUN: sed 's,//.*,,' %t.cpp | FileCheck %s
 
 class Baz {
Index: test/clang-rename/ReinterpretCastExpr.cpp
===
--- test/clang-rename/ReinterpretCastExpr.cpp
+++ test/clang-rename/ReinterpretCastExpr.cpp
@@ -1,5 +1,5 @@
 // RUN: cat %s > %t.cpp
-// RUN: clang-rename -offset=133 -new-name=X %t.cpp -i --
+// RUN: clang-rename rename-at -offset=143 -new-name=X %t.cpp -i --
 // RUN: sed 's,//.*,,' %t.cpp | FileCheck %s
 class Cla {
 public:
Index: test/clang-rename/NoNewName.cpp
===
--- test/clang-rename/NoNewName.cpp
+++ test/clang-rename/NoNewName.cpp
@@ -1,4 +1,4 @@
 // Check for an error while -new-name argument has not been passed to
 // clang-rename.
-// RUN: not clang-rename -offset=133 %s 2>&1 | FileCheck %s
-// CHECK: ERROR: no new name provided.
+// RUN: not clang-rename rename-at -offset=133 %s 2>&1 | FileCheck %s
+// CHECK: clang-rename rename-at: for the -new-name option: must be specified
Index: test/clang-rename/Namespace.cpp
===
--- test/clang-rename/Namespace.cpp
+++ test/clang-rename/Namespace.cpp
@@ -1,5 +1,5 @@
 // RUN: cat %s > %t.cpp
-// RUN: clang-rename -offset=143 -new-name=llvm %t.cpp -i --
+// RUN: clang-rename rename-at -offset=153 -new-name=llvm %t.cpp -i --
 // RUN: sed 's,//.*,,' %t.cpp | FileCheck %s
 
 namespace foo { // CHECK: namespace llvm {
Index: test/clang-rename/MemberExprMacro.cpp
===
--- test/clang-rename/MemberExprMacro.cpp
+++ test/clang-rename/MemberExprMacro.cpp
@@ -1,5 +1,5 @@
 // RUN: cat %s > %t.cpp
-// RUN: clang-rename -offset=156 -new-name=Bar %t.cpp -i --
+// RUN: clang-rename rename-at -offset=166 -new-name=Bar %t.cpp -i --
 // RUN: sed 's,//.*,,' %t.cpp | FileCheck %s
 
 class Baz {
Index: test/clang-rename/InvalidNewName.cpp
===
--- test/clang-rename/InvalidNewName.cpp
+++ test/clang-rename/InvalidNewName.cpp
@@ -1,2 +1,2 @@
-// RUN: not clang-rename -new-name=class -offset=133 %s 2>&1 | FileCheck %s
+// RUN: not clang-rename rename-at -new-name=class -offset=133 %s 2>&1 | FileCheck %s
 // CHECK: ERROR: new name is not a valid identifier in  C++17.
Index: test/clang-rename/FunctionMacro.cpp
===
--- test/clang-rename/FunctionMacro.cpp
+++ test/clang-rename/FunctionMacro.cpp
@@ -1,5 +1,5 @@
 // RUN: cat %s > %t.cp

Re: [PATCH] D21814: clang-rename: split existing options into two new subcommands

2016-07-21 Thread Miklos Vajna via cfe-commits
vmiklos added a comment.

Rebased on top of r276282 and resolved conflicts.


https://reviews.llvm.org/D21814



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D21814: clang-rename: split existing options into two new subcommands

2016-07-21 Thread Miklos Vajna via cfe-commits
vmiklos marked an inline comment as done.
vmiklos added a comment.

https://reviews.llvm.org/D21814



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D21814: clang-rename: split existing options into two new subcommands

2016-07-21 Thread Miklos Vajna via cfe-commits
vmiklos added a comment.

> The patch looks fine to me (though I'm not sure if there are no new tests; if

>  they are interface changes should be applied).


`make check-clang-tools` + the patch at r276098 passes for me at least. But any
pending test should be trivial to adapt.

> P.S. it seems logical to me to support `-offset` option in `-rename-all`,

>  too.


OK, I've added that, with a testcase.

> And introducing `-rename-all` without actually supporting multiple

>  renaming actions "at once" seems weird to me, too.


OK, I've squashed the original diff into this one, with a testcase, which
addresses this.

A nice side-effect is that now the option parser takes care of checking if
-new-name is provided, no need to have explicit code for that in clang-rename.

> use std::function here?


Done, also changed the `typedef` to `using`.


https://reviews.llvm.org/D21814



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D21814: clang-rename: split existing options into two new subcommands

2016-07-21 Thread Miklos Vajna via cfe-commits
vmiklos updated this revision to Diff 64859.

https://reviews.llvm.org/D21814

Files:
  clang-rename/RenamingAction.cpp
  clang-rename/RenamingAction.h
  clang-rename/tool/ClangRename.cpp
  clang-rename/tool/clang-rename.py
  docs/clang-rename.rst
  test/clang-rename/ClassFindByName.cpp
  test/clang-rename/ClassReplacements.cpp
  test/clang-rename/ClassSimpleRenaming.cpp
  test/clang-rename/ClassTestMulti.cpp
  test/clang-rename/ClassTestMultiByName.cpp
  test/clang-rename/ConstCastExpr.cpp
  test/clang-rename/ConstructExpr.cpp
  test/clang-rename/CtorFindByDeclaration.cpp
  test/clang-rename/CtorFindByDefinition.cpp
  test/clang-rename/CtorInitializer.cpp
  test/clang-rename/DeclRefExpr.cpp
  test/clang-rename/DtorDeclaration.cpp
  test/clang-rename/DtorDefinition.cpp
  test/clang-rename/DynamicCastExpr.cpp
  test/clang-rename/Field.cpp
  test/clang-rename/FunctionMacro.cpp
  test/clang-rename/MemberExprMacro.cpp
  test/clang-rename/Namespace.cpp
  test/clang-rename/NoNewName.cpp
  test/clang-rename/ReinterpretCastExpr.cpp
  test/clang-rename/StaticCastExpr.cpp
  test/clang-rename/Variable.cpp
  test/clang-rename/VariableMacro.cpp

Index: test/clang-rename/VariableMacro.cpp
===
--- test/clang-rename/VariableMacro.cpp
+++ test/clang-rename/VariableMacro.cpp
@@ -1,5 +1,5 @@
 // RUN: cat %s > %t.cpp
-// RUN: clang-rename -offset=208 -new-name=Z %t.cpp -i --
+// RUN: clang-rename rename-at -offset=218 -new-name=Z %t.cpp -i --
 // RUN: sed 's,//.*,,' %t.cpp | FileCheck %s
 
 #define Y X // CHECK: #define Y Z
Index: test/clang-rename/Variable.cpp
===
--- test/clang-rename/Variable.cpp
+++ test/clang-rename/Variable.cpp
@@ -1,5 +1,5 @@
 // RUN: cat %s > %t.cpp
-// RUN: clang-rename -offset=148 -new-name=Bar %t.cpp -i --
+// RUN: clang-rename rename-at -offset=158 -new-name=Bar %t.cpp -i --
 // RUN: sed 's,//.*,,' %t.cpp | FileCheck %s
 
 namespace A {
Index: test/clang-rename/StaticCastExpr.cpp
===
--- test/clang-rename/StaticCastExpr.cpp
+++ test/clang-rename/StaticCastExpr.cpp
@@ -1,5 +1,5 @@
 // RUN: cat %s > %t.cpp
-// RUN: clang-rename -offset=152 -new-name=Bar %t.cpp -i --
+// RUN: clang-rename rename-at -offset=162 -new-name=Bar %t.cpp -i --
 // RUN: sed 's,//.*,,' %t.cpp | FileCheck %s
 
 class Baz {
Index: test/clang-rename/ReinterpretCastExpr.cpp
===
--- test/clang-rename/ReinterpretCastExpr.cpp
+++ test/clang-rename/ReinterpretCastExpr.cpp
@@ -1,5 +1,5 @@
 // RUN: cat %s > %t.cpp
-// RUN: clang-rename -offset=133 -new-name=X %t.cpp -i --
+// RUN: clang-rename rename-at -offset=143 -new-name=X %t.cpp -i --
 // RUN: sed 's,//.*,,' %t.cpp | FileCheck %s
 class Cla {
 public:
Index: test/clang-rename/NoNewName.cpp
===
--- test/clang-rename/NoNewName.cpp
+++ test/clang-rename/NoNewName.cpp
@@ -1,4 +1,4 @@
 // Check for an error while -new-name argument has not been passed to
 // clang-rename.
-// RUN: not clang-rename -offset=133 %s 2>&1 | FileCheck %s
-// CHECK: clang-rename: no new name provided.
+// RUN: not clang-rename rename-at -offset=133 %s 2>&1 | FileCheck %s
+// CHECK: clang-rename rename-at: for the -new-name option: must be specified
Index: test/clang-rename/Namespace.cpp
===
--- test/clang-rename/Namespace.cpp
+++ test/clang-rename/Namespace.cpp
@@ -1,5 +1,5 @@
 // RUN: cat %s > %t.cpp
-// RUN: clang-rename -offset=143 -new-name=llvm %t.cpp -i --
+// RUN: clang-rename rename-at -offset=153 -new-name=llvm %t.cpp -i --
 // RUN: sed 's,//.*,,' %t.cpp | FileCheck %s
 
 namespace foo { // CHECK: namespace llvm {
Index: test/clang-rename/MemberExprMacro.cpp
===
--- test/clang-rename/MemberExprMacro.cpp
+++ test/clang-rename/MemberExprMacro.cpp
@@ -1,5 +1,5 @@
 // RUN: cat %s > %t.cpp
-// RUN: clang-rename -offset=156 -new-name=Bar %t.cpp -i --
+// RUN: clang-rename rename-at -offset=166 -new-name=Bar %t.cpp -i --
 // RUN: sed 's,//.*,,' %t.cpp | FileCheck %s
 
 class Baz {
Index: test/clang-rename/FunctionMacro.cpp
===
--- test/clang-rename/FunctionMacro.cpp
+++ test/clang-rename/FunctionMacro.cpp
@@ -1,5 +1,5 @@
 // RUN: cat %s > %t.cpp
-// RUN: clang-rename -offset=199 -new-name=macro_function %t.cpp -i --
+// RUN: clang-rename rename-at -offset=209 -new-name=macro_function %t.cpp -i --
 // RUN: sed 's,//.*,,' %t.cpp | FileCheck %s
 
 #define moo foo // CHECK: #define moo macro_function
Index: test/clang-rename/Field.cpp
===
--- test/clang-rename/Field.cpp
+++ test/clang-rename/Field.cpp
@@ -1,5 +1,5 @@
 // RUN: cat %s > %t.cpp
-// 

Re: [PATCH] D21814: clang-rename: split existing options into two new subcommands

2016-07-21 Thread Miklos Vajna via cfe-commits
vmiklos added a comment.

Is there anything I can help with to get this reviewed, please? As far as I see 
it still applies cleanly on top of current trunk.


https://reviews.llvm.org/D21814



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D21814: clang-rename: split existing options into two new subcommands

2016-07-16 Thread Miklos Vajna via cfe-commits
vmiklos added a comment.

In https://reviews.llvm.org/D21814#486204, @omtcyfz wrote:

> - Can you please update diff? I changed most of the tests recently.


Sure, I actually wanted to ask if those test additions were meant to be test
renames. :-)

> - I think you should update `doc/clang-rename` in this patch (making it a 
> subsequent patch isn't worthy IMO)


Done.

> - Updating `clang-rename/tool/clang-rename.py` (simply add `-rename-at` into 
> the argument list there) seems reasonable.


Done.

> - Also, I'd be happy to see at least few good tests for `-rename-all` with 
> multiple `-old-name` and `-new-name` arguments.


Multiple -old-name / -new-name is not supported yet. I implemented that in the
first diff of this review, but then I was asked to split the two use cases into
separate subcommands first, and only support the multi-rename feature in
rename-all only. So I plan to add that in a subsequent patch. Or should squash
even that into this review?

> - Why does `-rename-at` not have `-export-fixes` option anymore?


The use-case for -export-fixes was that multiple translation units will want to
do the same replacements in common headers, so -i is not a good choice there.
Instead using -export-fixes, and then letting clang-apply-replacements do the
deduplication is the way to go. From this point of view, -export-fixes is not
useful for the rename-at / single TU use-case. But no problem, I've added it
back.

> - Is there really a need to dispatch `main` to `renameAtMain` and 
> `renameAllMain`? Most of the code is exactly the same (apart from YAML dump 
> absence in `renameAtMain`, which I do not understand).


The first idea was to use two separate binaries for rename-at/rename-all. Then
a compromise was to still have the same binary, but separate subcommands. So I
thought it's considered good to have a separate implementation of the separate
subcommands. But I'm happy if sharing code between rename-at and rename-all is
still OK, I've changed that.


https://reviews.llvm.org/D21814



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D21814: clang-rename: split existing options into two new subcommands

2016-07-16 Thread Miklos Vajna via cfe-commits
vmiklos updated this revision to Diff 64231.

https://reviews.llvm.org/D21814

Files:
  clang-rename/tool/ClangRename.cpp
  clang-rename/tool/clang-rename.py
  docs/clang-rename.rst
  test/clang-rename/ClassFindByName.cpp
  test/clang-rename/ClassReplacements.cpp
  test/clang-rename/ClassSimpleRenaming.cpp
  test/clang-rename/ConstCastExpr.cpp
  test/clang-rename/ConstructExpr.cpp
  test/clang-rename/CtorFindByDeclaration.cpp
  test/clang-rename/CtorFindByDefinition.cpp
  test/clang-rename/CtorInitializer.cpp
  test/clang-rename/DeclRefExpr.cpp
  test/clang-rename/DtorDeclaration.cpp
  test/clang-rename/DtorDefinition.cpp
  test/clang-rename/DynamicCastExpr.cpp
  test/clang-rename/Field.cpp
  test/clang-rename/FunctionMacro.cpp
  test/clang-rename/MemberExprMacro.cpp
  test/clang-rename/Namespace.cpp
  test/clang-rename/NoNewName.cpp
  test/clang-rename/ReinterpretCastExpr.cpp
  test/clang-rename/StaticCastExpr.cpp
  test/clang-rename/Variable.cpp
  test/clang-rename/VariableMacro.cpp

Index: test/clang-rename/VariableMacro.cpp
===
--- test/clang-rename/VariableMacro.cpp
+++ test/clang-rename/VariableMacro.cpp
@@ -1,5 +1,5 @@
 // RUN: cat %s > %t.cpp
-// RUN: clang-rename -offset=208 -new-name=Z %t.cpp -i --
+// RUN: clang-rename rename-at -offset=218 -new-name=Z %t.cpp -i --
 // RUN: sed 's,//.*,,' %t.cpp | FileCheck %s
 
 #define Y X // CHECK: #define Y Z
Index: test/clang-rename/Variable.cpp
===
--- test/clang-rename/Variable.cpp
+++ test/clang-rename/Variable.cpp
@@ -1,5 +1,5 @@
 // RUN: cat %s > %t.cpp
-// RUN: clang-rename -offset=148 -new-name=Bar %t.cpp -i --
+// RUN: clang-rename rename-at -offset=158 -new-name=Bar %t.cpp -i --
 // RUN: sed 's,//.*,,' %t.cpp | FileCheck %s
 
 namespace A {
Index: test/clang-rename/StaticCastExpr.cpp
===
--- test/clang-rename/StaticCastExpr.cpp
+++ test/clang-rename/StaticCastExpr.cpp
@@ -1,5 +1,5 @@
 // RUN: cat %s > %t.cpp
-// RUN: clang-rename -offset=152 -new-name=Bar %t.cpp -i --
+// RUN: clang-rename rename-at -offset=162 -new-name=Bar %t.cpp -i --
 // RUN: sed 's,//.*,,' %t.cpp | FileCheck %s
 
 class Baz {
Index: test/clang-rename/ReinterpretCastExpr.cpp
===
--- test/clang-rename/ReinterpretCastExpr.cpp
+++ test/clang-rename/ReinterpretCastExpr.cpp
@@ -1,5 +1,5 @@
 // RUN: cat %s > %t.cpp
-// RUN: clang-rename -offset=133 -new-name=X %t.cpp -i --
+// RUN: clang-rename rename-at -offset=143 -new-name=X %t.cpp -i --
 // RUN: sed 's,//.*,,' %t.cpp | FileCheck %s
 class Cla {
 public:
Index: test/clang-rename/NoNewName.cpp
===
--- test/clang-rename/NoNewName.cpp
+++ test/clang-rename/NoNewName.cpp
@@ -1,4 +1,4 @@
 // Check for an error while -new-name argument has not been passed to
 // clang-rename.
-// RUN: not clang-rename -offset=133 %s 2>&1 | FileCheck %s
+// RUN: not clang-rename rename-at -offset=133 %s 2>&1 | FileCheck %s
 // CHECK: clang-rename: no new name provided.
Index: test/clang-rename/Namespace.cpp
===
--- test/clang-rename/Namespace.cpp
+++ test/clang-rename/Namespace.cpp
@@ -1,5 +1,5 @@
 // RUN: cat %s > %t.cpp
-// RUN: clang-rename -offset=143 -new-name=llvm %t.cpp -i --
+// RUN: clang-rename rename-at -offset=153 -new-name=llvm %t.cpp -i --
 // RUN: sed 's,//.*,,' %t.cpp | FileCheck %s
 
 namespace foo { // CHECK: namespace llvm {
Index: test/clang-rename/MemberExprMacro.cpp
===
--- test/clang-rename/MemberExprMacro.cpp
+++ test/clang-rename/MemberExprMacro.cpp
@@ -1,5 +1,5 @@
 // RUN: cat %s > %t.cpp
-// RUN: clang-rename -offset=156 -new-name=Bar %t.cpp -i --
+// RUN: clang-rename rename-at -offset=166 -new-name=Bar %t.cpp -i --
 // RUN: sed 's,//.*,,' %t.cpp | FileCheck %s
 
 class Baz {
Index: test/clang-rename/FunctionMacro.cpp
===
--- test/clang-rename/FunctionMacro.cpp
+++ test/clang-rename/FunctionMacro.cpp
@@ -1,5 +1,5 @@
 // RUN: cat %s > %t.cpp
-// RUN: clang-rename -offset=199 -new-name=macro_function %t.cpp -i --
+// RUN: clang-rename rename-at -offset=209 -new-name=macro_function %t.cpp -i --
 // RUN: sed 's,//.*,,' %t.cpp | FileCheck %s
 
 #define moo foo // CHECK: #define moo macro_function
Index: test/clang-rename/Field.cpp
===
--- test/clang-rename/Field.cpp
+++ test/clang-rename/Field.cpp
@@ -1,5 +1,5 @@
 // RUN: cat %s > %t.cpp
-// RUN: clang-rename -offset=148 -new-name=Bar %t.cpp -i --
+// RUN: clang-rename rename-at -offset=158 -new-name=Bar %t.cpp -i --
 // RUN: sed 's,//.*,,' %t.cpp | FileCheck %s
 
 class Baz {
Index: test/clang-rename/DynamicCastExpr

Re: [PATCH] D22237: clang-rename: fix renaming member functions

2016-07-16 Thread Miklos Vajna via cfe-commits
vmiklos abandoned this revision.
vmiklos added a comment.

I see your point, then let me abandon this.


https://reviews.llvm.org/D22237



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D21814: clang-rename: split existing options into two new subcommands

2016-07-15 Thread Miklos Vajna via cfe-commits
vmiklos added a comment.

I've implemented the requested split of options, now there are two new 
rename-at and rename-all subcommands. The only common options is -i and 
-new-name, nothing else is shared, apart from the common options added by 
`tooling::CommonOptionsParser`. The code is modeled after `llvm-cov`, that way 
I could break the chicken-and-egg problem I outlined in my previous comment.

I've also updated all tests to use either of the two subcommands.

For now I did not touch documentation, though that'll be obviously the next 
step, I just didn't want to make this patch larger than necessary. :-)


https://reviews.llvm.org/D21814



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D21814: clang-rename: support multiple renames with one invocation

2016-07-15 Thread Miklos Vajna via cfe-commits
vmiklos updated this revision to Diff 64204.

https://reviews.llvm.org/D21814

Files:
  clang-rename/tool/ClangRename.cpp
  test/clang-rename/ClassFindByName.cpp
  test/clang-rename/ClassReplacements.cpp
  test/clang-rename/ClassSimpleRenaming.cpp
  test/clang-rename/ClassTest.cpp
  test/clang-rename/ClassTestByName.cpp
  test/clang-rename/ClassTestReplacements.cpp
  test/clang-rename/ConstCastExpr.cpp
  test/clang-rename/ConstructExpr.cpp
  test/clang-rename/CtorDefTest.cpp
  test/clang-rename/CtorFindByDeclaration.cpp
  test/clang-rename/CtorFindByDefinition.cpp
  test/clang-rename/CtorInitializer.cpp
  test/clang-rename/CtorInitializerTest.cpp
  test/clang-rename/DeclRefExpr.cpp
  test/clang-rename/DtorDeclaration.cpp
  test/clang-rename/DtorDefTest.cpp
  test/clang-rename/DtorDefinition.cpp
  test/clang-rename/DynamicCastExpr.cpp
  test/clang-rename/Field.cpp
  test/clang-rename/FieldTest.cpp
  test/clang-rename/FunctionMacro.cpp
  test/clang-rename/MemberExprMacro.cpp
  test/clang-rename/Namespace.cpp
  test/clang-rename/NoNewName.cpp
  test/clang-rename/ReinterpretCastExpr.cpp
  test/clang-rename/StaticCastExpr.cpp
  test/clang-rename/VarTest.cpp
  test/clang-rename/Variable.cpp
  test/clang-rename/VariableMacro.cpp

Index: test/clang-rename/VariableMacro.cpp
===
--- test/clang-rename/VariableMacro.cpp
+++ test/clang-rename/VariableMacro.cpp
@@ -1,5 +1,5 @@
 // RUN: cat %s > %t.cpp
-// RUN: clang-rename -offset=208 -new-name=Z %t.cpp -i --
+// RUN: clang-rename rename-at -offset=218 -new-name=Z %t.cpp -i --
 // RUN: sed 's,//.*,,' %t.cpp | FileCheck %s
 
 #define Y X // CHECK: #define Y Z
Index: test/clang-rename/Variable.cpp
===
--- test/clang-rename/Variable.cpp
+++ test/clang-rename/Variable.cpp
@@ -1,5 +1,5 @@
 // RUN: cat %s > %t.cpp
-// RUN: clang-rename -offset=148 -new-name=Bar %t.cpp -i --
+// RUN: clang-rename rename-at -offset=158 -new-name=Bar %t.cpp -i --
 // RUN: sed 's,//.*,,' %t.cpp | FileCheck %s
 
 namespace A {
Index: test/clang-rename/VarTest.cpp
===
--- test/clang-rename/VarTest.cpp
+++ test/clang-rename/VarTest.cpp
@@ -1,5 +1,5 @@
 // RUN: cat %s > %t.cpp
-// RUN: clang-rename -offset=150 -new-name=hector %t.cpp -i --
+// RUN: clang-rename rename-at -offset=160 -new-name=hector %t.cpp -i --
 // RUN: sed 's,//.*,,' %t.cpp | FileCheck %s
 namespace A { int foo;  // CHECK: int hector;
 }
Index: test/clang-rename/StaticCastExpr.cpp
===
--- test/clang-rename/StaticCastExpr.cpp
+++ test/clang-rename/StaticCastExpr.cpp
@@ -1,5 +1,5 @@
 // RUN: cat %s > %t.cpp
-// RUN: clang-rename -offset=150 -new-name=X %t.cpp -i --
+// RUN: clang-rename rename-at -offset=160 -new-name=X %t.cpp -i --
 // RUN: sed 's,//.*,,' %t.cpp | FileCheck %s
 class Base {
 };
Index: test/clang-rename/ReinterpretCastExpr.cpp
===
--- test/clang-rename/ReinterpretCastExpr.cpp
+++ test/clang-rename/ReinterpretCastExpr.cpp
@@ -1,5 +1,5 @@
 // RUN: cat %s > %t.cpp
-// RUN: clang-rename -offset=133 -new-name=X %t.cpp -i --
+// RUN: clang-rename rename-at -offset=143 -new-name=X %t.cpp -i --
 // RUN: sed 's,//.*,,' %t.cpp | FileCheck %s
 class Cla {
 public:
Index: test/clang-rename/NoNewName.cpp
===
--- test/clang-rename/NoNewName.cpp
+++ test/clang-rename/NoNewName.cpp
@@ -1,4 +1,4 @@
 // Check for an error while -new-name argument has not been passed to
 // clang-rename.
-// RUN: not clang-rename -offset=133 %s 2>&1 | FileCheck %s
+// RUN: not clang-rename rename-at -offset=133 %s 2>&1 | FileCheck %s
 // CHECK: clang-rename: no new name provided.
Index: test/clang-rename/Namespace.cpp
===
--- test/clang-rename/Namespace.cpp
+++ test/clang-rename/Namespace.cpp
@@ -1,5 +1,5 @@
 // RUN: cat %s > %t.cpp
-// RUN: clang-rename -offset=143 -new-name=llvm %t.cpp -i --
+// RUN: clang-rename rename-at -offset=153 -new-name=llvm %t.cpp -i --
 // RUN: sed 's,//.*,,' %t.cpp | FileCheck %s
 
 namespace foo { // CHECK: namespace llvm {
Index: test/clang-rename/MemberExprMacro.cpp
===
--- test/clang-rename/MemberExprMacro.cpp
+++ test/clang-rename/MemberExprMacro.cpp
@@ -1,5 +1,5 @@
 // RUN: cat %s > %t.cpp
-// RUN: clang-rename -offset=156 -new-name=Bar %t.cpp -i --
+// RUN: clang-rename rename-at -offset=166 -new-name=Bar %t.cpp -i --
 // RUN: sed 's,//.*,,' %t.cpp | FileCheck %s
 
 class Baz {
Index: test/clang-rename/FunctionMacro.cpp
===
--- test/clang-rename/FunctionMacro.cpp
+++ test/clang-rename/FunctionMacro.cpp
@@ -1,5 +1,5 @@
 // RUN: cat %s > %t.cpp
-// RUN:

Re: [PATCH] D21814: clang-rename: support multiple renames with one invocation

2016-07-15 Thread Miklos Vajna via cfe-commits
vmiklos added a comment.

I'm a bit confused.

On one hand, I want to use tooling::CommonOptionsParser to parse the options, 
which needs a cl::OptionCategory as a parameter.

On the other hand, I want to parse the options, based on that I'll know what 
subcommand was requested, and then I can choose the right option category. 
Based on the above example, I want to use an option category that recognizes 
-oldname when "rename-all" is used, and I want an other option category that 
recognizes -offset" when "rename-at" is used.

I sense a chicken-and-egg problem, the argument of CommonOptionsParser needs 
the category, but I'll only know the correct category after I called 
CommonOptionsParser. Or is there a way out of this? ;-)


https://reviews.llvm.org/D21814



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D21814: clang-rename: support multiple renames with one invocation

2016-07-15 Thread Miklos Vajna via cfe-commits
vmiklos added a comment.

The alternative is to change the `CommonOptionsParser` ctor to take a vector of 
`OptionCategory&`, and in that case we can add the -extra-arg-before and other 
options to all subcommands, but that means he'll have to adapt all client code, 
i.e. all tools in clang-tools-extra that uses CommonOptionsParser. Is that an 
acceptable cost? Or did I miss some easier way?


https://reviews.llvm.org/D21814



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D22237: clang-rename: fix renaming member functions

2016-07-14 Thread Miklos Vajna via cfe-commits
vmiklos updated this revision to Diff 64027.

https://reviews.llvm.org/D22237

Files:
  clang-rename/USRLocFinder.cpp
  test/clang-rename/VirtualFunction.cpp

Index: test/clang-rename/VirtualFunction.cpp
===
--- /dev/null
+++ test/clang-rename/VirtualFunction.cpp
@@ -0,0 +1,26 @@
+// RUN: cat %s > %t.cpp
+// RUN: clang-rename -offset=163 -new-name=boo %t.cpp -i --
+// RUN: sed 's,//.*,,' %t.cpp | FileCheck %s
+
+class A {
+public:
+  virtual void foo() { } // CHECK: virtual void boo() { }
+};
+
+class B : public A {
+public:
+  void foo() { } // CHECK: void boo() { }
+};
+
+int main() {
+  A a;
+  a.foo(); // CHECK: a.boo();
+
+  B b;
+  b.foo(); // CHECK: b.boo();
+
+  return 0;
+}
+
+// Use grep -FUbo 'foo'  to get the correct offset of foo when changing
+// this file.
Index: clang-rename/USRLocFinder.cpp
===
--- clang-rename/USRLocFinder.cpp
+++ clang-rename/USRLocFinder.cpp
@@ -111,6 +111,11 @@
 return true;
   }
 
+  bool VisitCXXMethodDecl(CXXMethodDecl *Decl) {
+handleCXXMethodDecl(Decl, Decl->getLocation());
+return true;
+  }
+
   // Expression visitors:
 
   bool VisitDeclRefExpr(const DeclRefExpr *Expr) {
@@ -163,6 +168,12 @@
 return handleCXXNamedCastExpr(Expr);
   }
 
+  bool VisitCXXMemberCallExpr(const CXXMemberCallExpr *Expr) {
+CXXMethodDecl *Decl = Expr->getMethodDecl();
+handleCXXMethodDecl(Decl, Expr->getExprLoc());
+return true;
+  }
+
   // Non-visitors:
 
   // \brief Returns a list of unique locations. Duplicate or overlapping
@@ -200,6 +211,21 @@
 return true;
   }
 
+  void handleCXXMethodDecl(const CXXMethodDecl* Decl, SourceLocation Location) 
{
+if (getUSRForDecl(Decl) == USR) {
+  // This member function was requested to be renamed explicitly.
+  LocationsFound.push_back(Location);
+}
+else if (Decl->isVirtual()) {
+  for (auto *OverridenDecl : Decl->overridden_methods()) {
+if (getUSRForDecl(OverridenDecl) == USR) {
+  // This member function overwrites one that is to be renamed.
+  LocationsFound.push_back(Location);
+}
+  }
+}
+  }
+
   // All the locations of the USR were found.
   const std::string USR;
   // Old name that is renamed.


Index: test/clang-rename/VirtualFunction.cpp
===
--- /dev/null
+++ test/clang-rename/VirtualFunction.cpp
@@ -0,0 +1,26 @@
+// RUN: cat %s > %t.cpp
+// RUN: clang-rename -offset=163 -new-name=boo %t.cpp -i --
+// RUN: sed 's,//.*,,' %t.cpp | FileCheck %s
+
+class A {
+public:
+  virtual void foo() { } // CHECK: virtual void boo() { }
+};
+
+class B : public A {
+public:
+  void foo() { } // CHECK: void boo() { }
+};
+
+int main() {
+  A a;
+  a.foo(); // CHECK: a.boo();
+
+  B b;
+  b.foo(); // CHECK: b.boo();
+
+  return 0;
+}
+
+// Use grep -FUbo 'foo'  to get the correct offset of foo when changing
+// this file.
Index: clang-rename/USRLocFinder.cpp
===
--- clang-rename/USRLocFinder.cpp
+++ clang-rename/USRLocFinder.cpp
@@ -111,6 +111,11 @@
 return true;
   }
 
+  bool VisitCXXMethodDecl(CXXMethodDecl *Decl) {
+handleCXXMethodDecl(Decl, Decl->getLocation());
+return true;
+  }
+
   // Expression visitors:
 
   bool VisitDeclRefExpr(const DeclRefExpr *Expr) {
@@ -163,6 +168,12 @@
 return handleCXXNamedCastExpr(Expr);
   }
 
+  bool VisitCXXMemberCallExpr(const CXXMemberCallExpr *Expr) {
+CXXMethodDecl *Decl = Expr->getMethodDecl();
+handleCXXMethodDecl(Decl, Expr->getExprLoc());
+return true;
+  }
+
   // Non-visitors:
 
   // \brief Returns a list of unique locations. Duplicate or overlapping
@@ -200,6 +211,21 @@
 return true;
   }
 
+  void handleCXXMethodDecl(const CXXMethodDecl* Decl, SourceLocation Location) {
+if (getUSRForDecl(Decl) == USR) {
+  // This member function was requested to be renamed explicitly.
+  LocationsFound.push_back(Location);
+}
+else if (Decl->isVirtual()) {
+  for (auto *OverridenDecl : Decl->overridden_methods()) {
+if (getUSRForDecl(OverridenDecl) == USR) {
+  // This member function overwrites one that is to be renamed.
+  LocationsFound.push_back(Location);
+}
+  }
+}
+  }
+
   // All the locations of the USR were found.
   const std::string USR;
   // Old name that is renamed.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D22237: clang-rename: fix renaming member functions

2016-07-14 Thread Miklos Vajna via cfe-commits
vmiklos added a comment.

Forgot to add asserts for main() in the testcase.


https://reviews.llvm.org/D22237



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D22237: clang-rename: fix renaming member functions

2016-07-14 Thread Miklos Vajna via cfe-commits
vmiklos updated this revision to Diff 64025.

https://reviews.llvm.org/D22237

Files:
  clang-rename/USRLocFinder.cpp
  test/clang-rename/VirtualFunction.cpp

Index: test/clang-rename/VirtualFunction.cpp
===
--- /dev/null
+++ test/clang-rename/VirtualFunction.cpp
@@ -0,0 +1,26 @@
+// RUN: cat %s > %t.cpp
+// RUN: clang-rename -offset=163 -new-name=boo %t.cpp -i --
+// RUN: sed 's,//.*,,' %t.cpp | FileCheck %s
+
+class A {
+public:
+  virtual void foo() { } // CHECK: virtual void boo() { }
+};
+
+class B : public A {
+public:
+  void foo() { } // CHECK: void boo() { }
+};
+
+int main() {
+  A a;
+  a.foo();
+
+  B b;
+  b.foo();
+
+  return 0;
+}
+
+// Use grep -FUbo 'foo'  to get the correct offset of foo when changing
+// this file.
Index: clang-rename/USRLocFinder.cpp
===
--- clang-rename/USRLocFinder.cpp
+++ clang-rename/USRLocFinder.cpp
@@ -111,6 +111,11 @@
 return true;
   }
 
+  bool VisitCXXMethodDecl(CXXMethodDecl *Decl) {
+handleCXXMethodDecl(Decl, Decl->getLocation());
+return true;
+  }
+
   // Expression visitors:
 
   bool VisitDeclRefExpr(const DeclRefExpr *Expr) {
@@ -163,6 +168,12 @@
 return handleCXXNamedCastExpr(Expr);
   }
 
+  bool VisitCXXMemberCallExpr(const CXXMemberCallExpr *Expr) {
+CXXMethodDecl *Decl = Expr->getMethodDecl();
+handleCXXMethodDecl(Decl, Expr->getExprLoc());
+return true;
+  }
+
   // Non-visitors:
 
   // \brief Returns a list of unique locations. Duplicate or overlapping
@@ -200,6 +211,21 @@
 return true;
   }
 
+  void handleCXXMethodDecl(const CXXMethodDecl* Decl, SourceLocation Location) 
{
+if (getUSRForDecl(Decl) == USR) {
+  // This member function was requested to be renamed explicitly.
+  LocationsFound.push_back(Location);
+}
+else if (Decl->isVirtual()) {
+  for (auto *OverridenDecl : Decl->overridden_methods()) {
+if (getUSRForDecl(OverridenDecl) == USR) {
+  // This member function overwrites one that is to be renamed.
+  LocationsFound.push_back(Location);
+}
+  }
+}
+  }
+
   // All the locations of the USR were found.
   const std::string USR;
   // Old name that is renamed.


Index: test/clang-rename/VirtualFunction.cpp
===
--- /dev/null
+++ test/clang-rename/VirtualFunction.cpp
@@ -0,0 +1,26 @@
+// RUN: cat %s > %t.cpp
+// RUN: clang-rename -offset=163 -new-name=boo %t.cpp -i --
+// RUN: sed 's,//.*,,' %t.cpp | FileCheck %s
+
+class A {
+public:
+  virtual void foo() { } // CHECK: virtual void boo() { }
+};
+
+class B : public A {
+public:
+  void foo() { } // CHECK: void boo() { }
+};
+
+int main() {
+  A a;
+  a.foo();
+
+  B b;
+  b.foo();
+
+  return 0;
+}
+
+// Use grep -FUbo 'foo'  to get the correct offset of foo when changing
+// this file.
Index: clang-rename/USRLocFinder.cpp
===
--- clang-rename/USRLocFinder.cpp
+++ clang-rename/USRLocFinder.cpp
@@ -111,6 +111,11 @@
 return true;
   }
 
+  bool VisitCXXMethodDecl(CXXMethodDecl *Decl) {
+handleCXXMethodDecl(Decl, Decl->getLocation());
+return true;
+  }
+
   // Expression visitors:
 
   bool VisitDeclRefExpr(const DeclRefExpr *Expr) {
@@ -163,6 +168,12 @@
 return handleCXXNamedCastExpr(Expr);
   }
 
+  bool VisitCXXMemberCallExpr(const CXXMemberCallExpr *Expr) {
+CXXMethodDecl *Decl = Expr->getMethodDecl();
+handleCXXMethodDecl(Decl, Expr->getExprLoc());
+return true;
+  }
+
   // Non-visitors:
 
   // \brief Returns a list of unique locations. Duplicate or overlapping
@@ -200,6 +211,21 @@
 return true;
   }
 
+  void handleCXXMethodDecl(const CXXMethodDecl* Decl, SourceLocation Location) {
+if (getUSRForDecl(Decl) == USR) {
+  // This member function was requested to be renamed explicitly.
+  LocationsFound.push_back(Location);
+}
+else if (Decl->isVirtual()) {
+  for (auto *OverridenDecl : Decl->overridden_methods()) {
+if (getUSRForDecl(OverridenDecl) == USR) {
+  // This member function overwrites one that is to be renamed.
+  LocationsFound.push_back(Location);
+}
+  }
+}
+  }
+
   // All the locations of the USR were found.
   const std::string USR;
   // Old name that is renamed.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D22102: [clang-rename] extend testset

2016-07-14 Thread Miklos Vajna via cfe-commits
vmiklos added a subscriber: vmiklos.
vmiklos added a comment.

Can you please avoid adding VirtualFunction.cpp? http://reviews.llvm.org/D22237 
would add it as well, but without the FIXME. Thanks! :-)


http://reviews.llvm.org/D22102



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D22237: clang-rename: fix renaming member functions

2016-07-11 Thread Miklos Vajna via cfe-commits
vmiklos created this revision.
vmiklos added a reviewer: klimek.
vmiklos added a subscriber: cfe-commits.

Testcase by Kirill Bobyrev.

http://reviews.llvm.org/D22237

Files:
  clang-rename/USRLocFinder.cpp
  test/clang-rename/VirtualFunction.cpp

Index: test/clang-rename/VirtualFunction.cpp
===
--- /dev/null
+++ test/clang-rename/VirtualFunction.cpp
@@ -0,0 +1,16 @@
+// RUN: cat %s > %t.cpp
+// RUN: clang-rename -offset=163 -new-name=boo %t.cpp -i --
+// RUN: sed 's,//.*,,' %t.cpp | FileCheck %s
+
+class A {
+public:
+  virtual void foo(); // CHECK: virtual void boo();
+};
+
+class B : public A {
+public:
+  void foo(); // CHECK: void boo();
+};
+
+// Use grep -FUbo 'foo'  to get the correct offset of foo when changing
+// this file.
Index: clang-rename/USRLocFinder.cpp
===
--- clang-rename/USRLocFinder.cpp
+++ clang-rename/USRLocFinder.cpp
@@ -161,6 +161,22 @@
 return handleCXXNamedCastExpr(Expr);
   }
 
+  bool VisitCXXMethodDecl(CXXMethodDecl *Decl) {
+if (getUSRForDecl(Decl) == USR) {
+  // This member function was requested to be renamed explicitly.
+  LocationsFound.push_back(Decl->getLocation());
+} else if (Decl->isVirtual()) {
+  for (auto *OverridenDecl : Decl->overridden_methods()) {
+if (getUSRForDecl(OverridenDecl) == USR) {
+  // This member function overwrites one that is to be renamed.
+  LocationsFound.push_back(Decl->getLocation());
+}
+  }
+}
+
+return true;
+  }
+
   // Non-visitors:
 
   // \brief Returns a list of unique locations. Duplicate or overlapping


Index: test/clang-rename/VirtualFunction.cpp
===
--- /dev/null
+++ test/clang-rename/VirtualFunction.cpp
@@ -0,0 +1,16 @@
+// RUN: cat %s > %t.cpp
+// RUN: clang-rename -offset=163 -new-name=boo %t.cpp -i --
+// RUN: sed 's,//.*,,' %t.cpp | FileCheck %s
+
+class A {
+public:
+  virtual void foo(); // CHECK: virtual void boo();
+};
+
+class B : public A {
+public:
+  void foo(); // CHECK: void boo();
+};
+
+// Use grep -FUbo 'foo'  to get the correct offset of foo when changing
+// this file.
Index: clang-rename/USRLocFinder.cpp
===
--- clang-rename/USRLocFinder.cpp
+++ clang-rename/USRLocFinder.cpp
@@ -161,6 +161,22 @@
 return handleCXXNamedCastExpr(Expr);
   }
 
+  bool VisitCXXMethodDecl(CXXMethodDecl *Decl) {
+if (getUSRForDecl(Decl) == USR) {
+  // This member function was requested to be renamed explicitly.
+  LocationsFound.push_back(Decl->getLocation());
+} else if (Decl->isVirtual()) {
+  for (auto *OverridenDecl : Decl->overridden_methods()) {
+if (getUSRForDecl(OverridenDecl) == USR) {
+  // This member function overwrites one that is to be renamed.
+  LocationsFound.push_back(Decl->getLocation());
+}
+  }
+}
+
+return true;
+  }
+
   // Non-visitors:
 
   // \brief Returns a list of unique locations. Duplicate or overlapping
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D21814: clang-rename: support multiple renames with one invocation

2016-07-08 Thread Miklos Vajna via cfe-commits
vmiklos added a comment.

As far as I see `tooling::CommonOptionsParser` (in its current form) does not 
handle cl::SubCommand instances. Should I fix that or would it be OK to switch 
to using `cl::ParseCommandLineOptions` directly in clang-rename?


http://reviews.llvm.org/D21814



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D22091: [clang-rename] exit code-related bugfix and code cleanup

2016-07-08 Thread Miklos Vajna via cfe-commits
vmiklos added a comment.

In http://reviews.llvm.org/D22091#476756, @vmiklos wrote:

> Can you please postpone the cleanup till http://reviews.llvm.org/D21814 is 
> reviewed? The two patches conflict with each other, I fear. Thanks. :-)


Ignore this, that one won't land as-is after all.


http://reviews.llvm.org/D22091



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D21814: clang-rename: support multiple renames with one invocation

2016-07-07 Thread Miklos Vajna via cfe-commits
vmiklos added a comment.

Kirill: OK, so you're in the camp marked as b) by Manuel. Sure, the vim 
integration is nice (I'm also a vim user), now that you mentioned it, I need to 
go and try it myself. ;-) Given the above patch, probably it's obvious that I'm 
more in camp a). I don't insist on having that in a tool named `clang-rename`, 
though.

Hmm, so here is the summary of the comments so far, as far as I understand:

- Manuel: it's OK to handle multiple renames with a single command-line 
invocation, but not sure if clang-rename should do that, or if it should be a 
separate tool
- Benjamin: no problem with clang-rename having this feature
- Kirill: clang-rename should definitely not have this feature.

What's the consensus, should I rework this patch, so that it doesn't touch 
`tool/ClangRename.cpp`, but adds a new tool (named e.g. `clang-multi-rename`, 
still linking to `clangRename`)? I can do that, but it would be good to hear 
first if it is worth the effort, or there would be still "the patch is correct, 
but it's not the way to go" style comments. :-)

Thanks.


http://reviews.llvm.org/D21814



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D22091: [clang-rename] exit code-related bugfix and code cleanup

2016-07-07 Thread Miklos Vajna via cfe-commits
vmiklos added a subscriber: vmiklos.
vmiklos added a comment.

Can you please postpone the cleanup till http://reviews.llvm.org/D21814 is 
reviewed? The two patches conflict with each other, I fear. Thanks. :-)


http://reviews.llvm.org/D22091



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D21814: clang-rename: support multiple renames with one invocation

2016-07-05 Thread Miklos Vajna via cfe-commits
vmiklos added a comment.

Manuel, do you have an opinion on this, please?


http://reviews.llvm.org/D21814



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


  1   2   >